diff options
author | Caleb Bassi <calebjbassi@gmail.com> | 2018-02-19 01:59:51 -0800 |
---|---|---|
committer | Caleb Bassi <calebjbassi@gmail.com> | 2018-02-19 02:00:26 -0800 |
commit | bf138746d85259fed6d111dfec42471cfe48aa34 (patch) | |
tree | e6f199795843d94c830e708e96ec15d2c2086c9e | |
parent | fd0664912cce4e156725371468f2d9742d227836 (diff) |
Added update
-rwxr-xr-x | install.sh | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -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 |