2005-01-05 03:46:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-03-18 23:43:46 +01:00
|
|
|
TORLOC=/Library/StartupItems/Tor/Tor.loc
|
|
|
|
|
|
|
|
if [ -f $TORLOC ]; then
|
|
|
|
TORDIR=`cat /Library/StartupItems/Tor/Tor.loc`
|
|
|
|
if [ "x$TORDIR" = "x" -o ! -d $TORDIR -o ! -x $TORDIR/tor ]; then
|
|
|
|
TORDIR=/Library/Tor
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
TORDIR=/Library/Tor
|
|
|
|
fi
|
|
|
|
TORCONF=$TORDIR/torrc
|
|
|
|
TORDATA=$TORDIR/var/lib/tor
|
2005-01-05 03:46:25 +01:00
|
|
|
TORPID=/var/run/Tor.pid
|
|
|
|
TORUSER=_tor
|
|
|
|
TORGROUP=daemon
|
2005-03-18 23:43:46 +01:00
|
|
|
TORCMD=$TORDIR/tor
|
2007-03-12 01:02:18 +01:00
|
|
|
TORLOG=/var/log/tor.log
|
2005-01-05 03:46:25 +01:00
|
|
|
|
2007-04-23 06:10:52 +02:00
|
|
|
## Determine OSX Version
|
|
|
|
# map version to name
|
|
|
|
if [ -x /usr/bin/sw_vers ]; then
|
|
|
|
# This is poor, yet functional. We don't care about the 3rd number in
|
|
|
|
# the OS version
|
|
|
|
OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
|
|
|
|
case "$OSVER" in
|
2009-10-12 14:36:39 +02:00
|
|
|
"10.6") ARCH="i386";;
|
|
|
|
"10.5") ARCH="i386";;
|
|
|
|
"10.4") ARCH="i386";;
|
2008-08-28 03:27:34 +02:00
|
|
|
"10.3") ARCH="ppc";;
|
|
|
|
"10.2") ARCH="ppc";;
|
|
|
|
"10.1") ARCH="ppc";;
|
|
|
|
"10.0") ARCH="ppc";;
|
2007-04-23 06:10:52 +02:00
|
|
|
esac
|
|
|
|
else
|
2008-08-28 03:32:45 +02:00
|
|
|
ARCH="unknown"
|
2007-04-23 06:10:52 +02:00
|
|
|
fi
|
|
|
|
|
2009-10-12 14:36:39 +02:00
|
|
|
if [ $ARCH != "i386" ]; then
|
2007-04-23 06:10:52 +02:00
|
|
|
export EVENT_NOKQUEUE=1
|
|
|
|
fi
|
|
|
|
|
2005-01-05 03:46:25 +01:00
|
|
|
##
|
|
|
|
# Tor Service
|
|
|
|
##
|
|
|
|
|
|
|
|
. /etc/rc.common
|
|
|
|
|
|
|
|
StartService ()
|
|
|
|
{
|
|
|
|
|
|
|
|
if [ -f $TORCMD ]; then
|
|
|
|
if pid=$(GetPID Tor); then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
ConsoleMessage "Starting Tor Service"
|
|
|
|
# Tentative
|
|
|
|
# Making sure it is not running (I know it is not a best approarch)
|
|
|
|
killall tor 2>/dev/null
|
2005-03-18 23:43:46 +01:00
|
|
|
$TORCMD -f "$TORCONF" --runasdaemon 1 --pidfile "$TORPID" --datadirectory "$TORDATA" --user "$TORUSER" --group "$TORGROUP" --log "notice file $TORLOG" &
|
2005-01-05 03:46:25 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
StopService ()
|
|
|
|
{
|
|
|
|
if pid=$(GetPID Tor); then
|
|
|
|
ConsoleMessage "Stopping Tor Service"
|
|
|
|
kill -TERM "${pid}"
|
|
|
|
# Just for sanity (sometimes necessary.)
|
|
|
|
killall tor 2>/dev/null
|
|
|
|
else
|
|
|
|
ConsoleMessage "Tor Service not responding."
|
|
|
|
# Just for sanity (sometimes necessary.)
|
|
|
|
killall tor 2>/dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
RestartService () { StopService; StartService; }
|
|
|
|
|
2005-06-15 20:19:42 +02:00
|
|
|
if [ "$#" = 0 ]; then
|
2005-05-16 02:52:54 +02:00
|
|
|
echo "Syntax: tor {start|stop}"
|
2005-05-11 00:41:31 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-01-05 03:46:25 +01:00
|
|
|
RunService "$1"
|