3 # Copyright (c) 2006-2007 Andrew Lewman
7 # Startup/shutdown script for tor. This is a wrapper around torctl;
8 # torctl does the actual work in a relatively system-independent, or at least
9 # distribution-independent, way, and this script deals with fitting the
10 # whole thing into the conventions of the particular system at hand.
12 # These next couple of lines "declare" tor for the "chkconfig" program,
13 # originally from SGI, used on Red Hat/Fedora and probably elsewhere.
15 # chkconfig: 2345 90 10
16 # description: Onion Router - A low-latency anonymous proxy
21 # Required-Start: $remote_fs $network
22 # Required-Stop: $remote_fs $network
24 # Default-Stop: 0 1 2 6
25 # Short-Description: Start the tor daemon
26 # Description: Start the tor daemon: the anon-proxy server
31 # Shell functions sourced from /etc/rc.status:
32 # rc_check check and set local and overall rc status
33 # rc_status check and set local and overall rc status
34 # rc_status -v ditto but be verbose in local rc status
35 # rc_status -v -r ditto and clear the local rc status
36 # rc_failed set local and overall rc status to failed
37 # rc_reset clear local rc status (overall remains)
38 # rc_exit exit appropriate to overall rc status
40 # First reset status of this service
43 # Increase open file descriptors a reasonable amount
46 TORCTL
=@BINDIR@
/torctl
48 # torctl will use these environment variables
54 TOR_DAEMON_PID_DIR
="@LOCALSTATEDIR@/run/tor"
56 if [ -x /bin
/su
] ; then
58 elif [ -x /sbin
/su
] ; then
60 elif [ -x /usr
/bin
/su
] ; then
62 elif [ -x /usr
/sbin
/su
] ; then
71 echo "Starting tor daemon"
73 if [ ! -d $TOR_DAEMON_PID_DIR ] ; then
74 mkdir
-p $TOR_DAEMON_PID_DIR
75 chown
$TORUSER:$TORGROUP $TOR_DAEMON_PID_DIR
78 ## Start daemon with startproc(8). If this fails
79 ## the echo return value is set appropriate.
81 startproc
-f $TORCTL start
82 # Remember status and be verbose
87 echo "Stopping tor daemon"
88 startproc
-f $TORCTL stop
89 # Remember status and be verbose
94 echo "Restarting tor daemon"
95 startproc
-f $TORCTL restart
96 # Remember status and be verbose
101 echo "Reloading tor daemon"
102 startproc
-f $TORCTL reload
103 # Remember status and be verbose
108 startproc
-f $TORCTL status
109 # Remember status and be verbose
114 echo "Usage: $0 (start|stop|restart|reload|status)"