2018-02-20 03:30:38 +08:00
|
|
|
#!/usr/bin/env bash
|
2018-02-19 16:22:14 +08:00
|
|
|
|
2018-05-11 15:35:06 +08:00
|
|
|
|
|
|
|
get_latest_release_version() {
|
|
|
|
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
|
|
|
|
grep '"tag_name":' | # Get tag line
|
|
|
|
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
|
|
|
|
}
|
|
|
|
|
2018-02-19 16:22:14 +08:00
|
|
|
|
2018-02-27 04:55:05 +08:00
|
|
|
download() {
|
2018-05-11 15:35:06 +08:00
|
|
|
archive=gotop_${version}_${1}.tgz
|
|
|
|
curl -LO https://github.com/cjbassi/gotop/releases/download/$version/$archive
|
2018-04-10 09:07:36 +08:00
|
|
|
tar xf $archive
|
|
|
|
rm $archive
|
2018-02-19 17:59:51 +08:00
|
|
|
}
|
2018-02-20 10:11:00 +08:00
|
|
|
|
2018-05-11 15:35:06 +08:00
|
|
|
|
2018-02-20 10:11:00 +08:00
|
|
|
arch=$(uname -sm)
|
2018-05-11 15:35:06 +08:00
|
|
|
version=$(get_latest_release_version 'cjbassi/gotop')
|
|
|
|
|
2018-02-20 10:11:00 +08:00
|
|
|
case "$arch" in
|
2018-04-15 03:49:50 +08:00
|
|
|
# order matters
|
2018-04-30 02:42:00 +08:00
|
|
|
Darwin\ *64) download darwin_amd64 ;;
|
|
|
|
Darwin\ *86) download darwin_386 ;;
|
2018-04-14 07:14:30 +08:00
|
|
|
Linux\ armv5*) download linux_arm5 ;;
|
|
|
|
Linux\ armv6*) download linux_arm6 ;;
|
|
|
|
Linux\ armv7*) download linux_arm7 ;;
|
|
|
|
Linux\ armv8*) download linux_arm8 ;;
|
|
|
|
Linux\ aarch64*) download linux_arm8 ;;
|
2018-04-15 03:49:50 +08:00
|
|
|
Linux\ *64) download linux_amd64 ;;
|
|
|
|
Linux\ *86) download linux_386 ;;
|
2018-02-20 10:11:00 +08:00
|
|
|
*)
|
2018-05-11 14:50:12 +08:00
|
|
|
echo "\
|
|
|
|
No binary found for your system.
|
|
|
|
Feel free to request that we prebuild one that works on your system."
|
2018-02-20 10:11:00 +08:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|