From 2ce3cd2fad3ed391d1daad64a661d52a6f8deab1 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Sun, 5 Dec 2021 20:01:34 +0400 Subject: [PATCH] install script: exit on failure, conditional curl/wget (#140) --- install.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 7ac5dd500..a95fd8884 100755 --- a/install.sh +++ b/install.sh @@ -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