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