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"
10 # Panicks script if anything fails
14 echo "error occurred, aborting." ; exit 1
18 echo "Ouch v$VERSION."
20 printf "Detected system: "
21 # System detection from https://stackoverflow.com/a/27776822/9982477
22 # Go there to see a full table of what `uname -s` might output
26 system_suffix
="-ubuntu-18.04-glibc"
31 system_suffix
="-macOS"
34 CYGWIN
*|MINGW32
*|MSYS
*|MINGW
*)
41 echo "This script only works for installing on Linux, Mac OS and Windows."
42 echo "We found '$(uname -s)' instead."
44 echo "To install 'ouch' you can opt for other installation method"
45 echo "listed at $REPO_URL"
47 echo "If you think this is an error, please open an issue"
52 binary_url
="https://github.com/vrmiguel/ouch/releases/download/${VERSION}/ouch${system_suffix}"
56 if [ -f "$DOWNLOAD_LOCATION" ]; then
57 echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
59 echo "Downloading binary to '$DOWNLOAD_LOCATION' with curl."
60 echo "From $binary_url"
61 curl
-fSL $binary_url -o $DOWNLOAD_LOCATION
66 if [ "$USER" = "root" ]; then
67 echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
68 cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
70 echo "Asking for \"sudo\" permissions to finish installation."
71 echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"
73 sudo
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION || abort
78 echo "Successfully installed!"
79 echo "See $REPO_URL for usage instructions."