#!/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>
# Modified for masqmail by Oliver Kurth <oku@masqmail.cx>
set -e
# If you disable this file, masqmail can be run from /etc/inetd.conf
#exit 0
# defaults, do not edit here but in
# /etc/default/masqmail
INIT_SMTP_DAEMON=true
INIT_QUEUE_DAEMON=true
INIT_FETCH_DAEMON=false
QUEUE_DAEMON_IVAL=-q10m
FETCH_DAEMON_IVAL=-go5m
RUN_DIR=/var/run/masqmail
[ -r /etc/default/masqmail ] && . /etc/default/masqmail
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/masqmail
NAME=masqmail
DESC="MTA (masqmail)"
test -x $DAEMON || exit 0
if [ ! -f /etc/masqmail/masqmail.conf ] ; then
echo "you have to configure masqmail first."
exit 0
fi
if [ x"$INIT_SMTP_DAEMON" = x"true" ] || [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
DAEMON_ARGS=
if [ x"$INIT_SMTP_DAEMON" = x"true" ] ; then
DAEMON_ARGS=-bd
fi
if [ x"$INIT_QUEUE_DAEMON" = x"true" ] ; then
DAEMON_ARGS="$DAEMON_ARGS $QUEUE_DAEMON_IVAL"
fi
INIT_DAEMON=true
else
INIT_DAEMON=false
fi
case "$1" in
start)
echo -n "Starting $DESC: "
if [ x"$INIT_DAEMON" = x"true" ] ; then
update-inetd --disable smtp
start-stop-daemon --start --startas $DAEMON \
--pidfile $RUN_DIR/masqmail.pid -- $DAEMON_ARGS
echo -n " listen/queue"
fi
if [ x"$INIT_FETCH_DAEMON" = x"true" ] ; then
start-stop-daemon --start --startas $DAEMON \
--pidfile $RUN_DIR/masqmail-get.pid -- $FETCH_DAEMON_IVAL
echo -n " fetch"
fi
echo "."
;;
stop)
echo -n "Stopping $DESC: "
if [ -f $RUN_DIR/masqmail.pid ] ; then
start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail.pid
update-inetd --enable smtp
echo -n " listen/queue"
fi
if [ -f $RUN_DIR/masqmail-get.pid ] ; then
start-stop-daemon --stop --oknodo --retry 1 --name $NAME --pidfile $RUN_DIR/masqmail-get.pid
echo -n " fetch"
fi
echo "."
;;
restart)
$0 stop
$0 start
;;
reload|force-reload)
echo -n "Reloading $DESC configuration files: "
if [ -f $RUN_DIR/masqmail.pid ] ; then
start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail.pid
echo -n " listen/queue"
fi
if [ -f $RUN_DIR/masqmail-get.pid ] ; then
start-stop-daemon --stop --signal 1 --pidfile $RUN_DIR/masqmail-get.pid
echo -n " fetch"
fi
echo "."
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
syntax highlighted by Code2HTML, v. 0.9.1