aboutsummaryrefslogtreecommitdiff
path: root/contrib/osx/Tor
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-01-05 02:46:25 +0000
committerNick Mathewson <nickm@torproject.org>2005-01-05 02:46:25 +0000
commit20142a2508b6fb486a7df4b61afae4522fd32571 (patch)
treeb0dc496d6fb31ea6f20489a8bf3aba8bb22d40e9 /contrib/osx/Tor
parent041edf87548688b67477b9216268d18501160a4e (diff)
downloadtor-20142a2508b6fb486a7df4b61afae4522fd32571.tar
tor-20142a2508b6fb486a7df4b61afae4522fd32571.tar.gz
Forward-port OSX packaging stuff from maint branch
svn:r3299
Diffstat (limited to 'contrib/osx/Tor')
-rwxr-xr-xcontrib/osx/Tor48
1 files changed, 48 insertions, 0 deletions
diff --git a/contrib/osx/Tor b/contrib/osx/Tor
new file mode 100755
index 000000000..0752b85c5
--- /dev/null
+++ b/contrib/osx/Tor
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+TORCONF=/Library/Tor/torrc
+TORDIR=/Library/Tor/var/lib/tor
+TORPID=/var/run/Tor.pid
+TORUSER=_tor
+TORGROUP=daemon
+TORCMD=/Library/Tor/tor
+
+##
+# 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
+ $TORCMD -f $TORCONF --runasdaemon 1 --pidfile $TORPID --datadirectory $TORDIR --user $TORUSER --group $TORGROUP &
+ 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; }
+
+RunService "$1"