Skip to content

Instantly share code, notes, and snippets.

@srounet
Created March 23, 2013 23:03
Show Gist options
  • Save srounet/5229668 to your computer and use it in GitHub Desktop.
Save srounet/5229668 to your computer and use it in GitHub Desktop.
Tor rc.d for FreeBSD 9.1
#!/bin/sh
# $FreeBSD: branches/RELENG_9_1_0/security/tor/files/tor.in 300897 2012-07-14 14:29:18Z beat $
. /etc/rc.subr
name="tor"
rcvar=tor_enable
load_rc_config ${name}
: ${tor_user="_tor"}
: ${tor_datadir="/var/db/tor"}
: ${tor_pidfile="/var/run/tor/tor.pid"}
max=10
for i in `seq 1 $max`
do
[ -d ${tor_datadir}$i ] || mkdir -p ${tor_datadir}$i
chown ${tor_user}:${tor_user} ${tor_datadir}$i
chmod 700 ${tor_datadir}$i
chmod g+s ${tor_datadir}$i
required_dirs=${tor_datadir}$i
pidfile=${tor_pidfile}$i
command="/usr/local/bin/${name}"
command_args="--SocksPort $((9050 + i)) --PidFile ${pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}$i"
run_rc_command "$1"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment