Sync usage() with arp.8
[dragonfly.git] / etc / periodic / daily / 460.status-mail-rejects
blob191426c85505211ee94230c6781f258405db98b4
1 #!/bin/sh
3 # $FreeBSD: src/etc/periodic/daily/460.status-mail-rejects,v 1.16 2003/11/07 21:55:35 ru Exp $
4 # $DragonFly: src/etc/periodic/daily/460.status-mail-rejects,v 1.3 2004/11/15 08:11:59 joerg Exp $
7 # If there is a global system configuration file, suck it in.
9 if [ -r /etc/defaults/periodic.conf ]
10 then
11 . /etc/defaults/periodic.conf
12 source_periodic_confs
15 case "$daily_status_mail_rejects_enable" in
16 [Yy][Ee][Ss])
17 if [ ! -d /etc/mail ]
18 then
19 echo '$daily_status_mail_rejects_enable is set but /etc/mail' \
20 "doesn't exist"
21 rc=2
22 elif [ ! -f /var/log/maillog ]
23 then
24 echo '$daily_status_mail_rejects_enable is set but ' \
25 "/var/log/maillog doesn't exist"
26 rc=2
27 elif [ "$daily_status_mail_rejects_logs" -le 0 ]
28 then
29 echo '$daily_status_mail_rejects_enable is set but ' \
30 '$daily_status_mail_rejects_logs is not greater than zero'
31 rc=2
32 else
33 echo
34 echo Checking for rejected mail hosts:
36 start=`date -v-1d '+%b %e'`
37 n=$(($daily_status_mail_rejects_logs - 2))
38 rc=$({
39 while [ $n -ge 0 ]
41 if [ -f /var/log/maillog.$n ]
42 then
43 cat /var/log/maillog.$n
44 elif [ -f /var/log/maillog.$n.gz ]
45 then
46 zcat -fc /var/log/maillog.$n.gz
47 elif [ -f /var/log/maillog.$n.bz2 ]
48 then
49 bzcat -fc /var/log/maillog.$n.bz2
51 n=$(($n - 1))
52 done
53 cat /var/log/maillog
54 } |
55 fgrep 'reject=' |
56 egrep -e "^$start.*ruleset=check_[^[:space:]]+,[[:space:]]+arg1=(<[^@]+@)?([^>,]+).*reject=.*" |
57 sed -e 's/.*arg1=//' -e 's/.*@//' -e 's/[>[:space:]].*$//' |
58 sort -f | uniq -ic | sort -fnr | tee /dev/stderr | wc -l)
59 [ $rc -gt 0 ] && rc=1
60 fi;;
62 *) rc=0;;
63 esac
65 exit $rc