#! /bin/sh
# /etc/init.d/masqmail
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for exim by Tim Cutts <tjrc1@mole.bio.cam.ac.uk>
# Modified for masqmail by Gregor Hoffleit <flight@debian.org>

set -e

# If you disable this file, masqmail can be run from /etc/inetd.conf
#exit 0

DAEMON=/usr/sbin/masqmail
NAME=masqmail

test -x $DAEMON || exit 0

case "$1" in
  start)
    update-inetd --disable smtp
    echo -n "Starting MTA: "
    start-stop-daemon --start --exec $DAEMON -- -bd -q10m
    echo "masqmail."
    ;;
  stop)
    echo -n "Stopping MTA: "
    start-stop-daemon --stop --oknodo --name $NAME --exec $DAEMON
    echo "masqmail."
    update-inetd --enable smtp
      ;;
  restart)
    echo "Restarting MTA: "
    start-stop-daemon --stop --oknodo --name $NAME --exec $DAEMON
    start-stop-daemon --start --exec $DAEMON -- -bd -q10m
    echo "masqmail."
    ;;
  reload|force-reload)
    echo "Reloading $NAME configuration files"
    start-stop-daemon --stop --signal 1 --exec $DAEMON
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|reload}"
    exit 1
    ;;
esac

exit 0
