8daf906a0d8aa9983bfc6abf6fa955f487465054
[dragonfly.git] / etc / periodic / daily / 440.status-mailq
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/periodic/daily/440.status-mailq,v 1.9 2002/12/07 23:37:44 keramida Exp $
4 # $DragonFly: src/etc/periodic/daily/440.status-mailq,v 1.3 2004/11/15 08:11:59 joerg 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 | fgrep -v 'mqueue is empty' | wc -l)
37             [ $rc -gt 1 ] && rc=1
38
39             case "$daily_status_include_submit_mailq" in
40             [Yy][Ee][Ss])
41                 if [ -f /etc/mail/submit.cf ]
42                 then
43                     echo ""
44                     echo "Mail in submit queue:"
45
46                     rc=$(case "$daily_status_mailq_shorten" in
47                         [Yy][Ee][Ss])
48                             mailq -Ac |
49                                 egrep -e '^[[:space:]]+[^[:space:]]+@' |
50                                 sort |
51                                 uniq -c |
52                                 sort -nr |
53                                 awk '$1 > 1 {print $1, $2}';;
54                         *)
55                             mailq -Ac;;
56                     esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l)
57                     [ $rc -gt 1 ] && rc=1
58                 fi;;
59             esac
60         fi;;
61                 
62     *)  rc=0;;
63 esac
64
65 exit $rc