From 2d6f84f24d6ae1cc7b7328f5995d3bcf97320a71 Mon Sep 17 00:00:00 2001 From: Runar Serigstad Date: Tue, 23 Feb 2021 15:51:36 +0100 Subject: [PATCH] Create install.sh --- install.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..d9da992 --- /dev/null +++ b/install.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +echo " ___ _____ _ ___ ___ " +echo "/ __|_ _/_\ / __/ __|" +echo "\__ \ | |/ _ \ (_| (__ " +echo "|___/ |_/_/ \_\___\___|" +echo "" + +if [[ ! ":$PATH:" == *":/usr/local/bin:"* ]]; then + echo "Your path is missing /usr/local/bin, you need to add this to use this installer." + exit 1 +fi + +if [ "$(uname)" == "Darwin" ]; then + OS=darwin +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + OS=linux +else + echo "This installer is only supported on Linux and MacOS" + exit 1 +fi + +ARCH="\$(uname -m)" + +VERSION=$(curl --silent "https://api.github.com/repos/stacc/stacc-CLI/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + +URL="https://github.com/stacc/stacc-CLI/releases/download/$VERSION/stacc_${VERSION:1}_$(uname)_$(uname -m).tar.gz" + +echo "- Downloading from $URL" + +if [ $(command -v curl) ]; then + curl -LSs "$URL" | tar xz +else + wget -O- "$URL" | tar xz +fi + +if [ $? -ne 0 ]; then + echo "Failed to download from $URL" + exit 1 +fi + +TARGET="/usr/local/bin/stacc" + +echo "- Installing binary to $TARGET" + +sudo mv "stacc" "$TARGET" + +LOCATION=$(command -v stacc) +echo "" +echo "Stacc CLI has been successfully installed!"