r17097@catbus: nickm | 2007-12-11 18:13:48 -0500
[tor.git] / contrib / rc.subr
blob8852b60466de838765ff5933bfa517b3998b21f2
1 #!/bin/sh
2 # $Id$
3 # $FreeBSD: ports/security/tor-devel/files/tor.in,v 1.1 2006/02/17 22:21:25 mnag Exp $
5 # (rc.subr written by Peter Thoenen for Net/FreeBSD)
7 # REQUIRE: NETWORKING SERVERS USR
8 # BEFORE: LOGIN
10 # Add the following lines to /etc/rc.conf to enable tor
12 # tor_enable (bool): Set to "NO" by default
13 # Set it to "YES" to enable tor
14 # tor_conf (str): Points to your tor conf file
15 # Default: /usr/local/etc/tor/torrc
16 # tor_user (str): Tor Daemon user. Default _tor
17 # tor_groupr (str): Tor Daemon group. Default _tor
20 . /etc/rc.subr
22 name="tor"
23 rcvar=${name}_enable
25 load_rc_config ${name}
27 : ${tor_enable="NO"}
28 : ${tor_conf="/usr/local/etc/tor/torrc"}
29 : ${tor_user="_tor"}
30 : ${tor_group="_tor"}
31 : ${tor_pidfile="/var/run/tor/tor.pid"}
32 : ${tor_logfile="/var/log/tor"}
33 : ${tor_datadir="/var/run/tor"}
35 required_files=${tor_conf}
36 required_dirs=${tor_datadir}
37 command="/usr/local/bin/${name}"
38 command_args="-f ${tor_conf} --pidfile ${tor_pidfile} --runasdaemon 1 --datadirectory ${tor_datadir} --user ${tor_user} --group ${tor_group}"
39 extra_commands="log"
40 log_cmd="${name}_log"
42 tor_log() {
43 cat ${tor_logfile}
46 run_rc_command "$1"