#!/bin/sh
#
# $NetBSD: rspamd.sh,v 1.3 2024/04/25 15:19:22 taca Exp $
#
# PROVIDE: rspamd
# REQUIRE: DAEMON
# BEFORE: mail

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

name="rspamd"
rcvar=$name
command="/usr/pkg/bin/rspamd"
pidfile="/var/run/rspamd/${name}.pid"
command_args="-u rspamd -g rspamd -c /usr/pkg/etc/rspamd/rspamd.conf"
extra_commands="reload"
required_files="/usr/pkg/etc/rspamd/rspamd.conf"
start_precmd="rspamd_precmd"

rspamd_precmd()
{
	if [ ! -d /var/run/rspamd ]; then
		/bin/mkdir -p /var/run/rspamd
		/bin/chmod 0755 /var/run/rspamd
		/usr/sbin/chown rspamd:rspamd /var/run/rspamd
	fi
}

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

