#!/bin/sh
#
# $NetBSD: dkimproxy_in.sh,v 1.2 2025/04/11 14:49:02 schmonz Exp $
#
# PROVIDE: dkimproxy_in
# REQUIRE: DAEMON
# BEFORE: mail

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

name="dkimproxy_in"
rcvar=$name
command="/usr/pkg/bin/dkimproxy.in"
command_interpreter="/usr/pkg/bin/perl"
pidfile="/var/run/dkimproxy/${name}.pid"
command_args="--pidfile=${pidfile} --daemonize --conf_file=/usr/pkg/etc/dkimproxy_in.conf --user=dkimproxy --group=dkimproxy"
required_files="/usr/pkg/etc/dkimproxy_in.conf"
start_precmd="dkimproxy_precmd"

dkimproxy_precmd()
{
	if [ ! -d /var/run/dkimproxy ]; then
		/bin/mkdir -p /var/run/dkimproxy
		/bin/chmod 0750 /var/run/dkimproxy
		/usr/sbin/chown dkimproxy:dkimproxy /var/run/dkimproxy
	fi

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

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