#!/bin/sh

# PROVIDE: c-icap
# REQUIRE: DAEMON cleanvar
# BEFORE: LOGIN

#
# Add the following lines to /etc/rc.conf to enable c-icap:
#
# c_icap_enable="YES"
# c_icap_flags="<set as needed>"
#
# See '%%PREFIX%%/bin/c-icap --help' for flags
#

. /etc/rc.subr

name=c_icap
rcvar=c_icap_enable

command="%%PREFIX%%/bin/c-icap"

stop_postcmd="rm -f $pidfile"

# read settings, set default values
load_rc_config "$name"
: ${c_icap_enable="NO"}
: ${c_icap_conf="%%PREFIX%%/etc/c-icap/c-icap.conf"}
: ${c_icap_pidfile="%%RUN_DIR%%/c-icap.pid"}
: ${c_icap_user="%%CICAP_USER%%"}

pidfile="${c_icap_pidfile}"
required_files="${c_icap_conf}"
command_args="-f ${c_icap_conf}"
stop_postcmd=stop_postcmd

stop_postcmd() {
	rm -f %%RUN_DIR%%/c-icap.ctl
}

run_rc_command "$1"
