#!/bin/ksh

daemon="${TRUEPREFIX}/sbin/conserver -d"
daemon_flags="-n"
daemon_user="_conserver"

. /etc/rc.d/rc.subr

pexp="(${daemon}${daemon_flags:+ ${daemon_flags}}|conserver: .*)"

rc_pre() {
	install -d -o _conserver /var/run/conserver
	[[ -f /var/log/conserver ]] || install -o _conserver \
	    -m 644 /dev/null /var/log/conserver
}

rc_reload() {
        if pgrep -T "${daemon_rtable}" -q -xf 'conserver: master.*'; then
                pkill -HUP -T "${daemon_rtable}" -xf 'conserver: master.*'
        else
                pkill -HUP -T "${daemon_rtable}" -xf \
		    "(${daemon}${daemon_flags:+ ${daemon_flags}}|conserver: .*)"
        fi
}

rc_stop() {
        if pgrep -T "${daemon_rtable}" -q -xf 'conserver: master.*'; then
                pkill -T "${daemon_rtable}" -xf 'conserver: master.*'
        else
                pkill -T "${daemon_rtable}" -xf \
		    "(${daemon}${daemon_flags:+ ${daemon_flags}}|conserver: .*)"
        fi
}

rc_cmd $1
