3 # Needs to be updated each version bump
6 DOWNLOAD_LOCATION
="/tmp/ouch"
7 INSTALLATION_LOCATION
="/usr/bin/ouch"
8 REPO_URL
="https://github.com/vrmiguel/ouch"
11 echo "error occurred, aborting." ; exit 1
14 # Panicks script if anything fails
17 echo "Ouch v$VERSION."
19 printf "Detected system: "
20 # System detection from https://stackoverflow.com/a/27776822/9982477
21 # Go there to see a full table of what `uname -s` might output
24 system_suffix
="-macOS"
30 system_suffix
="-ubuntu-18.04-glibc"
33 CYGWIN
*|MINGW32
*|MSYS
*|MINGW
*)
40 echo "This script only works for installing on Linux, Mac OS and Windows."
41 echo "We found '$(uname -s)' instead."
43 echo "To install 'ouch' you can opt for other installation method"
44 echo "listed at $REPO_URL"
46 echo "If you think this is an error, please open an issue"
51 binary_url
="https://github.com/vrmiguel/ouch/releases/download/${VERSION}/ouch${system_suffix}"
55 if [ -f "$DOWNLOAD_LOCATION" ]; then
56 echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
58 echo "Downloading binary to '$DOWNLOAD_LOCATION' with curl."
59 echo "From $binary_url"
60 curl
-fSL $binary_url -o $DOWNLOAD_LOCATION
65 if [ "$USER" = "root" ]; then
66 echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
67 cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
69 echo "Asking for \"sudo\" permissions to finish installation."
70 echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"
72 sudo
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
77 echo "Successfully installed!"
78 echo "See $REPO_URL for usage instructions."