Removing .*.tar and .*.zip from tests
[ouch.git] / install.sh
blob36605ae5a573f9b89e9cd69263245e9810946d54
1 #! /usr/bin/sh
3 # Needs to be updated each version bump
4 VERSION="0.1.5"
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
11 set -e
13 abort() {
14 echo "error occurred, aborting." ; exit 1
17 install() {
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
23 case "$(uname -s)" in
24 Linux)
25 echo "Linux."
26 system_suffix="-ubuntu-18.04-glibc"
29 Darwin)
30 echo "Mac OS X."
31 system_suffix="-macOS"
34 CYGWIN*|MINGW32*|MSYS*|MINGW*)
35 echo "Windows."
36 system_suffix=".exe"
40 echo "ERROR."
41 echo "This script only works for installing on Linux, Mac OS and Windows."
42 echo "We found '$(uname -s)' instead."
43 echo ""
44 echo "To install 'ouch' you can opt for other installation method"
45 echo "listed at $REPO_URL"
46 echo ""
47 echo "If you think this is an error, please open an issue"
48 exit 1
50 esac
52 binary_url="https://github.com/vrmiguel/ouch/releases/download/${VERSION}/ouch${system_suffix}"
54 echo ""
56 if [ -f "$DOWNLOAD_LOCATION" ]; then
57 echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
58 else
59 echo "Downloading binary to '$DOWNLOAD_LOCATION' with curl."
60 echo "From $binary_url"
61 curl -fSL $binary_url -o $DOWNLOAD_LOCATION
64 echo ""
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
69 else
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
76 echo ""
78 echo "Successfully installed!"
79 echo "See $REPO_URL for usage instructions."
82 install