440.status-mailq revision 65843
1#!/bin/sh
2#
3# $FreeBSD: head/etc/periodic/daily/440.status-mailq 65843 2000-09-14 17:19:15Z brian $
4#
5
6# If there is a global system configuration file, suck it in.
7#
8if [ -r /etc/defaults/periodic.conf ]
9then
10    . /etc/defaults/periodic.conf
11    source_periodic_confs
12fi
13
14case "$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	elif [ ! -d /var/spool/mqueue ]
22	then
23	    echo '$daily_status_mailq_enable is set but /var/spool/mqueue' \
24		"doesn't exist"
25	    rc=2
26	else
27	    echo ""
28	    echo "Mail in local queue:"
29
30	    rc=$(case "$daily_status_mailq_shorten" in
31		[Yy][Ee][Ss])
32		    rc=$(mailq |
33			perl -ne  'print if /^\s+\S+@/' |
34			sort |
35			uniq -c |
36			sort -nr |
37			awk '$1 > 1 {print $1, $2}');;
38		*)
39		    mailq;;
40	    esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l)
41	    [ $rc -gt 1 ] && rc=1
42	fi;;
43
44    *)  rc=0;;
45esac
46
47exit $rc
48