Last active
September 1, 2015 13:51
-
-
Save johnae/6fdc84ea7d843812152e to your computer and use it in GitHub Desktop.
Install latest spook version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### This will download the latest release and put it in PREFIX, the default is /usr/local | |
### You can run the remote script locally like this: | |
### curl https://gist.githubusercontent.com/johnae/6fdc84ea7d843812152e/raw/install.sh | PREFIX=~/Local bash | |
defined () { | |
[[ ${!1-X} == ${!1-Y} ]] | |
} | |
has_value () { | |
if defined $1; then | |
if [[ -n ${!1} ]]; then | |
return 0 | |
fi | |
fi | |
return 1 | |
} | |
if ! has_value PREFIX; then | |
PREFIX=/usr/local | |
fi | |
UNAME=$(uname) | |
ARCH=$(uname -m) | |
release=$(curl -i https://api.github.com/repos/johnae/spook/releases/latest 2>/dev/null | grep browser_download | grep $UNAME-$ARCH | awk '{print $2}' | sed 's/"//g') | |
if ! has_value release; then | |
echo "No release found for OS $UNAME and arch $ARCH, consider cloning the repo and building it yourself" | |
else | |
echo "Downloading $release..." | |
curl -L -o /tmp/spook.gz "$release" 2>/dev/null | |
pushd /tmp >/dev/null | |
echo "Installing spook..." | |
rm -f /tmp/spook | |
gunzip spook.gz | |
chmod +x spook | |
mv -f spook $PREFIX/bin/ | |
echo "Installed spook in $PREFIX/bin" | |
popd >/dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment