freebsd-ports/www/privoxy/files/privoxy.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

62 lines
2 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
#
# PROVIDE: privoxy
# REQUIRE: DAEMON
# BEFORE: LOGIN
#
# This rc script understands the following variables
# which are read from /etc/rc.conf:
#
# privoxy_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable Privoxy.
# privoxy_config (str): Privoxy's configuration file. Default is:
# %%PREFIX%%/etc/privoxy/config.
# privoxy_flags (str): List of additional Privoxy options you want
# to use. None set by default.
# privoxy_pidfile (str): Default is /var/run/privoxy/privoxy.pid.
# privoxy_user (str): Privoxy Daemon user. Default is privoxy.
#
# Usage:
# %%PREFIX%%/etc/rc.d/privoxy [fast|force|one](start|stop|restart|rcvar|status|poll)
. /etc/rc.subr
name="privoxy"
rcvar=privoxy_enable
load_rc_config ${name}
: ${privoxy_enable="NO"}
: ${privoxy_config="%%PREFIX%%/etc/privoxy/config"}
: ${privoxy_logdir="/var/log/privoxy"}
: ${privoxy_user="privoxy"}
: ${privoxy_pidfile="/var/run/privoxy/privoxy.pid"}
config_file_check () {
if [ ! -e ${privoxy_config} ]; then
echo config file not found. Copying the example file to ${privoxy_config}.
cp %%PREFIX%%/share/examples/privoxy/config ${privoxy_config}
chown ${privoxy_user}:${privoxy_user} ${privoxy_config};
fi
actionfile="%%PREFIX%%/etc/privoxy/match-all.action"
if [ ! -e ${actionfile} ]; then
echo ${actionfile} not found. Copying the example file.
cp %%PREFIX%%/share/examples/privoxy/match-all.action ${actionfile}
chown ${privoxy_user}:${privoxy_user} ${actionfile}
fi
if [ ! -e ${privoxy_logdir} ]; then
echo ${privoxy_logdir} not found. Creating ...
mkdir ${privoxy_logdir}
chown ${privoxy_user}:${privoxy_user} ${privoxy_logdir}
chmod 0750 ${privoxy_logdir}
fi
}
start_precmd="config_file_check"
command="%%PREFIX%%/sbin/privoxy"
command_args="${privoxy_flags} --pidfile ${privoxy_pidfile} ${privoxy_config}"
run_rc_command "$1"