| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | #!/bin/shTORLOC=/Library/StartupItems/Tor/Tor.locif [ -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 fielse TORDIR=/Library/TorfiTORCONF=$TORDIR/torrcTORDATA=$TORDIR/var/lib/torTORPID=/var/run/Tor.pidTORUSER=_torTORGROUP=daemonTORCMD=$TORDIR/torTORLOG=/var/log/tor.log## Determine OSX Version# map version to nameif [ -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    "10.6") ARCH="i386";;	"10.5") ARCH="i386";; 	"10.4") ARCH="i386";; 	"10.3") ARCH="ppc";; 	"10.2") ARCH="ppc";; 	"10.1") ARCH="ppc";; 	"10.0") ARCH="ppc";;      esacelse	ARCH="unknown"fi if [ $ARCH != "i386" ]; then	export EVENT_NOKQUEUE=1fi### Tor Service##. /etc/rc.commonStartService (){    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		$TORCMD -f "$TORCONF" --runasdaemon 1 --pidfile "$TORPID" --datadirectory "$TORDATA" --user "$TORUSER" --group "$TORGROUP" --log "notice file $TORLOG" &	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; }if [ "$#" = 0 ]; then  echo "Syntax: tor {start|stop}"  exit 1fi RunService "$1"
 |