Skip to content

Commit

Permalink
Fixes to shell script from testing on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Bussiere committed Oct 2, 2021
1 parent 8cfbdef commit f364eca
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions install.sh
Expand Up @@ -5,13 +5,13 @@ BIN_TARGET="/usr/local/bin/poly"
# Proper cleanup if something happens
# Unfortunately we can't undo PIP packages easily if they installed...
function cleanup() {
sudo /usr/bin/cp poly/old_poly "${BIN_TARGET}"|| true
/usr/bin/rm -rf poly/ || true
sudo cp poly/old_poly "${BIN_TARGET}" 2>/dev/null || true
rm -rf poly/ 2>/dev/null || true
>&2 echo "Something went wrong - exiting without changes"
exit 255
}

trap 'cleanup' SIGINT SIGTERM ERR EXIT
trap 'cleanup' SIGINT SIGTERM ERR

# -------------------------------------------------

Expand All @@ -23,7 +23,7 @@ git clone https://github.com/3digitdev/poly.git ./poly
if command -v poly; then
# Use their install location instead of our own!
BIN_TARGET=$(command -v poly)
sudo /usr/bin/cp "${BIN_TARGET}" ./poly/old_poly
sudo cp "${BIN_TARGET}" ./poly/old_poly
echo "Detected ${BIN_TARGET} -- this will be overwritten!"
fi

Expand All @@ -37,13 +37,13 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
/usr/bin/python3 -m pip install --user -r poly/requirements.txt
# This will overwrite whatever is there -- handy for upgrades
# ...not so handy if someone steals my project name :)
sudo /usr/bin/cp poly/poly ${BIN_TARGET}
sudo cp poly/poly ${BIN_TARGET}
sudo chmod +x ${BIN_TARGET}
/usr/bin/rm -rf poly/
rm -rf poly/
echo "poly installed to ${BIN_TARGET}"
exit 0
else
/usr/bin/rm -rf poly/
rm -rf poly/
>&2 echo "Exiting without changes"
exit 1
fi
fi

0 comments on commit f364eca

Please sign in to comment.