summaryrefslogtreecommitdiffstats
path: root/scripts/sh/check_tor.sh
blob: 216c3a487ac68a3622a8bfa32fed133c9ab42e40 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Query tor node
# Designed to be run with multi.sh

version_check() {
        if [ -f "$PKGBINARY" ]; then
                echo "Packaged version:"
                $PKGBINARY --version
        else
                echo "No packaged version."
        fi
        if [ -f "$SRCBINARY" ]; then
                echo "Source version:"
                $SRCBINARY --version
        else
                echo "No source version."
        fi

}

run_check_linux() {
        # to-do: check if Sytemd or SysV-Init and behave accordingly
        systemctl is-active tor
}

run_check_bsd() {
        if [ -f "$RCSCRIPT" ]; then
                $RCSCRIPT status
        else
                ps aux |grep tor
        fi
}

echo "Found in PATH: `command -v tor`"

case `uname` in
        'Linux' )
                PKGBINARY="/usr/bin/tor"
                SRCBINARY="/usr/local/bin/tor"
                version_check
                run_check_linux
        ;;
        'NetBSD' )
                PKGBINARY="/usr/pkg/bin/tor"
                SRCBINARY="/usr/local/bin/tor"
                RCSCRIPT="/etc/rc.d/tor"
                version_check
                run_check_bsd
        ;;
esac