diff options
Diffstat (limited to 'debian/exim4-base.init')
-rw-r--r-- | debian/exim4-base.init | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/debian/exim4-base.init b/debian/exim4-base.init new file mode 100644 index 0000000..b7aeb4a --- /dev/null +++ b/debian/exim4-base.init @@ -0,0 +1,145 @@ +#! /bin/sh +# /etc/init.d/exim4 +# +# 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> +# Modified for exim4 by Andreas Metzler <ametzler@downhill.at.eu.org> + +set -e + +upex4conf() { + UPEX4CONF="update-exim4.conf" + OLDIFS="$IFS" + IFS=: + for p in $PATH; do + if [ -x "$p/$UPEX4CONF" ]; then + IFS="$OLDIFS" + $p/$UPEX4CONF + return 0 + fi + done + IFS="$OLDIFS" +} + +# Exit if exim runs from /etc/inetd.conf +if [ -f /etc/inetd.conf ] && grep -E -q "^ *([0-9.]+:)?smtp" /etc/inetd.conf; then + upex4conf + exit 0 +fi + + +DAEMON=/usr/sbin/exim4 +NAME=exim4 + +##test -x $DAEMON || exit 0 +test -x /usr/lib/exim4/exim4 || exit 0 + +#read default file +QUEUERUNNER='combined' +QUEUEINTERVAL='30m' +[ -f /etc/default/exim4 ] && . /etc/default/exim4 + +start_exim() +{ + case ${QUEUERUNNER} in + combined) + start-stop-daemon --start --pidfile /var/run/exim4/exim.pid \ + --exec $DAEMON -- -bd -q${QFLAGS}${QUEUEINTERVAL} \ + ${COMMONOPTIONS} ${QUEUERUNNEROPTIONS} ${SMTPLISTENEROPTIONS} + ;; + separate) + start-stop-daemon --start --pidfile /var/run/exim4/exim.pid \ + --exec $DAEMON -- -bd ${SMTPLISTENEROPTIONS} ${COMMONOPTIONS} + start-stop-daemon --start --pidfile /var/run/exim4/eximqr.pid \ + --exec $DAEMON -- -oP /var/run/exim4/eximqr.pid \ + -q${QFLAGS}${QUEUEINTERVAL} ${QUEUERUNNEROPTIONS} ${COMMONOPTIONS} + ;; + no) + start-stop-daemon --start --pidfile /var/run/exim4/exim.pid \ + --exec $DAEMON -- -bd ${SMTPLISTENEROPTIONS} + ;; + esac +} + +stop_exim() +{ +# we try to kill eximqr and exim SMTP listener, no matter what ${QUEUERUNNER} is +# set to, we could have switched since starting. + [ -f /var/run/exim4/eximqr.pid ] && \ + start-stop-daemon --stop --pidfile /var/run/exim4/eximqr.pid \ + --oknodo --retry 30 --exec $DAEMON + [ -f /var/run/exim4/exim.pid ] && \ + start-stop-daemon --stop --pidfile /var/run/exim4/exim.pid \ + --oknodo --retry 30 --exec $DAEMON + rm -f /var/run/exim4/eximqr.pid /var/run/exim4/exim.pid +} + +reload_exim() +{ + case ${QUEUERUNNER} in + combined|no) + start-stop-daemon --stop --pidfile /var/run/exim4/exim.pid \ + --signal 1 --exec $DAEMON + ;; + separate) + start-stop-daemon --stop --pidfile /var/run/exim4/exim.pid \ + --signal 1 --exec $DAEMON + start-stop-daemon --stop --pidfile /var/run/exim4/eximqr.pid \ + --signal 1 --exec $DAEMON + ;; + esac +} + + +# check for valid configuration file +isconfigvalid() +{ +if ! $DAEMON -bV > /dev/null ; then + echo + echo "Warning! Invalid configuration file for $NAME. Exiting." 1>&2 + exit 1 +fi +} + +case "$1" in + start) + echo -n "Starting MTA: " + # regenerate exim4.conf + upex4conf + isconfigvalid + start_exim + echo "$NAME." + ;; + stop) + echo -n "Stopping MTA: " + stop_exim + echo "$NAME." + ;; + restart) + echo -n "Restarting MTA: " + # regenerate exim4.conf + upex4conf + isconfigvalid + stop_exim + sleep 2 + start_exim + echo "$NAME." + ;; + reload|force-reload) + echo "Reloading $NAME configuration files" + # regenerate exim4.conf + upex4conf + isconfigvalid + reload_exim + ;; + status) + exiwhat + ;; + *) + echo "Usage: $0 {start|stop|restart|reload|status}" + exit 1 + ;; +esac + +exit 0 |