#!/bin/sh
#
# $NetBSD: mailman3.sh,v 1.2 2023/06/17 01:28:02 markd Exp $
#
# PROVIDE: mailman3
# REQUIRE: mail
# KEYWORD: shutdown

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

name="mailman3"
rcvar=$name
command="/usr/pkg/bin/mailman"
#command_args="-C ${mailman_config}"
start_cmd="mailman_doit start --force"
stop_cmd="mailman_doit stop"
restart_cmd="mailman_doit restart"
status_cmd="mailman_doit status"
info_cmd="mailman_doit info"
extra_commands=info
start_precmd=mailman_prestart

mailman_prestart() {
	dir="/var/run/mailman"
	if test ! -d $dir; then
		/bin/mkdir -p -p $dir
		/bin/chmod 0755 $dir
		/usr/sbin/chown mailman:mailman $dir
	fi
}

mailman_doit()
{
	LANG=en_US.UTF-8 /usr/bin/su -m mailman -c "${command} ${command_args} $*"
}

if [ -f /etc/rc.subr ]; then
	load_rc_config $name
	run_rc_command "$1"
else
	mailman_doit "$1"
fi
