Skip to content

Commit

Permalink
Prettify install script (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor authored and zaquestion committed Nov 22, 2018
1 parent 9ba0548 commit 1e7613a
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
#!/usr/bin/env bash

set -e
[[ -z $DEBUG ]] || set -x

if [ $EUID != 0 ]; then
if [[ ! -z $DEBUG ]]; then
set -x
fi

if [[ $EUID != 0 ]]; then
sudo "$0" "$@"
exit $?
exit "$?"
fi

machine=""
case $(uname -m) in
x86_64) machine="amd64";;
i386) machine="386";;
case "$(uname -m)" in
x86_64)
machine="amd64"
;;
i386)
machine="386"
;;
*)
machine=""
;;
esac

os=""
case $(uname -s) in
Linux) os="linux";;
Darwin) os="darwin";;
*) echo "OS not supported" && exit 1;;
Linux)
os="linux"
;;
Darwin)
os="darwin"
;;
*)
echo "OS not supported"
exit 1
;;
esac

latest=$(curl -sL 'https://api.github.com/repos/zaquestion/lab/releases/latest' | grep tag_name | grep --only 'v[0-9\.]\+' | cut -c2-)
latest="$(curl -sL 'https://api.github.com/repos/zaquestion/lab/releases/latest' | grep 'tag_name' | grep --only 'v[0-9\.]\+' | cut -c 2-)"

curl -sL "https://github.com/zaquestion/lab/releases/download/v${latest}/lab_${latest}_${os}_${machine}.tar.gz" | tar -C /tmp/ -xzf -
cp /tmp/lab /usr/local/bin/lab
echo "Successfully installed lab into /usr/local/bin/"

0 comments on commit 1e7613a

Please sign in to comment.