mirror of https://github.com/cjbassi/gotop.git
Added update
This commit is contained in:
parent
fd0664912c
commit
bf138746d8
29
install.sh
29
install.sh
|
@ -1,14 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
VERSION=v1.0
|
||||
VERSION=1.0.0
|
||||
|
||||
download() {
|
||||
curl -L https://github.com/cjbassi/gotop/releases/download/$VERSION/${1} > /usr/bin/gotop
|
||||
arch=$(uname -sm)
|
||||
case "$arch" in
|
||||
Linux\ *64) exe=gotop-linux_amd64 ;;
|
||||
esac
|
||||
curl -L https://github.com/cjbassi/gotop/releases/download/$VERSION/$exe > /usr/bin/gotop
|
||||
chmod +x /usr/bin/gotop
|
||||
}
|
||||
|
||||
update() {
|
||||
cur_version=$(gotop -v 2>/dev/null)
|
||||
if [[ $? != 0 ]]; then
|
||||
download
|
||||
fi
|
||||
if (( "${cur_version//.}" < "${VERSION//.}" )); then
|
||||
download
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
rm /usr/bin/gotop
|
||||
rm /usr/bin/gotop 2>/dev/null
|
||||
}
|
||||
|
||||
for opt in "$@"; do
|
||||
|
@ -17,6 +31,10 @@ for opt in "$@"; do
|
|||
uninstall
|
||||
exit 0
|
||||
;;
|
||||
--update)
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "unknown option: $opt"
|
||||
exit 1
|
||||
|
@ -24,7 +42,4 @@ for opt in "$@"; do
|
|||
esac
|
||||
done
|
||||
|
||||
arch=$(uname -sm)
|
||||
case "$arch" in
|
||||
Linux\ *64) download gotop-linux_amd64 ;;
|
||||
esac
|
||||
download
|
||||
|
|
Loading…
Reference in New Issue