From 7b7eec2dba2b4fc2e8fe7c740a057ad68ad95163 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sat, 17 Apr 2021 15:57:15 +0200 Subject: [PATCH] install script --- install.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 4b4dfe0..8836a9b 100755 --- a/install.sh +++ b/install.sh @@ -1,21 +1,38 @@ #!/bin/bash +shopt -s nocaseglob + OUT_FILE=/usr/local/bin/autorestic -if [[ "$OSTYPE" == "linux-gnu" ]]; then - TYPE=linux -elif [[ "$OSTYPE" == "darwin"* ]]; then - TYPE=macos +# Type +NATIVE_OS=$(uname | tr '[:upper:]' '[:lower:]') +if [[ $NATIVE_OS == *"linux"* ]]; then + OS=linux +elif [[ $NATIVE_OS == *"darwin"* ]]; then + OS=darwin +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) +if [[ $NATIVE_ARCH == *"x86_64"* ]]; then + ARCH=amd64 +elif [[ $NATIVE_ARCH == *"x86"* ]]; then + ARCH=386 else - echo "Unsupported OS" + echo "Could not determine Architecure automatically, please check the release page manually: https://github.com/cupcakearmy/autorestic/releases" exit 1 fi +echo $ARCH curl -s https://api.github.com/repos/cupcakearmy/autorestic/releases/latest \ -| grep "browser_download_url.*_${TYPE}" \ +| grep "browser_download_url.*_${OS}_${ARCH}" \ | cut -d : -f 2,3 \ | tr -d \" \ -| wget -O ${OUT_FILE} -i - +| wget -O "${OUT_FILE}.bz2" -i - +bzip2 -fd "${OUT_FILE}.bz2" chmod +x ${OUT_FILE} autorestic install