summaryrefslogtreecommitdiff
path: root/network/tor/rc.tor
blob: d7ef906aae51e82a318b6d35af17686059501d33 (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

#!/bin/sh

PIDFILE="/var/lib/tor/tor.pid"

tor_start() {
	echo -n "Starting tor: "
	if [ ! -f $PIDFILE ]; then
		/usr/bin/tor 1> /dev/null
		echo "OK"
	else
		echo -n "Removing stale lock.. "
		rm -f $PIDFILE
		/usr/bin/tor 1> /dev/null
		echo "OK"
	fi
}

tor_stop() {
	echo -n "Stopping tor: "
	if [ -f $PIDFILE ]; then
		killall tor &> /dev/null
		rm -f $PIDFILE
		echo "OK"
	else
		echo "Not Running"
	fi
}

case "$1" in
	start)
		tor_start
		;;
	stop)
		tor_stop
		;;
	restart)
		tor_stop
		tor_start
		;;
	*)
		echo "Usage: rc.tor {start|stop|restart}"
esac