summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-02-19 01:59:51 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-02-19 02:00:26 -0800
commitbf138746d85259fed6d111dfec42471cfe48aa34 (patch)
treee6f199795843d94c830e708e96ec15d2c2086c9e
parentfd0664912cce4e156725371468f2d9742d227836 (diff)
Added update
-rwxr-xr-xinstall.sh29
1 files changed, 22 insertions, 7 deletions
diff --git a/install.sh b/install.sh
index a14e832..3d8f2fa 100755
--- a/install.sh
+++ b/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