#!/bin/sh
#
# $FreeBSD: head/security/tor/files/tor.in 403904 2015-12-17 10:58:13Z amdmi3 $
#
# PROVIDE: tor
# REQUIRE: DAEMON FILESYSTEMS
# BEFORE: LOGIN
#
# Add the following lines to /etc/rc.conf to enable tor.
# All these options will overide any settings in your local torrc as
# they are command line options.
#
# tor_enable (bool):	Set it to "YES" to enable tor. Default: NO
# tor_conf (str):	Points to your torrc file.
#			Default: %%PREFIX%%/etc/tor/torrc
# tor_user (str):	Tor daemon user. Default: _tor
# tor_datadir (str):	Tor datadir.  Default: /var/db/tor
#

. /etc/rc.subr

name="tor"
rcvar=tor_enable

load_rc_config ${name}

: ${tor_enable="NO"}
: ${tor_conf="%%PREFIX%%/etc/tor/torrc"}
: ${tor_user="_tor"}
: ${tor_pidfile="/var/run/tor/tor.pid"}
: ${tor_datadir="/var/db/tor"}

required_files=${tor_conf}
required_dirs=${tor_datadir}
pidfile=${tor_pidfile}
command="%%PREFIX%%/bin/${name}"
command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}"
extra_commands="reload"

run_rc_command "$1"