Skip to content

Commit

Permalink
Update install script
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kovalenko committed Nov 11, 2020
1 parent 6cc9db2 commit a2b1c22
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit a2b1c22

Please sign in to comment.