#!/bin/sh
#
# $NetBSD: postgrey.sh,v 1.3 2019/09/07 17:13:56 kim Exp $
#

# PROVIDE: postgrey
# BEFORE: mail
# REQUIRE: DAEMON LOGIN

. /etc/rc.subr

name="postgrey"
rcvar=$name
pidfile="/var/run/${name}/${name}.pid"
command_interpreter="/usr/pkg/bin/perl"
command="/usr/pkg/sbin/postgrey"
command_args="-d --pidfile=${pidfile}"
required_files="
 /usr/pkg/etc/postfix/postgrey_whitelist_clients
 /usr/pkg/etc/postfix/postgrey_whitelist_recipients
"
postgrey_flags=${postgrey_flags-"-i 2525"}
extra_commands="reload"
start_precmd="postgrey_precmd"

postgrey_precmd()
{
	if [ ! -d "/var/run/${name}" ]; then
		/bin/mkdir -p "/var/run/${name}"
		/bin/chmod 775 "/var/run/${name}"
		/usr/sbin/chown postgrey:postgrey "/var/run/${name}"
	fi
}

load_rc_config $name
run_rc_command "$1"
