440.status-mailq revision 94342
128263Spst#!/bin/sh 228263Spst# 350472Speter# $FreeBSD: head/etc/periodic/daily/440.status-mailq 94342 2002-04-10 03:58:40Z gshapiro $ 428263Spst# 528263Spst 661981Sbrian# If there is a global system configuration file, suck it in. 761981Sbrian# 861981Sbrianif [ -r /etc/defaults/periodic.conf ] 961981Sbrianthen 1061981Sbrian . /etc/defaults/periodic.conf 1161981Sbrian source_periodic_confs 1261981Sbrianfi 1332615Swosch 1461981Sbriancase "$daily_status_mailq_enable" in 1561981Sbrian [Yy][Ee][Ss]) 1665843Sbrian if [ ! -x /usr/bin/mailq ] 1761981Sbrian then 1865843Sbrian echo '$daily_status_mailq_enable is set but /usr/bin/mailq' \ 1965843Sbrian "isn't executable" 2065843Sbrian rc=2 2165843Sbrian else 2261981Sbrian echo "" 2361981Sbrian echo "Mail in local queue:" 2461981Sbrian 2565843Sbrian rc=$(case "$daily_status_mailq_shorten" in 2661981Sbrian [Yy][Ee][Ss]) 2765843Sbrian rc=$(mailq | 2861981Sbrian perl -ne 'print if /^\s+\S+@/' | 2961981Sbrian sort | 3061981Sbrian uniq -c | 3161981Sbrian sort -nr | 3265843Sbrian awk '$1 > 1 {print $1, $2}');; 3361981Sbrian *) 3461981Sbrian mailq;; 3565843Sbrian esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l) 3665843Sbrian [ $rc -gt 1 ] && rc=1 3794342Sgshapiro 3894342Sgshapiro case "$daily_status_include_submit_mailq" in 3994342Sgshapiro [Yy][Ee][Ss]) 4094342Sgshapiro if [ -f /etc/mail/submit.cf ] 4194342Sgshapiro then 4294342Sgshapiro echo "" 4394342Sgshapiro echo "Mail in submit queue:" 4494342Sgshapiro 4594342Sgshapiro rc=$(case "$daily_status_mailq_shorten" in 4694342Sgshapiro [Yy][Ee][Ss]) 4794342Sgshapiro rc=$(mailq -Ac | 4894342Sgshapiro perl -ne 'print if /^\s+\S+@/' | 4994342Sgshapiro sort | 5094342Sgshapiro uniq -c | 5194342Sgshapiro sort -nr | 5294342Sgshapiro awk '$1 > 1 {print $1, $2}');; 5394342Sgshapiro *) 5494342Sgshapiro mailq -Ac;; 5594342Sgshapiro esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l) 5694342Sgshapiro [ $rc -gt 1 ] && rc=1 5794342Sgshapiro fi;; 5894342Sgshapiro esac 5961981Sbrian fi;; 6094342Sgshapiro 6165843Sbrian *) rc=0;; 6261981Sbrianesac 6365843Sbrian 6465843Sbrianexit $rc 65