2018-02-20 03:30:38 +08:00
|
|
|
#!/usr/bin/env bash
|
2018-02-19 16:22:14 +08:00
|
|
|
|
2018-02-20 12:19:00 +08:00
|
|
|
VERSION=1.0.1
|
2018-02-19 16:22:14 +08:00
|
|
|
|
2018-02-20 10: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-20 03:30:38 +08:00
|
|
|
|
2018-02-20 10:11:00 +08:00
|
|
|
install() {
|
2018-02-20 14:34:49 +08:00
|
|
|
curl -L https://github.com/cjbassi/gotop/releases/download/$VERSION/gotop-$VERSION-${1}.tgz > /tmp/gotop.tgz
|
2018-02-20 10:11:00 +08:00
|
|
|
tar xf /tmp/gotop.tgz -C /usr/bin
|
|
|
|
rm /tmp/gotop.tgz
|
|
|
|
}
|
2018-02-19 16:55:31 +08:00
|
|
|
|
2018-02-19 17: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-20 10:11:00 +08:00
|
|
|
|
|
|
|
arch=$(uname -sm)
|
|
|
|
case "$arch" in
|
2018-02-20 12:19:00 +08:00
|
|
|
Linux\ *64) install linux_amd64 ;;
|
|
|
|
Linux\ *86) install linux_386 ;;
|
2018-02-20 10:11:00 +08:00
|
|
|
*)
|
|
|
|
print_error
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|