fix installation script (#204)
This commit is contained in:
parent
94bbc44960
commit
eebc24086b
116
install.sh
116
install.sh
@ -6,73 +6,73 @@ BIN_PATH="$BIN_DIR/$APP_NAME"
|
|||||||
PLATFORM="$(uname)"
|
PLATFORM="$(uname)"
|
||||||
|
|
||||||
if [ $PLATFORM == "Darwin" ]; then
|
if [ $PLATFORM == "Darwin" ]; then
|
||||||
PLATFORM="macos-x86-64"
|
PLATFORM="macos-x86-64"
|
||||||
elif [ $PLATFORM == "Linux" ]; then
|
elif [ $PLATFORM == "Linux" ]; then
|
||||||
PLATFORM="ubuntu-20_04-x86-64"
|
PLATFORM="ubuntu-20_04-x86-64"
|
||||||
else
|
else
|
||||||
echo "Scripted installation on your platform is not supported."
|
echo "Scripted installation on your platform is not supported."
|
||||||
echo "See compiled binaries in the latest release: https://github.com/$APP_NAME/$APP_NAME/releases/latest"
|
echo "See compiled binaries in the latest release: https://github.com/$APP_NAME/$APP_NAME/releases/latest"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# / Prepare to upgrade from v0 to v1
|
# / Prepare to upgrade from v0 to v1
|
||||||
|
|
||||||
# Determine path of chat binary
|
# Determine path of chat binary
|
||||||
if [[ -n "$(which $APP_NAME)" ]]; then
|
if [[ -n "$(which $APP_NAME)" ]]; then
|
||||||
binary=$(which $APP_NAME)
|
binary=$(which $APP_NAME)
|
||||||
elif [[ -f "$BIN_PATH" ]]; then
|
elif [[ -f "$BIN_PATH" ]]; then
|
||||||
binary=$BIN_PATH
|
binary=$BIN_PATH
|
||||||
else
|
else
|
||||||
binary=""
|
binary=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If chat binary not found, check v0 initial migration and offer to abort or continue
|
# If chat binary not found, check v0 initial migration and offer to abort or continue
|
||||||
if [[ -z $binary ]]; then
|
if [[ -z $binary ]]; then
|
||||||
agent_db="$HOME/.simplex/simplex.agent.db"
|
agent_db="$HOME/.simplex/simplex.agent.db"
|
||||||
if [[ \
|
if [[ \
|
||||||
-f "$agent_db" && \
|
-f "$agent_db" && \
|
||||||
$(echo "select * from migrations;" | sqlite3 $agent_db | grep 20210101_initial) \
|
$(echo "select * from migrations;" | sqlite3 $agent_db | grep 20210101_initial) \
|
||||||
]]; then
|
]]; then
|
||||||
echo "Warning: found SimpleX Chat database, the current version is not backwards compatible."
|
echo "Warning: found SimpleX Chat database, the current version is not backwards compatible."
|
||||||
echo "If you continue, the current version will be installed as $APP_NAME with a clean database, the old database will be preserved."
|
echo "If you continue, the current version will be installed as $APP_NAME with a clean database, the old database will be preserved."
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Please choose to (a)bort or (c)ontinue: " yn
|
read -p "Please choose to (a)bort or (c)ontinue: " yn < /dev/tty
|
||||||
case $yn in
|
case $yn in
|
||||||
[Aa]* ) exit 1 ;;
|
[Aa]* ) exit 1 ;;
|
||||||
[Cc]* ) break ;;
|
[Cc]* ) break ;;
|
||||||
* ) echo "Please answer 'a' or 'c'."
|
* ) echo "Please answer 'a' or 'c'."
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
# If chat binary found, check version and offer to abort or continue, on continue rename chat binary
|
# If chat binary found, check version and offer to abort or continue, on continue rename chat binary
|
||||||
elif [[ ! $($binary -h | grep v1) ]]; then
|
elif [[ ! $($binary -h | grep v1) ]]; then
|
||||||
echo "Warning: found a previous version of SimpleX Chat, the current version is not backwards compatible."
|
echo "Warning: found a previous version of SimpleX Chat, the current version is not backwards compatible."
|
||||||
echo "If you continue, it will be renamed to $APP_NAME-v0, and the new version will be installed as $APP_NAME with a clean database."
|
echo "If you continue, it will be renamed to $APP_NAME-v0, and the new version will be installed as $APP_NAME with a clean database."
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Please choose (a)bort or (c)ontinue: " yn
|
read -p "Please choose (a)bort or (c)ontinue: " yn < /dev/tty
|
||||||
case $yn in
|
case $yn in
|
||||||
[Aa]* ) exit 1 ;;
|
[Aa]* ) exit 1 ;;
|
||||||
[Cc]* )
|
[Cc]* )
|
||||||
binary_v0="$binary-v0"
|
binary_v0="$binary-v0"
|
||||||
mv ${binary} ${binary_v0}
|
mv ${binary} ${binary_v0}
|
||||||
echo "Renamed $binary into $binary_v0"
|
echo "Renamed $binary into $binary_v0"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
* ) echo "Please answer 'a' or 'c'."
|
* ) echo "Please answer 'a' or 'c'."
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
# Prepare to upgrade from v0 to v1 /
|
# Prepare to upgrade from v0 to v1 /
|
||||||
|
|
||||||
[ ! -d $BIN_DIR ] && mkdir -p $BIN_DIR
|
[[ ! -d $BIN_DIR ]] && mkdir -p $BIN_DIR
|
||||||
|
|
||||||
if [ -n "$(command -v curl)" ]; then
|
if [ -n "$(command -v curl)" ]; then
|
||||||
curl -L -o $BIN_PATH "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
|
curl -L -o $BIN_PATH "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
|
||||||
elif [ -n "$(command -v wget)" ]; then
|
elif [ -n "$(command -v wget)" ]; then
|
||||||
wget -O $BIN_PATH "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
|
wget -O $BIN_PATH "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
|
||||||
else
|
else
|
||||||
echo "Cannot download $APP_NAME - please install curl or wget"
|
echo "Cannot download $APP_NAME - please install curl or wget"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x $BIN_PATH
|
chmod +x $BIN_PATH
|
||||||
@ -80,19 +80,19 @@ chmod +x $BIN_PATH
|
|||||||
echo "$APP_NAME installed sucesfully!"
|
echo "$APP_NAME installed sucesfully!"
|
||||||
|
|
||||||
if [ -z "$(command -v $APP_NAME)" ]; then
|
if [ -z "$(command -v $APP_NAME)" ]; then
|
||||||
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
|
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
|
||||||
SHELL_FILE="$HOME/.zshrc"
|
SHELL_FILE="$HOME/.zshrc"
|
||||||
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
|
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
|
||||||
SHELL_FILE="$HOME/.bashrc"
|
SHELL_FILE="$HOME/.bashrc"
|
||||||
else
|
else
|
||||||
echo "Unknown shell - cannot add $APP_NAME folder to PATH"
|
echo "Unknown shell - cannot add $APP_NAME folder to PATH"
|
||||||
echo "Please add $BIN_DIR to PATH variable"
|
echo "Please add $BIN_DIR to PATH variable"
|
||||||
echo "Or you can run $APP_NAME via full path: $BIN_PATH"
|
echo "Or you can run $APP_NAME via full path: $BIN_PATH"
|
||||||
fi
|
fi
|
||||||
if [ -n "$SHELL_FILE" ]; then
|
if [ -n "$SHELL_FILE" ]; then
|
||||||
echo "export PATH=\$PATH:$BIN_DIR" >> $SHELL_FILE
|
echo "export PATH=\$PATH:$BIN_DIR" >> $SHELL_FILE
|
||||||
echo "Source your $SHELL_FILE or open a new shell and type $APP_NAME to run it"
|
echo "Source your $SHELL_FILE or open a new shell and type $APP_NAME to run it"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Type $APP_NAME in your terminal to run it"
|
echo "Type $APP_NAME in your terminal to run it"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user