summaryrefslogtreecommitdiffstats
path: root/scripts/sh/update_tor_netbsd.sh
blob: 77e7b470d8cc2ce6d820f2f3ad0754098c394ac9 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# Easily update Tor routers on NetBSD to the source release version specified as VERSION
# Combine this with multi.sh \o/

set -eu

if test `uname` = 'NetBSD'; then

VERSION="0.4.6.7"
TEMPDIR="~root/tmp"

BINARY="/usr/local/bin/tor"
check_version() {
        $BINARY --version | sed 's/[^0-9.]*\([0-9.]*\).*/\1/' | head -n 1
}

if test `check_version` != "$VERSION."; then

if ! test -d "$TEMPDIR"; then
mkdir $TEMPDIR
fi
cd $TEMPDIR

echo "Downloading ..."
curl -sLO https://dist.torproject.org/tor-$VERSION.tar.gz

echo "Extracting ..."
tar -xzf tor-$VERSION.tar.gz

echo "Configuring ..."
cd tor-$VERSION
./configure

echo "Backing up ..."
tar -czf /tmp/tor-`hostname -s`.tgz /etc/rc.d/tor /usr/local/etc/tor/torrc /var/chroot/tor

echo "Stopping existing instances ..."
set +e
/etc/rc.d/tor stop
sleep 2
pkill -9 tor
set -e

echo "Removing shit ..."
make uninstall

echo "Compiling ..."
# to-do
#make -j `sysctl -n hw.ncpu`
make

echo "Installing ..."
make install

echo "Starting new instance ..."
/etc/rc.d/tor start

else
        echo "Version matches, aborting."
        exit 1
fi

else
        echo "This script only supports NetBSD deployments."
        exit 1
fi