#!/sbin/openrc-run
extra_commands="checkconfig"

description="Domain-based Message Authentication, Reporting & Conformance (DMARC) Milter"
description_checkconfig="Check configuration file"

: ${cfgfile:="/etc/opendmarc/$RC_SVCNAME.conf"}
: ${command_user:="opendmarc:mail"}

command="/usr/sbin/opendmarc"
command_args="-f -c $cfgfile ${command_args:-}"
pidfile="/run/opendmarc/$RC_SVCNAME.pid"

required_files="$cfgfile"

depend() {
	use dns logger net
	before mta
}

start_pre() {
	checkpath -d -m 750 -o "$command_user" "${pidfile%/*}" || return 1
	$command -c "$cfgfile" -n
}

checkconfig() {
	ebegin "Checking $name configuration"
	$command -c "$cfgfile" -n
	eend $?
}
