3 # Needs to be updated each version bump
6 DOWNLOAD_LOCATION
="/tmp/ouch-binary"
7 INSTALLATION_LOCATION
="/usr/local/bin/ouch"
8 REPO_URL
="https://github.com/ouch-org/ouch"
10 # Panics 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
="-linux-musl"
31 system_suffix
="-apple-darwin"
34 CYGWIN
*|MINGW32
*|MSYS
*|MINGW
*)
36 system_suffix
="-pc-windows-msvc.exe"
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_file_name
="ouch-x86_64${system_suffix}"
53 binary_url
="https://github.com/ouch-org/ouch/releases/download/${VERSION}/${binary_file_name}"
58 if [ $
(which curl
) ]; then
60 downloader_command
="curl -fSL $binary_url -o $DOWNLOAD_LOCATION"
61 elif [ $
(which wget
) ]; then
63 downloader_command
="wget $binary_url -O $DOWNLOAD_LOCATION"
65 echo "ERROR: have not found 'curl' nor 'wget' to donwload ouch binary."
69 if [ -f "$DOWNLOAD_LOCATION" ]; then
70 echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
72 echo "Downloading binary to '$DOWNLOAD_LOCATION' with $downloader."
73 echo "From $binary_url"
74 # Run command to download binary
80 if [ "$USER" = "root" ]; then
81 echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
82 cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION
83 chmod +x
$INSTALLATION_LOCATION
85 echo "Asking for \"sudo\" permissions to finish installation."
86 echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"
88 sudo
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION
89 sudo
chmod +x
$INSTALLATION_LOCATION
94 echo "Successfully installed!"
95 echo "See $REPO_URL for usage instructions."