Skip to content

Instantly share code, notes, and snippets.

@johnae
Last active September 1, 2015 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnae/6fdc84ea7d843812152e to your computer and use it in GitHub Desktop.
Save johnae/6fdc84ea7d843812152e to your computer and use it in GitHub Desktop.
Install latest spook version
#!/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