#! /bin/sh

# Invoke the nullmailer init scrit under the sid root.
#
# Note: unlike usual init scripts, this script does not start or stop the
#       daemon directly; instead, it calls invoke-rc.d under the sid root
#       so that the init policy (/usr/sbin/policy-rc.d) defined there is
#       not bypassed.
#
# Created by Florent.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

ORIGNAME=nullmailer
NAME="local-sid-root-$ORIGNAME"
DESC="mail transport agent (sid root)"
CHROOTED_SID_BASE=/mnt/mm/sid-root
DAEMON="$CHROOTED_SID_BASE/usr/sbin/nullmailer-send"

N="/etc/init.d/$NAME"

test -x "$DAEMON" || exit 0

set -e

help ()
{
    echo "Usage: $N { start | stop | restart | force-reload }" >&2
}

case "$1" in
  start|stop|restart|force-reload)
        chroot "$CHROOTED_SID_BASE" invoke-rc.d "$ORIGNAME" "$1"
	;;
  *)
        help
	exit 2                  # LSB: invalid or excess argument(s)
                                # (according to the init script of nullmailer
                                # 1.00RC7-21)
	;;
esac

exit 0
