#!/bin/sh
#
# $NetBSD: opendmarc.sh,v 1.1 2013/12/05 16:00:19 pettai Exp $
#
# PROVIDE: opendmarc
# REQUIRE: DAEMON
# BEFORE: mail

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="opendmarc"
rcvar=$name
command="/usr/pkg/sbin/opendmarc"
pidfile="/var/run/opendmarc/${name}.pid"
command_args="-P ${pidfile} -c /usr/pkg/etc/opendmarc/opendmarc.conf" 
required_files="/usr/pkg/etc/opendmarc/opendmarc.conf"
start_precmd="opendmarc_precmd"

opendmarc_precmd()
{
	if [ ! -d /var/run/opendmarc ]; then
		/bin/mkdir -p /var/run/opendmarc
		/bin/chmod 0750 /var/run/opendmarc
	fi

	if [ -f /var/run/opendmarc/${name}.sock ]; then
		/bin/rm -f /var/run/opendmarc/${name}.sock
	fi
}

if [ -f /etc/rc.subr ]; then
        load_rc_config $name
	run_rc_command "$1"
else
	echo -n " ${name}"
	${command} ${opendmarc_flags} ${command_args}
fi
