summaryrefslogtreecommitdiff
path: root/network/tor/rc.tor
blob: 5c2d99eb0a37fcdaf26e5c54189cd96ca85f7185 (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
#!/bin/bash

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