#!/bin/sh

# PROVIDE: miltersid
# REQUIRE: DAEMON
# BEFORE: mail localpkg
# KEYWORD: shutdown
#
# Define these miltersid_* variables in one of these files:
#	/etc/rc.conf
#	/etc/rc.conf.local
#	/etc/rc.conf.d/miltersid
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#

. /etc/rc.subr

name="miltersid"
desc="SID Milter Daemon"
rcvar="miltersid_enable"
load_rc_config $name

: ${miltersid_enable:="NO"}
: ${miltersid_socket:="local:/var/run/sid-filter"}
: ${miltersid_pid:="/var/run/sid-filter.pid"}
: ${miltersid_flags:="-r 0 -t"}
pidfile=${miltersid_pid}
command="%%PREFIX%%/libexec/sid-filter"
command_args="-l -p ${miltersid_socket} -P ${miltersid_pid}"
start_precmd="sid_precmd"

sid_precmd()
{
	if [ -S ${miltersid_socket##local:} ] ; then
		rm -f ${miltersid_socket##local:}
	elif [ -S ${miltersid_socket##unix:} ] ; then
		rm -f ${miltersid_socket##unix:}
	fi
}

run_rc_command "$1"
