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@debian.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 [ -f /etc
/default
/exim4
] && .
/etc
/default
/exim4
41 PIDFILE
="/run/exim4/exim.pid"
42 QRPIDFILE
="/run/exim4/eximqr.pid"
45 UPEX4CONF
="update-exim4.conf"
49 if [ -x "$p/$UPEX4CONF" ]; then
51 $p/$UPEX4CONF $UPEX4OPTS $1
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 /run
/exim4
] || \
85 install -d -oDebian-exim -gDebian-exim -m750 /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 "$PIDFILE" \
110 "$DAEMON" -oP $PIDFILE \
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 start-stop-daemon
--stop --retry 5 --quiet --oknodo --remove-pidfile \
134 --pidfile "$QRPIDFILE" \
136 # exim does not remove the pidfile
137 if [ $?
-eq 2 ] ; then rm -f "$QRPIDFILE" ; fi
138 log_progress_msg
"exim4_queuerunner"
140 if [ -f "$PIDFILE" ]; then
141 start-stop-daemon
--stop --retry 5 --quiet --oknodo --remove-pidfile \
142 --pidfile "$PIDFILE" \
144 # exim does not remove the pidfile
145 if [ $?
-eq 2 ] ; then rm -f "$PIDFILE" ; fi
146 log_progress_msg
"exim4_listener"
152 case ${QUEUERUNNER} in
153 combined|no|ppp|queueonly
)
154 start-stop-daemon
--stop --signal HUP
--quiet --oknodo \
155 --pidfile "$PIDFILE" \
157 log_progress_msg
"exim4"
160 start-stop-daemon
--stop --signal HUP
--quiet --oknodo \
161 --pidfile "$PIDFILE" \
163 log_progress_msg
"exim4_listener"
164 start-stop-daemon
--stop --signal HUP
--quiet --oknodo \
165 --pidfile "$QRPIDFILE" \
167 log_progress_msg
"exim4_queuerunner"
174 for pid
in $
(pidof
$NAME); do
175 if [ "$(readlink /proc/$pid/root)" = "/" ]; then
183 # the exit value of this function reflects the status of the SMTP
184 # service. Output shows the status of the queue runner as well.
185 SMTPNAME
="SMTP listener daemon"
186 QRNAME
="separate queue runner daemon"
187 if [ "${QUEUERUNNER}" = "combined" ]; then
188 SMTPNAME
="combined SMTP listener and queue runner daemon"
189 elif [ "${QUEUERUNNER}" = "queueonly" ]; then
190 SMTPNAME
="separate queue runner daemon"
192 log_action_begin_msg
"checking $QRNAME"
193 if pidofproc
-p "$QRPIDFILE" "$DAEMON" >/dev
/null
; then
194 log_action_end_msg
0 "running"
196 if [ -e "$QRPIDFILE" ]; then
197 log_action_end_msg
1 "$QRNAME failed"
199 log_action_end_msg
0 "not running"
202 log_action_begin_msg
"checking $SMTPNAME"
203 if pidofproc
-p "$PIDFILE" "$DAEMON" >/dev
/null
; then
204 log_action_end_msg
0 "running"
207 if [ -e "$PIDFILE" ]; then
208 log_action_end_msg
1 "$SMTPNAME failed"
211 log_action_end_msg
0 "not running"
217 # check for valid configuration file
220 if ! $DAEMON -bV > /dev
/null
; then
221 log
1 "Warning! Invalid configuration file for $NAME. Exiting."
226 # check for non-empty paniclog
229 if [ -s "/var/log/exim4/paniclog" ]; then
230 if [ -z "$E4BCD_PANICLOG_NOISE" ] ||
grep -vq "$E4BCD_PANICLOG_NOISE" /var
/log
/exim
4/paniclog
; then
231 echo "ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken" 1>&2
238 log_daemon_msg
"Starting MTA"
239 # regenerate exim4.conf
247 log_daemon_msg
"Stopping MTA"
253 # check whether newly generated config would work
255 log_daemon_msg
"Stopping MTA for restart"
257 # regenerate exim4.conf
262 log_daemon_msg
"Restarting MTA"
268 log_daemon_msg
"Reloading $NAME configuration files"
269 # regenerate exim4.conf
283 echo "Usage: $0 {start|stop|restart|reload|status|force-stop}"
289 # vim:tabstop=2:expandtab:shiftwidth=2