From a2b1c2206ae294dc23acc913210c87377fd1863a Mon Sep 17 00:00:00 2001 From: Dmitry Kovalenko Date: Wed, 11 Nov 2020 21:39:24 +0200 Subject: [PATCH] Update install script --- install.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 1522739..e9544c1 100755 --- a/install.sh +++ b/install.sh @@ -6,7 +6,7 @@ DOWNLOAD_URL=$(curl -fsSL https://api.github.com/repos/SupersonicAds/spotcli/rel | grep browser_download_url \ | cut -d '"' -f 4) WHEEL_FILE="$(mktemp -d)/${DOWNLOAD_URL##*/}" -trap "rm -f $WHEEL_FILE || true && echo 'ERROR: SpotCLI wasn\\'t installed' && exit 1" ERR +trap "rm -f $WHEEL_FILE >/dev/null 2>&1 || true && echo 'ERROR: SpotCLI wasn\\'t installed' && exit 1" ERR echo -en "Downloading latest wheel from GitHub..." curl -fsSL -o $WHEEL_FILE "$DOWNLOAD_URL" @@ -24,24 +24,27 @@ then elif [[ $(python3 -V 2>/dev/null) == *"Python 3"* ]] then echo -en "$(python3 -V | sed 's/Python //g') (system)\n" - echo -en "You may need to enter sudo password" - PIP="sudo $(which pip3)" + PIP="$(which pip3)" + if [ $(id -u 2>/dev/null) != "0" ] && which sudo >/dev/null 2>&1 + then + PIP="$(which sudo) $PIP" + fi else echo -en "ERROR: Python 3 not found\n" exit 1 fi echo -en "Installing SpotCLI..." -PIP_STDOUT=$(mktemp) -$PIP install "$WHEEL_FILE" >/dev/null -rm -f $WHEEL_FILE -rm -f $PIP_STDOUT -mkdir -p $HOME/.spot -touch $HOME/.spot/config.yaml +PIP_STDOUT=$(mktemp 2>/dev/null) +$PIP install -qq "$WHEEL_FILE" +rm -f $WHEEL_FILE >/dev/null 2>&1 || true +rm -f $PIP_STDOUT >/dev/null 2>&1 || true +mkdir -p $HOME/.spot >/dev/null +touch $HOME/.spot/config.yaml >/dev/null echo -en "done\n" echo -en "Verifying installation..." -[[ $(spotcli version) == *"SpotCLI version"* ]] +[[ $(spotcli version 2>/dev/null) == *"SpotCLI version"* ]] echo -en "ok\n" trap - EXIT