Tweak the implementation of proposal 109 slightly: allow at most
[tor.git] / contrib / tor.sh.in
blob362a455732add844524e013a4544a0d691902f0b
1 #!/bin/sh
3 # tor The Onion Router
5 # Startup/shutdown script for tor. This is a wrapper around torctl;
6 # torctl does the actual work in a relatively system-independent, or at least
7 # distribution-independent, way, and this script deals with fitting the
8 # whole thing into the conventions of the particular system at hand.
9 # This particular script is written for Red Hat/Fedora Linux, and may
10 # also work on Mandrake, but not SuSE.
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 # Library functions
20 if [ -f /etc/rc.d/init.d/functions ]; then
21 . /etc/rc.d/init.d/functions
22 elif [ -f /etc/init.d/functions ]; then
23 . /etc/init.d/functions
26 # Increase open file descriptors a reasonable amount
27 ulimit -n 8192
29 TORCTL=@BINDIR@/torctl
31 # torctl will use these environment variables
32 TORUSER=@TORUSER@
33 export TORUSER
34 TORGROUP=@TORGROUP@
35 export TORGROUP
37 if [ -x /bin/su ] ; then
38 SUPROG=/bin/su
39 elif [ -x /sbin/su ] ; then
40 SUPROG=/sbin/su
41 elif [ -x /usr/bin/su ] ; then
42 SUPROG=/usr/bin/su
43 elif [ -x /usr/sbin/su ] ; then
44 SUPROG=/usr/sbin/su
45 else
46 SUPROG=/bin/su
49 case "$1" in
51 start)
52 action $"Starting tor:" $TORCTL start
53 RETVAL=$?
56 stop)
57 action $"Stopping tor:" $TORCTL stop
58 RETVAL=$?
61 restart)
62 action $"Restarting tor:" $TORCTL restart
63 RETVAL=$?
66 reload)
67 action $"Reloading tor:" $TORCTL reload
68 RETVAL=$?
71 status)
72 $TORCTL status
73 RETVAL=$?
77 echo "Usage: $0 (start|stop|restart|reload|status)"
78 RETVAL=1
79 esac
81 exit $RETVAL