4 # Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
5 # Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
6 # Modified for exim by Tim Cutts <timc@chiark.greenend.org.uk>
7 # Modified for exim4 by Andreas Metzler <ametzler@downhill.at.eu.org>
8 # and Marc Haber <mh+debian-packages@zugschlus.de>
12 # Required-Start: $remote_fs $syslog $named $network $time
13 # Required-Stop: $remote_fs $syslog $named $network
14 # Should-Start: postgresql mysql clamav-daemon greylist spamassassin
15 # Should-Stop: postgresql mysql clamav-daemon greylist spamassassin
16 # Default-Start: 2 3 4 5
18 # Short-Description: exim Mail Transport Agent
19 # Description: exim is a Mail Transport agent
24 test -x /usr
/lib
/exim
4/exim4 ||
exit 0
26 .
/lib
/lsb
/init-functions
28 if [ -n "$EX4DEBUG" ]; then
29 echo "now debugging $0 $@"
37 QUEUERUNNER
='combined'
40 PIDFILE
="/var/run/exim4/exim.pid"
41 QRPIDFILE
="/var/run/exim4/eximqr.pid"
42 [ -f /etc
/default
/exim4
] && .
/etc
/default
/exim4
45 UPEX4CONF
="update-exim4.conf"
49 if [ -x "$p/$UPEX4CONF" ]; then
51 $p/$UPEX4CONF $UPEX4OPTS
58 # Exit if exim runs from /etc/inetd.conf
59 if [ -f /etc
/inetd.conf
] && grep -E -q '^[[:space:]]*((\*|[[:alnum:].-]+):)?smtp[[:space:]]' /etc
/inetd.conf
66 DAEMON
="/usr/sbin/exim4"
69 # this is from madduck on IRC, 2006-07-06
70 # There should be a better possibility to give daemon error messages
71 # and/or to log things
75 [[:digit
:]]*) success
=$1; shift;;
78 log_action_begin_msg
"$1"; shift
79 log_action_end_msg
${success:-0} "$*"
84 [ -e /var
/run
/exim4
] || \
85 install -d -oDebian-exim -gDebian-exim -m750 /var
/run
/exim4
86 case ${QUEUERUNNER} in
88 start_daemon
-p "$PIDFILE" \
89 "$DAEMON" -bd "-q${QFLAGS}${QUEUEINTERVAL}" \
91 ${QUEUERUNNEROPTIONS} \
92 ${SMTPLISTENEROPTIONS}
93 log_progress_msg
"exim4"
96 start_daemon
-p "$PIDFILE" \
99 ${SMTPLISTENEROPTIONS}
100 log_progress_msg
"exim4_listener"
101 start_daemon
-p "$QRPIDFILE" \
102 "$DAEMON" -oP $QRPIDFILE \
103 "-q${QFLAGS}${QUEUEINTERVAL}" \
105 ${QUEUERUNNEROPTIONS}
106 log_progress_msg
"exim4_queuerunner"
109 start_daemon
-p "$QRPIDFILE" \
110 "$DAEMON" -oP $QRPIDFILE \
111 "-q${QFLAGS}${QUEUEINTERVAL}" \
113 ${QUEUERUNNEROPTIONS}
114 log_progress_msg
"exim4_queuerunner"
117 start_daemon
-p "$PIDFILE" \
120 ${SMTPLISTENEROPTIONS}
121 log_progress_msg
"exim4_listener"
130 # we try to kill eximqr and exim SMTP listener, no matter what
131 # ${QUEUERUNNER} is set to, we could have switched since starting.
132 if [ -f "$QRPIDFILE" ]; then
133 killproc
-p "$QRPIDFILE" "$DAEMON"
134 # exim does not remove the pidfile
135 if [ $?
-eq 0 ] ; then rm -f "$QRPIDFILE" ; fi
136 log_progress_msg
"exim4_queuerunner"
138 if [ -f "$PIDFILE" ]; then
139 killproc
-p "$PIDFILE" "$DAEMON"
140 # exim does not remove the pidfile
141 if [ $?
-eq 0 ] ; then rm -f "$PIDFILE" ; fi
142 log_progress_msg
"exim4_listener"
148 case ${QUEUERUNNER} in
150 killproc
-p "$PIDFILE" "$DAEMON" -HUP
151 log_progress_msg
"exim4"
154 killproc
-p "$PIDFILE" "$DAEMON" -HUP
155 log_progress_msg
"exim4_listener"
156 killproc
-p "$QRPIDFILE" "$DAEMON" -HUP
157 log_progress_msg
"exim4_queuerunner"
164 for pid
in $
(pidof
$NAME); do
165 if [ "$(readlink /proc/$pid/root)" = "/" ]; then
173 # the exit value of this function reflects the status of the SMTP
174 # service. Output shows the status of the queue runner as well.
175 SMTPNAME
="SMTP listener daemon"
176 QRNAME
="separate queue runner daemon"
177 if [ "${QUEUERUNNER}" = "combined" ]; then
178 SMTPNAME
="combined SMTP listener and queue runner daemon"
180 log_action_begin_msg
"checking $QRNAME"
181 if pidofproc
-p "$QRPIDFILE" "$DAEMON" >/dev
/null
; then
182 log_action_end_msg
0 "running"
184 if [ -e "$QRPIDFILE" ]; then
185 log_action_end_msg
1 "$QRNAME failed"
187 log_action_end_msg
0 "not running"
190 log_action_begin_msg
"checking $SMTPNAME"
191 if pidofproc
-p "$PIDFILE" "$DAEMON" >/dev
/null
; then
192 log_action_end_msg
0 "running"
195 if [ -e "$PIDFILE" ]; then
196 log_action_end_msg
1 "$SMTPNAME failed"
199 log_action_end_msg
0 "not running"
205 # check for valid configuration file
208 if ! $DAEMON -bV > /dev
/null
; then
209 log
1 "Warning! Invalid configuration file for $NAME. Exiting."
214 # check for non-empty paniclog
217 if [ -s "/var/log/exim4/paniclog" ]; then
218 if [ -z "$E4BCD_PANICLOG_NOISE" ] ||
grep -vq "$E4BCD_PANICLOG_NOISE" /var
/log
/exim
4/paniclog
; then
219 echo "ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken" 1>&2
226 log_daemon_msg
"Starting MTA"
227 # regenerate exim4.conf
235 log_daemon_msg
"Stopping MTA"
241 log_daemon_msg
"Stopping MTA for restart"
242 # regenerate exim4.conf
248 log_daemon_msg
"Restarting MTA"
254 log_daemon_msg
"Reloading $NAME configuration files"
255 # regenerate exim4.conf
269 echo "Usage: $0 {start|stop|restart|reload|status|what|force-stop}"
275 # vim:tabstop=2:expandtab:shiftwidth=2