install script: exit on failure, conditional curl/wget (#140)

This commit is contained in:
Efim Poberezkin 2021-12-05 20:01:34 +04:00 committed by GitHub
parent e4328cb98d
commit 2ce3cd2fad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,5 @@
set -eu
APP_NAME="simplex-chat"
TARGET_DIR="$HOME/.local/bin"
PLATFORM="$(uname)"
@ -14,11 +16,20 @@ fi
[ ! -d $TARGET_DIR ] && mkdir -p $TARGET_DIR
wget -O $TARGET_DIR/$APP_NAME "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM" && chmod +x $TARGET_DIR/$APP_NAME
if [ -n "$(command -v curl)" ]; then
curl -L -o $TARGET_DIR/$APP_NAME "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
elif [ -n "$(command -v wget)" ]; then
wget -O $TARGET_DIR/$APP_NAME "https://github.com/$APP_NAME/$APP_NAME/releases/latest/download/$APP_NAME-$PLATFORM"
else
echo "Cannot download simplex-chat - please install curl or wget"
exit 1
fi
chmod +x $TARGET_DIR/$APP_NAME
echo "$APP_NAME installed sucesfully!"
if [ -z "$(which simplex-chat)" ]; then
if [ -z "$(command -v simplex-chat)" ]; then
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
SHELL_FILE="$HOME/.zshrc"
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then