xmtop/scripts/download.sh

41 lines
1.4 KiB
Bash
Raw Normal View History

2018-02-19 11:30:38 -08:00
#!/usr/bin/env bash
2018-02-19 00:22:14 -08:00
2019-02-06 21:24:48 -08:00
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
function get_latest_release {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
2019-02-07 03:06:55 -08:00
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
2019-02-06 21:24:48 -08:00
function download {
2020-02-13 16:26:28 -06:00
RELEASE=$(get_latest_release 'xxxserxxx/gotop')
2019-02-06 21:24:48 -08:00
ARCHIVE=gotop_${RELEASE}_${1}.tgz
2020-02-13 16:26:28 -06:00
curl -LO https://github.com/xxxserxxx/gotop/releases/download/${RELEASE}/${ARCHIVE}
2019-02-06 21:24:48 -08:00
tar xf ${ARCHIVE}
rm ${ARCHIVE}
2018-02-19 01:59:51 -08:00
}
2018-02-19 18:11:00 -08:00
2019-02-06 21:24:48 -08:00
function main {
ARCH=$(uname -sm)
case "${ARCH}" in
# order matters
Darwin\ *64) download darwin_amd64 ;;
Darwin\ *86) download darwin_386 ;;
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 ;;
Linux\ *64) download linux_amd64 ;;
Linux\ *86) download linux_386 ;;
*)
echo "\
No binary found for your system.
Feel free to request that we prebuild one that works on your system."
exit 1
;;
esac
}
2019-02-06 21:24:48 -08:00
main