Skip to content

Commit

Permalink
Create install.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
runi95 authored Feb 23, 2021
1 parent 439beb7 commit 2d6f84f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 2d6f84f

Please sign in to comment.