Do not leave empty, invalid chunks in buffers during buf_pullup
[tor.git] / contrib / suse / tor.sh.in
blobb7e9005eb5efa8f2c14105be79193c2997e754b3
1 #!/bin/sh
3 # Copyright (c) 2006-2007 Andrew Lewman
5 # tor The Onion Router
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
19 ### BEGIN INIT INFO
20 # Provides: tor
21 # Required-Start: $remote_fs $network
22 # Required-Stop: $remote_fs $network
23 # Default-Start: 3 5
24 # Default-Stop: 0 1 2 6
25 # Short-Description: Start the tor daemon
26 # Description: Start the tor daemon: the anon-proxy server
27 ### END INIT INFO
29 . /etc/rc.status
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
41 rc_reset
43 # Increase open file descriptors a reasonable amount
44 ulimit -n 8192
46 TORCTL=@BINDIR@/torctl
48 # torctl will use these environment variables
49 TORUSER=@TORUSER@
50 export TORUSER
51 TORGROUP=@TORGROUP@
52 export TORGROUP
54 TOR_DAEMON_PID_DIR="@LOCALSTATEDIR@/run/tor"
56 if [ -x /bin/su ] ; then
57 SUPROG=/bin/su
58 elif [ -x /sbin/su ] ; then
59 SUPROG=/sbin/su
60 elif [ -x /usr/bin/su ] ; then
61 SUPROG=/usr/bin/su
62 elif [ -x /usr/sbin/su ] ; then
63 SUPROG=/usr/sbin/su
64 else
65 SUPROG=/bin/su
68 case "$1" in
70 start)
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
83 rc_status -v
86 stop)
87 echo "Stopping tor daemon"
88 startproc -f $TORCTL stop
89 # Remember status and be verbose
90 rc_status -v
93 restart)
94 echo "Restarting tor daemon"
95 startproc -f $TORCTL restart
96 # Remember status and be verbose
97 rc_status -v
100 reload)
101 echo "Reloading tor daemon"
102 startproc -f $TORCTL reload
103 # Remember status and be verbose
104 rc_status -v
107 status)
108 startproc -f $TORCTL status
109 # Remember status and be verbose
110 rc_status -v
114 echo "Usage: $0 (start|stop|restart|reload|status)"
115 RETVAL=1
116 esac
118 rc_exit