#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          courier-mlm
# Required-Start:    courier-authdaemon $remote_fs $syslog
# Required-Stop:     courier-authdaemon $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Courier WebMLM server
### END INIT INFO

# Author: Ondřej Surý <ondrej@debian.org>

CONFIGFILE=/etc/courier/webmlmrc
DAEMON=/usr/bin/webmlmd
DESC="Courier WebMLM daemon"
DAEMON_ARGS="$CONFIGFILE"

test_config() {
    LISTS=$(sh -c '. $CONFIGFILE; echo "$LISTS";')
    if [ -z "$LISTS" ]; then
	log_begin_msg "$NAME: lists directories missing from configuration file, not starting/reloading..."
	log_end_msg 1
	return 1
    fi
    return 0
}

if test_config; then
    DO_START=yes
else
    DO_START=no
fi

. /usr/lib/courier/init-d-script-courier
