summaryrefslogtreecommitdiffstats
path: root/install.sh
blob: 2825e0898cac8f4237d86abbcb4f35ced4a14085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

VERSION=1.0.1

print_error() {
    echo "No binary found for your architecture. If your architecture is compatible with a binary"
    echo "that's already on GitHub, you can manually download and install it and open an issue"
    echo "saying so. Otherwise, create an issue requesting binaries to be build for your"
    echo "architecture and you can build from source in the meantime if you like."
}

install() {
    curl -L https://github.com/cjbassi/gotop/releases/download/$VERSION/gotop-$VERSION-${1}.tgz > /tmp/gotop.tgz
    tar xf /tmp/gotop.tgz -C /usr/bin
    rm /tmp/gotop.tgz
}

update() {
    cur_version=$(gotop -v 2>/dev/null)
    if [[ $? != 0 ]]; then
        download
    fi
    if (( "${cur_version//.}" < "${VERSION//.}" )); then
        download
    fi
}

arch=$(uname -sm)
case "$arch" in
    Linux\ *64)  install linux_amd64    ;;
    Linux\ *86)  install linux_386      ;;
    Darwin\ *64) install darwin_amd64   ;;
    *)
        print_error
        exit 1
        ;;
esac