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 # If env var ACCESSIBLE is set (to a nonempty value), suppress output of
14 # Panics script if anything fails
18 echo "error occurred, aborting." ; exit 1
22 echo "Ouch v$VERSION."
24 printf "Detected system: "
25 # System detection from https://stackoverflow.com/a/27776822/9982477
26 # Go there to see a full table of what `uname -s` might output
30 system_suffix
="-linux-musl"
35 system_suffix
="-apple-darwin"
38 CYGWIN
*|MINGW32
*|MSYS
*|MINGW
*)
40 system_suffix
="-pc-windows-msvc.exe"
45 echo "This script only works for installing on Linux, Mac OS and Windows."
46 echo "We found '$(uname -s)' instead."
48 echo "To install 'ouch' you can opt for other installation method"
49 echo "listed at $REPO_URL"
51 echo "If you think this is an error, please open an issue"
56 binary_file_name
="ouch-x86_64${system_suffix}"
57 binary_url
="https://github.com/ouch-org/ouch/releases/download/${VERSION}/${binary_file_name}"
62 downloader_quiet_flag
=""
63 if [ $
(which curl
) ]; then
65 if [ "$ACCESSIBLE" ]; then downloader_quiet_flag
="--silent"; fi
66 downloader_command
="curl $downloader_quiet_flag -fSL $binary_url -o $DOWNLOAD_LOCATION"
67 elif [ $
(which wget
) ]; then
69 if [ "$ACCESSIBLE" ]; then downloader_quiet_flag
="--quiet"; fi
70 downloader_command
="wget $downloader_quiet_flag $binary_url -O $DOWNLOAD_LOCATION"
72 echo "ERROR: have not found 'curl' nor 'wget' to donwload ouch binary."
76 if [ -f "$DOWNLOAD_LOCATION" ]; then
77 echo "Reusing downloaded binary at '$DOWNLOAD_LOCATION'."
79 echo "Downloading binary to '$DOWNLOAD_LOCATION' with $downloader."
80 echo "From $binary_url"
81 # Run command to download binary
87 if [ "$USER" = "root" ]; then
88 echo "Detected root user, trying to copy $DOWNLOAD_LOCATION to $INSTALLATION_LOCATION."
89 cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION
90 chmod +x
$INSTALLATION_LOCATION
92 echo "Asking for \"sudo\" permissions to finish installation."
93 echo "Permission is needed to copy '$DOWNLOAD_LOCATION' to '$INSTALLATION_LOCATION'"
95 sudo
cp $DOWNLOAD_LOCATION $INSTALLATION_LOCATION
96 sudo
chmod +x
$INSTALLATION_LOCATION
101 echo "Successfully installed!"
102 echo "See $REPO_URL for usage instructions."