2021-04-11 15:02:34 +00:00
|
|
|
#!/bin/bash
|
2024-11-29 07:39:58 +00:00
|
|
|
# Check if the script is running as root
|
|
|
|
[ "$EUID" -eq 0 ] || exec sudo bash "$0" "$@"
|
2024-10-21 14:06:49 +00:00
|
|
|
set -e -o pipefail
|
2021-04-17 13:57:15 +00:00
|
|
|
shopt -s nocaseglob
|
|
|
|
|
2021-04-11 15:02:34 +00:00
|
|
|
OUT_FILE=/usr/local/bin/autorestic
|
2024-11-29 07:39:58 +00:00
|
|
|
TMP_FILE=/tmp/autorestic
|
2021-04-11 15:02:34 +00:00
|
|
|
|
2021-04-17 13:57:15 +00:00
|
|
|
# Type
|
|
|
|
NATIVE_OS=$(uname | tr '[:upper:]' '[:lower:]')
|
2024-11-29 07:39:58 +00:00
|
|
|
case $NATIVE_OS in
|
|
|
|
*linux*)
|
|
|
|
OS=linux;;
|
|
|
|
*darwin*)
|
|
|
|
OS=darwin;;
|
|
|
|
*freebsd*)
|
|
|
|
OS=freebsd;;
|
|
|
|
*)
|
|
|
|
echo "Could not determine OS automatically, please check the release page"\
|
|
|
|
"manually: https://github.com/cupcakearmy/autorestic/releases"
|
2021-04-17 13:57:15 +00:00
|
|
|
exit 1
|
2024-11-29 07:39:58 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-04-17 13:57:15 +00:00
|
|
|
echo $OS
|
|
|
|
|
2021-04-26 11:15:58 +00:00
|
|
|
NATIVE_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
|
2024-11-29 07:39:58 +00:00
|
|
|
case $NATIVE_ARCH in
|
|
|
|
*x86_64*|*amd64*) ARCH=amd64 ;;
|
|
|
|
*arm64*|*aarch64*) ARCH=arm64 ;;
|
|
|
|
*x86*) ARCH=386 ;;
|
|
|
|
*armv7*) ARCH=arm ;;
|
|
|
|
*)
|
|
|
|
echo "Could not determine Architecure automatically, please check the"\
|
|
|
|
"release page manually: https://github.com/cupcakearmy/autorestic/releases"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2021-04-17 13:57:15 +00:00
|
|
|
echo $ARCH
|
2021-04-11 15:02:34 +00:00
|
|
|
|
2022-10-18 14:17:35 +00:00
|
|
|
if ! command -v bzip2 &>/dev/null; then
|
|
|
|
echo "Missing bzip2 command. Please install the bzip2 package for your system."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-10-30 12:38:53 +00:00
|
|
|
wget -qO - https://api.github.com/repos/cupcakearmy/autorestic/releases/latest \
|
2021-04-17 13:57:15 +00:00
|
|
|
| grep "browser_download_url.*_${OS}_${ARCH}" \
|
2024-11-29 07:39:58 +00:00
|
|
|
| xargs | cut -d ' ' -f 2 \
|
|
|
|
| wget -O "${TMP_FILE}.bz2" -i -
|
|
|
|
bzip2 -cd "${TMP_FILE}.bz2" > "${OUT_FILE}"
|
2021-04-11 15:02:34 +00:00
|
|
|
chmod +x ${OUT_FILE}
|
2024-11-29 07:39:58 +00:00
|
|
|
rm "${TMP_FILE}.bz2"
|
2021-04-11 15:02:34 +00:00
|
|
|
|
|
|
|
autorestic install
|
2024-11-29 07:39:58 +00:00
|
|
|
echo "Successfully installed autorestic under ${OUT_FILE}"
|