summaryrefslogtreecommitdiff
path: root/debian/tor.init
blob: 2a037ee5aeba1a95b1149600e89244482c3c6867 (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
#! /bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/tor
NAME=tor
DESC="tor daemon"
TORLOG=/var/log/tor/log
TORPID=/var/run/tor/tor.pid
ARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"

test -x $DAEMON || exit 0

# Include tor defaults if available
if [ -f /etc/default/tor ] ; then
	. /etc/default/tor
fi

set -e

case "$1" in
  start)
	if [ "$RUN_DAEMON" != "yes" ]; then
		echo "Not starting $DESC (Disabled in /etc/default/tor)."
	else
		echo -n "Starting $DESC: "
		start-stop-daemon --start --quiet --oknodo \
			--chuid debian-tor:debian-tor \
			--pidfile $TORPID \
			--exec $DAEMON -- $ARGS
		echo "$NAME."
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --oknodo --pidfile $TORPID \
		--exec $DAEMON
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration."
	start-stop-daemon --stop --signal 1 --oknodo --quiet --pidfile $TORPID \
		--exec $DAEMON
	;;
  restart)
	$0 stop
	sleep 1
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0