3 if [ -n "$EX4DEBUG" ]; then
4 echo "now debugging $0 $@"
9 # set this to some other value if you don't want the panic log to be
10 # watched by this script, for example when you're using your own log
11 # checking mechanisms or don't care.
13 E4BCD_DAILY_REPORT_TO
=""
14 E4BCD_DAILY_REPORT_OPTIONS
=""
15 E4BCD_WATCH_PANICLOG
="yes"
16 # Number of lines of paniclog quoted in warning email.
17 E4BCD_PANICLOG_LINES
="10"
18 E4BCD_PANICLOG_NOISE
=""
20 # Only do anything if exim4 is actually installed
21 if [ ! -x /usr
/lib
/exim
4/exim4
]; then
25 [ -f /etc
/default
/exim4
] && .
/etc
/default
/exim4
27 SPOOLDIR
="$(exim4 -bP spool_directory | sed 's/.*=[[:space:]]\(.*\)/\1/')"
29 # The log processing code used in this cron script is not very
30 # sophisticated. It relies on this cron job being executed earlier than
31 # the log rotation job, and will have false results if the log is not
32 # rotated exactly once daily in the daily cron processing. Even in the
33 # default configuration, it will ignore log entries made between this
34 # cron job and the log rotation job.
36 # Patches for more sophisticated processing are appreciated via the
39 E4BCD_MAINLOG_NOISE
="^[[:digit:][:space:]:-]\{20\}\(\(Start\|End\) queue run: pid=[[:digit:]]\+\|exim [[:digit:]\.]\+ daemon started: pid=[[:digit:]]\+, .*\)$"
41 if [ -n "$E4BCD_DAILY_REPORT_TO" ]; then
42 if [ -x "$(command -v eximstats)" ] && [ -x "$(command -v mail)" ]; then
43 if [ "$(< /var/log/exim4/mainlog grep -v "$E4BCD_MAINLOG_NOISE" | wc -l)" -gt "0" ]; then
44 < /var
/log
/exim
4/mainlog
grep -v "$E4BCD_MAINLOG_NOISE" \
45 | eximstats
$E4BCD_DAILY_REPORT_OPTIONS \
46 |
mail -s"$(hostname --fqdn) Daily e-mail activity report" \
47 $E4BCD_DAILY_REPORT_TO
49 echo "no mail activity in this interval" \
50 |
mail -s"$(hostname --fqdn) Daily e-mail activity report" \
51 $E4BCD_DAILY_REPORT_TO
54 echo "The exim4 cron job is configured to send a daily report, but eximstats"
55 echo "and/or mail cannot be found. Please check and make sure that these two"
56 echo "binaries are available"
62 if ! logger
-t exim4
-p mail.alert
$TEXT; then
64 echo >&2 "ALERT: could not syslog $TEXT, logger return value $RET"
68 if [ "$E4BCD_WATCH_PANICLOG" != "no" ]; then
69 if [ -s "/var/log/exim4/paniclog" ]; then
70 if [ -x "/usr/local/lib/exim4/nonzero_paniclog_hook" ]; then
71 /usr
/local
/lib
/exim
4/nonzero_paniclog_hook
73 if [ -z "$E4BCD_PANICLOG_NOISE" ] ||
grep -vq "$E4BCD_PANICLOG_NOISE" /var
/log
/exim
4/paniclog
; then
74 log_this
"ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken"
75 if ! printf "Subject: exim paniclog on %s has non-zero size\nTo: root\n\nexim paniclog /var/log/exim4/paniclog on %s has non-zero size, mail system might be broken. The last ${E4BCD_PANICLOG_LINES} lines are quoted below.\n\n%s\n" \
76 "$(hostname --fqdn)" "$(hostname --fqdn)" \
77 "$(tail -n "${E4BCD_PANICLOG_LINES}" /var/log/exim4/paniclog)" \
79 log_this
"PANIC: sending out e-mail warning has failed, exim has non-zero return code"
81 if [ "$E4BCD_WATCH_PANICLOG" = "once" ]; then
82 logrotate
-f /etc
/logrotate.d
/exim4-paniclog
88 # run tidydb as Debian-exim:Debian-exim.
89 if [ -x /usr
/sbin
/exim_tidydb
]; then
90 cd $SPOOLDIR/db ||
exit 1
91 if ! find $SPOOLDIR/db
-maxdepth 1 -name '*.lockfile' -or -name 'log.*' \
92 -or -type f
-printf '%f\0' | \
94 start-stop-daemon
--start --exec /usr
/sbin
/exim_tidydb \
95 --chuid Debian-exim
:Debian-exim
-- $SPOOLDIR > /dev
/null
; then
96 # if we reach this, invoking exim_tidydb from start-stop-daemon has
97 # failed, most probably because of libpam-tmpdir being in use
98 # (see #373786 and #376165)
99 find $SPOOLDIR/db
-maxdepth 1 -name '*.lockfile' -or -name 'log.*' \
100 -or -type f
-printf '%f\0' | \
101 runuser
--shell=/bin
/bash \
102 --command="xargs -0r -n 1 /usr/sbin/exim_tidydb $SPOOLDIR > /dev/null" \