2018-02-19 11:30:38 -08:00
|
|
|
#!/usr/bin/env bash
|
2018-02-19 00:22:14 -08:00
|
|
|
|
2018-02-19 20:19:00 -08:00
|
|
|
VERSION=1.0.1
|
2018-02-19 00:22:14 -08:00
|
|
|
|
2018-02-19 18:11:00 -08:00
|
|
|
print_error() {
|
|
|
|
echo "No binary found for your architecture. If your architecture is compatible with a binary"
|
|
|
|
echo "that's already on GitHub, you can manually download and install it and open an issue"
|
|
|
|
echo "saying so. Otherwise, create an issue requesting binaries to be build for your"
|
|
|
|
echo "architecture and you can build from source in the meantime if you like."
|
|
|
|
}
|
2018-02-19 11:30:38 -08:00
|
|
|
|
2018-02-19 18:11:00 -08:00
|
|
|
install() {
|
2018-02-19 22:34:49 -08:00
|
|
|
curl -L https://github.com/cjbassi/gotop/releases/download/$VERSION/gotop-$VERSION-${1}.tgz > /tmp/gotop.tgz
|
2018-02-19 18:11:00 -08:00
|
|
|
tar xf /tmp/gotop.tgz -C /usr/bin
|
|
|
|
rm /tmp/gotop.tgz
|
|
|
|
}
|
2018-02-19 00:55:31 -08:00
|
|
|
|
2018-02-19 01:59:51 -08:00
|
|
|
update() {
|
|
|
|
cur_version=$(gotop -v 2>/dev/null)
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
download
|
|
|
|
fi
|
|
|
|
if (( "${cur_version//.}" < "${VERSION//.}" )); then
|
|
|
|
download
|
|
|
|
fi
|
|
|
|
}
|
2018-02-19 18:11:00 -08:00
|
|
|
|
|
|
|
arch=$(uname -sm)
|
|
|
|
case "$arch" in
|
2018-02-21 02:37:29 -08:00
|
|
|
Linux\ *64) install linux_amd64 ;;
|
|
|
|
Linux\ *86) install linux_386 ;;
|
|
|
|
Darwin\ *64) install darwin_amd64 ;;
|
2018-02-19 18:11:00 -08:00
|
|
|
*)
|
|
|
|
print_error
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|