Sync etc/periodic with FreeBSD. Short summary:
[dragonfly.git] / etc / periodic / daily / 440.status-mailq
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/periodic/daily/440.status-mailq,v 1.11 2006/03/08 17:26:53 matteo Exp $
4 # $DragonFly: src/etc/periodic/daily/440.status-mailq,v 1.4 2007/12/29 21:44:44 matthias Exp $
5 #
6
7 # If there is a global system configuration file, suck it in.
8 #
9 if [ -r /etc/defaults/periodic.conf ]
10 then
11     . /etc/defaults/periodic.conf
12     source_periodic_confs
13 fi
14
15 case "$daily_status_mailq_enable" in
16     [Yy][Ee][Ss])
17         if [ ! -x /usr/bin/mailq ]
18         then
19             echo '$daily_status_mailq_enable is set but /usr/bin/mailq' \
20                 "isn't executable"
21             rc=2
22         else
23             echo ""
24             echo "Mail in local queue:"
25
26             rc=$(case "$daily_status_mailq_shorten" in
27                 [Yy][Ee][Ss])
28                     mailq |
29                         egrep -e '^[[:space:]]+[^[:space:]]+@' |
30                         sort |
31                         uniq -c |
32                         sort -nr |
33                         awk '$1 >= 1 {print $1, $2}';;
34                 *)
35                     mailq;;
36             esac | tee /dev/stderr |
37             egrep -v '(mqueue is empty|Total requests)' | wc -l)
38             [ $rc -gt 0 ] && rc=1 || rc=0
39
40             case "$daily_status_include_submit_mailq" in
41             [Yy][Ee][Ss])
42                 if [ -f /etc/mail/submit.cf ]
43                 then
44                     echo ""
45                     echo "Mail in submit queue:"
46
47                     rc_submit=$(case "$daily_status_mailq_shorten" in
48                         [Yy][Ee][Ss])
49                             mailq -Ac |
50                                 egrep -e '^[[:space:]]+[^[:space:]]+@' |
51                                 sort |
52                                 uniq -c |
53                                 sort -nr |
54                                 awk '$1 >= 1 {print $1, $2}';;
55                         *)
56                             mailq -Ac;;
57                     esac | tee /dev/stderr |
58                     egrep -v '(mqueue is empty|Total requests)' | wc -l)
59                     [ $rc_submit -gt 0 ] && rc=1
60                 fi;;
61             esac
62         fi;;
63                 
64     *)  rc=0;;
65 esac
66
67 exit $rc