#!/bin/sh

# PROVIDE: dspam
# REQUIRE: DAEMON   clamd
# BEFORE: mail
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf[.local] to enable dspam:
# dspam_enable="YES"
#
# dspam_debug="YES" will start dspam with debug logging (you need ar least WITH_DEBUG)
# you can also set the pid file via dspam_pidfile
#

. /etc/rc.subr

name="dspam"
rcvar=dspam_enable

load_rc_config $name

#defaults
: ${dspam_enable="NO"}
: ${dspam_debug="NO"}
: ${dspam_pidfile:-/var/run/dspam/dspam.pid}
: ${dspam_user="dspam"}
: ${dspam_group="dspam"}

command=/usr/local/bin/${name}

start_precmd=dspam_checkdebug
extra_commands=reload

required_dirs=/var/db/dspam
required_files=/usr/local/etc/${name}.conf

dspam_checkdebug()
{
	if checkyesno dspam_debug
	then
		command_args="--daemon --debug > /dev/null 2>&1 &"
	else
		command_args="--daemon > /dev/null 2>&1 &"
	fi
}

reload()
{
 kill -HUP `cat $pidfile`
}

run_rc_command "$1"
