One more update for FlySpray #341.
[tor/rransom.git] / contrib / osx / Tor
blob9e62cf180d9d996553e8a928f65134028af557dc
1 #!/bin/sh
3 TORLOC=/Library/StartupItems/Tor/Tor.loc
5 if [ -f $TORLOC ]; then
6 TORDIR=`cat /Library/StartupItems/Tor/Tor.loc`
7 if [ "x$TORDIR" = "x" -o ! -d $TORDIR -o ! -x $TORDIR/tor ]; then
8 TORDIR=/Library/Tor
9 fi
10 else
11 TORDIR=/Library/Tor
13 TORCONF=$TORDIR/torrc
14 TORDATA=$TORDIR/var/lib/tor
15 TORPID=/var/run/Tor.pid
16 TORUSER=_tor
17 TORGROUP=daemon
18 TORCMD=$TORDIR/tor
19 TORLOG=/var/log/tor.log
22 # Tor Service
25 . /etc/rc.common
27 StartService ()
30 if [ -f $TORCMD ]; then
31 if pid=$(GetPID Tor); then
32 return 0
33 else
34 ConsoleMessage "Starting Tor Service"
35 # Tentative
36 # Making sure it is not running (I know it is not a best approarch)
37 killall tor 2>/dev/null
38 $TORCMD -f "$TORCONF" --runasdaemon 1 --pidfile "$TORPID" --datadirectory "$TORDATA" --user "$TORUSER" --group "$TORGROUP" --log "notice file $TORLOG" &
43 StopService ()
45 if pid=$(GetPID Tor); then
46 ConsoleMessage "Stopping Tor Service"
47 kill -TERM "${pid}"
48 # Just for sanity (sometimes necessary.)
49 killall tor 2>/dev/null
50 else
51 ConsoleMessage "Tor Service not responding."
52 # Just for sanity (sometimes necessary.)
53 killall tor 2>/dev/null
57 RestartService () { StopService; StartService; }
59 if [ "$#" = 0 ]; then
60 echo "Syntax: tor {start|stop}"
61 exit 1
62 fi
64 RunService "$1"