2004-02-17 01:55:29 +01:00
|
|
|
#!/bin/sh
|
2004-02-27 01:07:33 +01:00
|
|
|
#
|
2005-12-24 05:03:39 +01:00
|
|
|
# tor The Onion Router
|
|
|
|
#
|
|
|
|
# Startup/shutdown script for tor. This is a wrapper around torctl;
|
|
|
|
# torctl does the actual work in a relatively system-independent, or at least
|
|
|
|
# distribution-independent, way, and this script deals with fitting the
|
|
|
|
# whole thing into the conventions of the particular system at hand.
|
|
|
|
# This particular script is written for Red Hat/Fedora Linux, and may
|
|
|
|
# also work on Mandrake, but not SuSE.
|
|
|
|
#
|
|
|
|
# These next couple of lines "declare" tor for the "chkconfig" program,
|
|
|
|
# originally from SGI, used on Red Hat/Fedora and probably elsewhere.
|
2004-02-27 01:07:33 +01:00
|
|
|
#
|
2004-06-07 01:20:28 +02:00
|
|
|
# chkconfig: 2345 90 10
|
2005-12-24 05:03:39 +01:00
|
|
|
# description: Onion Router - A low-latency anonymous proxy
|
|
|
|
#
|
2004-11-04 16:17:22 +01:00
|
|
|
|
2010-10-01 02:38:28 +02:00
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
DAEMON=/usr/sbin/tor
|
|
|
|
NAME=tor
|
|
|
|
DESC="tor daemon"
|
|
|
|
TORPIDDIR=/var/run/tor
|
|
|
|
TORPID=$TORPIDDIR/tor.pid
|
|
|
|
WAITFORDAEMON=60
|
|
|
|
ARGS=""
|
|
|
|
|
2005-12-24 05:03:39 +01:00
|
|
|
# Library functions
|
|
|
|
if [ -f /etc/rc.d/init.d/functions ]; then
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
elif [ -f /etc/init.d/functions ]; then
|
|
|
|
. /etc/init.d/functions
|
2004-02-27 01:24:08 +01:00
|
|
|
fi
|
2005-12-24 05:03:39 +01:00
|
|
|
|
|
|
|
TORCTL=@BINDIR@/torctl
|
|
|
|
|
|
|
|
# torctl will use these environment variables
|
|
|
|
TORUSER=@TORUSER@
|
|
|
|
export TORUSER
|
2004-02-17 01:55:29 +01:00
|
|
|
|
2005-06-05 16:44:27 +02:00
|
|
|
if [ -x /bin/su ] ; then
|
|
|
|
SUPROG=/bin/su
|
|
|
|
elif [ -x /sbin/su ] ; then
|
|
|
|
SUPROG=/sbin/su
|
|
|
|
elif [ -x /usr/bin/su ] ; then
|
|
|
|
SUPROG=/usr/bin/su
|
|
|
|
elif [ -x /usr/sbin/su ] ; then
|
|
|
|
SUPROG=/usr/sbin/su
|
|
|
|
else
|
|
|
|
SUPROG=/bin/su
|
|
|
|
fi
|
|
|
|
|
2010-10-01 02:38:28 +02:00
|
|
|
# Raise ulimit based on number of file descriptors available (thanks, Debian)
|
|
|
|
|
|
|
|
if [ -r /proc/sys/fs/file-max ]; then
|
|
|
|
system_max=`cat /proc/sys/fs/file-max`
|
|
|
|
if [ "$system_max" -gt "80000" ] ; then
|
|
|
|
MAX_FILEDESCRIPTORS=32768
|
|
|
|
elif [ "$system_max" -gt "40000" ] ; then
|
|
|
|
MAX_FILEDESCRIPTORS=16384
|
|
|
|
elif [ "$system_max" -gt "10000" ] ; then
|
|
|
|
MAX_FILEDESCRIPTORS=8192
|
|
|
|
else
|
|
|
|
MAX_FILEDESCRIPTORS=1024
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
Warning: Your system has very few filedescriptors available in total.
|
|
|
|
|
|
|
|
Maybe you should try raising that by adding 'fs.file-max=100000' to your
|
|
|
|
/etc/sysctl.conf file. Feel free to pick any number that you deem appropriate.
|
|
|
|
Then run 'sysctl -p'. See /proc/sys/fs/file-max for the current value, and
|
|
|
|
file-nr in the same directory for how many of those are used at the moment.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
MAX_FILEDESCRIPTORS=8192
|
|
|
|
fi
|
|
|
|
|
|
|
|
NICE=""
|
|
|
|
|
2004-02-17 01:55:29 +01:00
|
|
|
case "$1" in
|
|
|
|
|
|
|
|
start)
|
2010-10-01 02:38:28 +02:00
|
|
|
if [ -n "$MAX_FILEDESCRIPTORS" ]; then
|
|
|
|
echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
|
|
|
|
if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
|
|
|
|
echo "."
|
|
|
|
else
|
|
|
|
echo ": FAILED."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2005-12-24 05:03:39 +01:00
|
|
|
action $"Starting tor:" $TORCTL start
|
|
|
|
RETVAL=$?
|
2004-02-17 01:55:29 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
2005-12-24 05:03:39 +01:00
|
|
|
action $"Stopping tor:" $TORCTL stop
|
|
|
|
RETVAL=$?
|
2004-06-07 01:20:28 +02:00
|
|
|
;;
|
|
|
|
|
2004-02-17 01:55:29 +01:00
|
|
|
restart)
|
2005-12-24 05:03:39 +01:00
|
|
|
action $"Restarting tor:" $TORCTL restart
|
|
|
|
RETVAL=$?
|
2004-02-17 01:55:29 +01:00
|
|
|
;;
|
|
|
|
|
2005-12-24 05:03:39 +01:00
|
|
|
reload)
|
|
|
|
action $"Reloading tor:" $TORCTL reload
|
|
|
|
RETVAL=$?
|
2004-02-17 01:55:29 +01:00
|
|
|
;;
|
|
|
|
|
2005-12-24 05:03:39 +01:00
|
|
|
status)
|
|
|
|
$TORCTL status
|
|
|
|
RETVAL=$?
|
2004-02-17 01:55:29 +01:00
|
|
|
;;
|
2004-11-10 02:20:17 +01:00
|
|
|
|
2004-02-17 01:55:29 +01:00
|
|
|
*)
|
2005-12-24 05:03:39 +01:00
|
|
|
echo "Usage: $0 (start|stop|restart|reload|status)"
|
|
|
|
RETVAL=1
|
2004-02-17 01:55:29 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|