#! /bin/sh
# /etc/init.d/exim
#
# 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 <timc@chiark.greenend.org.uk>

set -e

# Exit if exim runs from /etc/inetd.conf
if grep -q "^ *smtp" /etc/inetd.conf; then
    exit 0
fi

DAEMON=/usr/sbin/exim
NAME=exim

test -x $DAEMON || exit 0

case "$1" in
  start)
    update-inetd --disable smtp
    echo -n "Starting MTA: "
    start-stop-daemon --start --exec $DAEMON -- -bd -q30m
    echo "exim."
    ;;
  stop)
    echo -n "Stopping MTA: "
    start-stop-daemon --stop --oknodo --exec $DAEMON
    echo "exim."
      ;;
  restart)
    echo "Restarting MTA: "
    start-stop-daemon --stop --oknodo --exec $DAEMON
    start-stop-daemon --start --exec $DAEMON -- -bd -q30m
    echo "exim."
    ;;
  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
