mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 00:06:25 +00:00
8a773856de
Prior to this change, running the example from the docs without root privs produces this misleading/confusing output that claims that the software was installed when it wasn't: ```console $ wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash linux amd64 /usr/local/bin/autorestic.bz2: Permission denied bzip2: Can't open input file /usr/local/bin/autorestic.bz2: No such file or directory. chmod: cannot access '/usr/local/bin/autorestic': No such file or directory bash: line 49: autorestic: command not found Successfully installed autorestic ``` With this change, the errors stop the script much earlier and produce this output instead: ``` linux amd64 /usr/local/bin/autorestic.bz2: Permission denied ```
51 lines
1.4 KiB
Bash
Executable File
51 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e -o pipefail
|
|
shopt -s nocaseglob
|
|
|
|
OUT_FILE=/usr/local/bin/autorestic
|
|
|
|
# Type
|
|
NATIVE_OS=$(uname | tr '[:upper:]' '[:lower:]')
|
|
if [[ $NATIVE_OS == *"linux"* ]]; then
|
|
OS=linux
|
|
elif [[ $NATIVE_OS == *"darwin"* ]]; then
|
|
OS=darwin
|
|
elif [[ $NATIVE_OS == *"freebsd"* ]]; then
|
|
OS=freebsd
|
|
else
|
|
echo "Could not determine OS automatically, please check the release page manually: https://github.com/cupcakearmy/autorestic/releases"
|
|
exit 1
|
|
fi
|
|
echo $OS
|
|
|
|
NATIVE_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
|
|
if [[ $NATIVE_ARCH == *"x86_64"* || $NATIVE_ARCH == *"amd64"* ]]; then
|
|
ARCH=amd64
|
|
elif [[ $NATIVE_ARCH == *"arm64"* || $NATIVE_ARCH == *"aarch64"* ]]; then
|
|
ARCH=arm64
|
|
elif [[ $NATIVE_ARCH == *"x86"* ]]; then
|
|
ARCH=386
|
|
elif [[ $NATIVE_ARCH == *"armv7"* ]]; then
|
|
ARCH=arm
|
|
else
|
|
echo "Could not determine Architecure automatically, please check the release page manually: https://github.com/cupcakearmy/autorestic/releases"
|
|
exit 1
|
|
fi
|
|
echo $ARCH
|
|
|
|
if ! command -v bzip2 &>/dev/null; then
|
|
echo "Missing bzip2 command. Please install the bzip2 package for your system."
|
|
exit 1
|
|
fi
|
|
|
|
wget -qO - https://api.github.com/repos/cupcakearmy/autorestic/releases/latest \
|
|
| grep "browser_download_url.*_${OS}_${ARCH}" \
|
|
| cut -d : -f 2,3 \
|
|
| tr -d \" \
|
|
| wget -O "${OUT_FILE}.bz2" -i -
|
|
bzip2 -fd "${OUT_FILE}.bz2"
|
|
chmod +x ${OUT_FILE}
|
|
|
|
autorestic install
|
|
echo "Successfully installed autorestic"
|