diff options
author | brian <brian@FreeBSD.org> | 2000-09-14 17:19:15 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-09-14 17:19:15 +0000 |
commit | 4484d23ba731b5a116bedf7b28421514aa70f53b (patch) | |
tree | c37ec10ec51a7430c5a8044972107e92a18f16b0 /etc/periodic/daily | |
parent | d63a19c1e21807290eba99997d2935286893fede (diff) | |
download | FreeBSD-src-4484d23ba731b5a116bedf7b28421514aa70f53b.zip FreeBSD-src-4484d23ba731b5a116bedf7b28421514aa70f53b.tar.gz |
Another overhaul of the periodic stuff.
All periodic sub-scripts <larf> now have their return codes interpreted
by periodic(8). Output may be masked based on variable values in
periodic.conf.
It's also now possible to email periodic output to arbitrary addresses,
or to send it to a log file, examples of which can be found in
newsyslog.conf.
The upshot of it all should be no discernable changes to the default
behaviour of periodic(8).
PR: 21250
Diffstat (limited to 'etc/periodic/daily')
22 files changed, 361 insertions, 118 deletions
diff --git a/etc/periodic/daily/100.clean-disks b/etc/periodic/daily/100.clean-disks index 6f95a69..e225237 100755 --- a/etc/periodic/daily/100.clean-disks +++ b/etc/periodic/daily/100.clean-disks @@ -15,8 +15,18 @@ fi case "$daily_clean_disks_enable" in [Yy][Ee][Ss]) - if [ -n "$daily_clean_disks_days" -a -n "$daily_clean_disks_files" ] + if [ -z "$daily_clean_disks_days" ] then + echo '$daily_clean_disks_enable is set but' \ + '$daily_clean_disks_days is not' + rc=2 + elif [ -z "$daily_clean_disks_files" ] + then + echo '$daily_clean_disks_enable is set but' \ + '$daily_clean_disks_files is not' + are misconfigured + rc=2 + else echo "" echo "Removing old temporary files:" set -f noglob @@ -30,8 +40,15 @@ case "$daily_clean_disks_enable" in print=;; esac - find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \ - \( $args \) -atime +$daily_clean_disks_days -delete $print + rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \ + \( $args \) -atime +$daily_clean_disks_days -delete $print | + tee /dev/stderr | wc -l) + [ -z "$print" ] && rc=0 + [ $rc -gt 1 ] && rc=1 set -f glob fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/110.clean-tmps b/etc/periodic/daily/110.clean-tmps index 0ae223b..b6a4795 100755 --- a/etc/periodic/daily/110.clean-tmps +++ b/etc/periodic/daily/110.clean-tmps @@ -16,8 +16,12 @@ fi case "$daily_clean_tmps_enable" in [Yy][Ee][Ss]) - if [ -n "$daily_clean_tmps_days" ] + if [ -z "$daily_clean_tmps_days" ] then + echo '$daily_clean_tmps_enable is set but' \ + '$daily_clean_tmps_days is not' + rc=2 + else echo "" echo "Removing old temporary files:" @@ -33,14 +37,20 @@ case "$daily_clean_tmps_enable" in print=;; esac - for dir in $daily_clean_tmps_dirs - do - [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { - find -d . -type f $args -delete $print - find -d . ! -name . -type d -mtime +$daily_clean_tmps_days \ - -delete $print - } | sed "s,^\\., $dir," - done + rc=$(for dir in $daily_clean_tmps_dirs + do + [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { + find -d . -type f $args -delete $print + find -d . ! -name . -type d -mtime \ + +$daily_clean_tmps_days -delete $print + } | sed "s,^\\., $dir," + done | tee /dev/stderr | wc -l) + [ -z "$print" ] && rc=0 + [ $rc -gt 1 ] && rc=1 set -f glob fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/120.clean-preserve b/etc/periodic/daily/120.clean-preserve index 2230a03..d5b34a1 100755 --- a/etc/periodic/daily/120.clean-preserve +++ b/etc/periodic/daily/120.clean-preserve @@ -15,20 +15,39 @@ fi case "$daily_clean_preserve_enable" in [Yy][Ee][Ss]) - if [ -n "$daily_clean_preserve_days" -a -d /var/preserve ] + if [ -z "$daily_clean_preserve_days" ] then + echo '$daily_clean_preserve_enable is set but' \ + '$daily_clean_preserve_days is not' + rc=2 + elif [ ! -d /var/preserve ] + then + echo '$daily_clean_preserve_enable is set but /var/preserve' \ + "doesn't exist" + rc=2 + else echo "" echo "Removing stale files from /var/preserve:" - case "$daily_clean_preserve_verbose" in - [Yy][Ee][Ss]) - print=-print;; - *) - print=;; - esac + if cd /var/preserve + then + case "$daily_clean_preserve_verbose" in + [Yy][Ee][Ss]) + print=-print;; + *) + print=;; + esac - cd /var/preserve && - find . ! -name . -mtime +$daily_clean_preserve_days \ - -delete $print + rc=$(find . ! -name . -mtime +$daily_clean_preserve_days \ + -delete $print | tee /dev/stderr | wc -l) + [ -z "$print" ] && rc=0 + [ $rc -gt 1 ] && rc=1 + else + rc=3 + fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/130.clean-msgs b/etc/periodic/daily/130.clean-msgs index c12cba9..b7890db 100755 --- a/etc/periodic/daily/130.clean-msgs +++ b/etc/periodic/daily/130.clean-msgs @@ -15,13 +15,21 @@ fi case "$daily_clean_msgs_enable" in [Yy][Ee][Ss]) - if [ -d /var/msgs ] + if [ ! -d /var/msgs ] then + echo '$daily_clean_msgs_enable is set but /var/msgs' \ + "doesn't exist" + rc=2 + else echo "" echo "Cleaning out old system announcements:" [ -n "$daily_clean_msgs_days" ] && arg=-${daily_clean_msgs_days#-} || arg= - msgs -c $arg + msgs -c $arg && rc=0 || rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/140.clean-rwho b/etc/periodic/daily/140.clean-rwho index 9504f81..9645d7e 100755 --- a/etc/periodic/daily/140.clean-rwho +++ b/etc/periodic/daily/140.clean-rwho @@ -15,8 +15,17 @@ fi case "$daily_clean_rwho_enable" in [Yy][Ee][Ss]) - if [ -n "$daily_clean_rwho_days" -a -d /var/rwho ] + if [ -z "$daily_clean_rwho_days" ] then + echo '$daily_clean_rwho_enable is enabled but' \ + '$daily_clean_rwho_days is not set' + rc=2 + elif [ ! -d /var/rwho ] + then + echo '$daily_clean_rwho_enable is enabled but /var/rwho' \ + "doesn't exist" + rc=2 + else echo "" echo "Removing stale files from /var/rwho:" @@ -27,7 +36,18 @@ case "$daily_clean_rwho_enable" in print=;; esac - cd /var/rwho && - find . ! -name . -mtime +$daily_clean_rwho_days -delete $print + if cd /var/rwho + then + rc=$(find . ! -name . -mtime +$daily_clean_rwho_days \ + -delete $print | tee /dev/stderr | wc -l) + [ -z "$print" ] && rc=0 + [ $rc -gt 1 ] && rc=1 + else + rc=3 + fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/150.clean-hoststat b/etc/periodic/daily/150.clean-hoststat index 85c1e67..952d96a 100755 --- a/etc/periodic/daily/150.clean-hoststat +++ b/etc/periodic/daily/150.clean-hoststat @@ -15,8 +15,17 @@ fi case "$daily_clean_hoststat_enable" in [Yy][Ee][Ss]) - if [ -n "$daily_clean_hoststat_days" -a -d /var/spool/.hoststat ] + if [ -z "$daily_clean_hoststat_days" ] then + echo '$daily_clean_hoststat_enable is enabled but' \ + '$daily_clean_hoststat_days is not set' + rc=2 + elif [ ! -d /var/spool/.hoststat ] + then + echo '$daily_clean_hoststat_enable is enabled but' \ + "/var/spool/.hoststat doesn't exist" + rc=2 + else echo "" echo "Removing stale files from /var/spool/.hoststat:" @@ -27,8 +36,18 @@ case "$daily_clean_hoststat_enable" in print=;; esac - cd /var/hoststat && - find . ! -name . -mtime +$daily_clean_hoststat_days \ - -delete $print + if cd /var/hoststat + then + rc=$(find . ! -name . -mtime +$daily_clean_hoststat_days \ + -delete $print | tee /dev/stderr | wc -l) + [ -z "$print" ] && rc=0 + [ $rc -gt 1 ] && rc=1 + else + rc=3 + fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/200.backup-passwd b/etc/periodic/daily/200.backup-passwd index b8858e7..865a197 100755 --- a/etc/periodic/daily/200.backup-passwd +++ b/etc/periodic/daily/200.backup-passwd @@ -13,47 +13,65 @@ fi case "$daily_backup_passwd_enable" in [Yy][Ee][Ss]) - if [ -f /etc/master.passwd -o -f /etc/group ] + if [ ! -f /etc/master.passwd ] then + echo '$daily_backup_passwd_enable" is set but /etc/master.passwd' \ + "doesn't exist" + rc=2 + elif [ ! -f /etc/group ] + then + echo '$daily_backup_passwd_enable" is set but /etc/group' \ + "doesn't exist" + rc=2 + else bak=/var/backups + rc=0 echo "" echo "Backup passwd and group files:" if [ ! -f $bak/master.passwd.bak ] then + rc=1 echo "no $bak/master.passwd.bak" - cp -p /etc/master.passwd $bak/master.passwd.bak + cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 fi if ! cmp -s $bak/master.passwd.bak /etc/master.passwd then + [ $rc -lt 1 ] && rc=1 echo "$host passwd diffs:" diff $bak/master.passwd.bak /etc/master.passwd |\ sed 's/^\([<>] [^:]*\):[^:]*:/\1:(password):/' mv $bak/master.passwd.bak $bak/master.passwd.bak2 - cp -p /etc/master.passwd $bak/master.passwd.bak + cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 fi if [ ! -f $bak/group.bak ] then + [ $rc -lt 1 ] && rc=1 echo "no $bak/group.bak" - cp -p /etc/group $bak/group.bak + cp -p /etc/group $bak/group.bak || rc=3 fi if ! cmp -s $bak/group.bak /etc/group then + [ $rc -lt 1 ] && rc=1 echo "$host group diffs:" diff $bak/group.bak /etc/group mv $bak/group.bak $bak/group.bak2 - cp -p /etc/group $bak/group.bak + cp -p /etc/group $bak/group.bak || rc=3 fi if [ -f /etc/group ] then echo "" echo "Verifying group file syntax:" - chkgrp /etc/group + chkgrp /etc/group || rc=3 fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/210.backup-aliases b/etc/periodic/daily/210.backup-aliases index 0b5206e..fe17038 100755 --- a/etc/periodic/daily/210.backup-aliases +++ b/etc/periodic/daily/210.backup-aliases @@ -13,9 +13,14 @@ fi case "$daily_backup_aliases_enable" in [Yy][Ee][Ss]) - if [ -f /etc/mail/aliases ] + if [ ! -f /etc/mail/aliases ] then + echo '$daily_backup_aliases_enable is enabled but' \ + "/etc/mail/aliases doesn't exist" + rc=2 + else bak=/var/backups + rc=0 echo "" echo "Backing up mail aliases:" @@ -23,15 +28,20 @@ case "$daily_backup_aliases_enable" in if [ ! -f $bak/aliases.bak ] then echo "no $bak/aliases.bak" - cp -p /etc/mail/aliases $bak/aliases.bak + cp -p /etc/mail/aliases $bak/aliases.bak || rc=3 fi if ! cmp -s $bak/aliases.bak /etc/mail/aliases then + [ $rc -lt 1 ] && rc=1 echo "$host aliases diffs:" diff -u $bak/aliases.bak /etc/mail/aliases mv $bak/aliases.bak $bak/aliases.bak2 - cp -p /etc/mail/aliases $bak/aliases.bak + cp -p /etc/mail/aliases $bak/aliases.bak || rc=3 fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/220.backup-distfile b/etc/periodic/daily/220.backup-distfile index 37efaea..93d7660 100755 --- a/etc/periodic/daily/220.backup-distfile +++ b/etc/periodic/daily/220.backup-distfile @@ -13,17 +13,27 @@ fi case "$daily_backup_distfile_enable" in [Yy][Ee][Ss]) - if [ -f /etc/Distfile ] + if [ ! -f /etc/Distfile ] then + echo '$daily_backup_distfile_enable is set but /etc/Distfile' \ + "doesn't exist" + rc=2 + else bak=/var/backups + rc=0 echo "" echo "Backing up /etc/Distfile:" if ! cmp -s $bak/Distfile.bak /etc/Distfile then + rc=1 mv $bak/Distfile.bak $bak/Distfile.bak2 - cp /etc/Distfile $bak/Distfile.bak + cp /etc/Distfile $bak/Distfile.bak || rc=3 fi fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/300.calendar b/etc/periodic/daily/300.calendar index a921bcf..cc12097 100755 --- a/etc/periodic/daily/300.calendar +++ b/etc/periodic/daily/300.calendar @@ -18,11 +18,12 @@ fi case "$daily_calendar_enable" in [Yy][Ee][Ss]) - if [ -f /usr/bin/calendar ] - then - echo "" - echo "Running calendar:" + echo "" + echo "Running calendar:" - calendar -a - fi;; + calendar -a && rc=0 || rc=3;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/310.accounting b/etc/periodic/daily/310.accounting index 2baf232..c510a94 100755 --- a/etc/periodic/daily/310.accounting +++ b/etc/periodic/daily/310.accounting @@ -13,26 +13,35 @@ fi case "$daily_accounting_enable" in [Yy][Ee][Ss]) - if [ -f /var/account/acct ] + if [ ! -f /var/account/acct ] then + echo '$daily_accounting_enable is set but /var/account/acct' \ + "doesn't exist" + rc=2 + else echo "" echo "Rotating accounting logs and gathering statistics:" cd /var/account + rc=0 - rm -f acct.3.gz acct.3 - [ -f acct.2.gz ] && mv -f acct.2.gz acct.3.gz - [ -f acct.2 ] && mv -f acct.2 acct.3 - [ -f acct.1.gz ] && mv -f acct.1.gz acct.2.gz - [ -f acct.1 ] && mv -f acct.1 acct.2 - [ -f acct.0.gz ] && mv -f acct.0.gz acct.1.gz - [ -f acct.0 ] && mv -f acct.0 acct.1 - cp -pf acct acct.0 - sa -s >/dev/null + rm -f acct.3.gz acct.3 || rc=3 + [ -f acct.2.gz ] && { mv -f acct.2.gz acct.3.gz || rc=3; } + [ -f acct.2 ] && { mv -f acct.2 acct.3 || rc=3; } + [ -f acct.1.gz ] && { mv -f acct.1.gz acct.2.gz || rc=3; } + [ -f acct.1 ] && { mv -f acct.1 acct.2 || rc=3; } + [ -f acct.0.gz ] && { mv -f acct.0.gz acct.1.gz || rc=3; } + [ -f acct.0 ] && { mv -f acct.0 acct.1 || rc=3; } + cp -pf acct acct.0 || rc=3 + sa -s >/dev/null || rc=3 case "$daily_accounting_compress" in [Yy][Ee][Ss]) - gzip -f acct.0;; + gzip -f acct.0 || rc=3;; esac fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/320.rdist b/etc/periodic/daily/320.rdist index 0095ae6..11ec190 100755 --- a/etc/periodic/daily/320.rdist +++ b/etc/periodic/daily/320.rdist @@ -13,11 +13,19 @@ fi case "$daily_distfile_enable" in [Yy][Ee][Ss]) - if [ -f /etc/Distfile ] + if [ ! -f /etc/Distfile ] then + echo '$daily_distfile_enable is set but /etc/Distfile' \ + "doesn't exist" + rc=2 + else echo "" echo "Running rdist with /etc/Distfile:" - rdist -f /etc/Distfile + rdist -f /etc/Distfile && rc=0 || rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/330.news b/etc/periodic/daily/330.news index dc3a3bf..ec06437 100755 --- a/etc/periodic/daily/330.news +++ b/etc/periodic/daily/330.news @@ -16,11 +16,19 @@ fi case "$daily_news_expire_enable" in [Yy][Ee][Ss]) - if [ -f /etc/news.expire ] + if [ ! -f /etc/news.expire ] then + echo '$daily_news_expire_enable is set but /etc/news.expire' \ + "doesn't exist" + rc=2 + else echo "" echo "Running news.expire:" - /etc/news.expire + /etc/news.expire && rc=0 || rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/340.uucp b/etc/periodic/daily/340.uucp index 178fa63..120c874 100755 --- a/etc/periodic/daily/340.uucp +++ b/etc/periodic/daily/340.uucp @@ -16,11 +16,24 @@ fi case "$daily_uuclean_enable" in [Yy][Ee][Ss]) - if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ] + if [ ! -d /var/spool/uucp ] then + echo '$daily_uuclean_enable is set, but /var/spool/uucp' \ + "doesn't exist" + rc=2 + elif [ ! -f /etc/uuclean.daily ] + then + echo '$daily_uuclean_enable is set, but /etc/uuclean.daily' \ + "doesn't exist" + rc=2 + else echo "" echo "Cleaning up UUCP:" - echo /etc/uuclean.daily | su -m uucp + echo /etc/uuclean.daily | su -m uucp && rc=0 || rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/400.status-disks b/etc/periodic/daily/400.status-disks index f6147b1..6d6ebac 100755 --- a/etc/periodic/daily/400.status-disks +++ b/etc/periodic/daily/400.status-disks @@ -16,10 +16,14 @@ case "$daily_status_disks_enable" in echo "" echo "Disk status:" - df $daily_status_disks_df_flags + df $daily_status_disks_df_flags && rc=0 || rc=3 # display which filesystems need backing up echo "" - dump W;; + dump W || rc=3;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/410.status-uucp b/etc/periodic/daily/410.status-uucp index 5336477..96b52ec 100755 --- a/etc/periodic/daily/410.status-uucp +++ b/etc/periodic/daily/410.status-uucp @@ -13,11 +13,24 @@ fi case "$daily_status_uucp_enable" in [Yy][Ee][Ss]) - if [ -d /var/spool/uucp -a -x /usr/bin/uustat ] + if [ ! -d /var/spool/uucp ] then + echo '$daily_status_uucp_enable is set but /var/spool/uucp' \ + "doesn't exist" + rc=2 + elif [ ! -x /usr/bin/uustat ] + then + echo '$daily_status_uucp_enable is set but /usr/bin/uustat' \ + "isn't executable" + rc=2 + else echo "" echo "UUCP status:" - uustat -a + uustat -a && rc=0 || rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/420.status-network b/etc/periodic/daily/420.status-network index 6805361..8399cf7 100755 --- a/etc/periodic/daily/420.status-network +++ b/etc/periodic/daily/420.status-network @@ -13,16 +13,17 @@ fi case "$daily_status_network_enable" in [Yy][Ee][Ss]) - if [ -x /usr/bin/netstat ] - then - echo "" - echo "Network interface status:" + echo "" + echo "Network interface status:" - case "$daily_status_network_usedns" in - [Yy][Ee][Ss]) - netstat -i;; - *) - netstat -in;; - esac - fi;; + case "$daily_status_network_usedns" in + [Yy][Ee][Ss]) + netstat -i && rc=0 || rc=3;; + *) + netstat -in && rc=0 || rc=3;; + esac;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/430.status-rwho b/etc/periodic/daily/430.status-rwho index 728f4b2..4476136 100755 --- a/etc/periodic/daily/430.status-rwho +++ b/etc/periodic/daily/430.status-rwho @@ -14,14 +14,25 @@ fi case "$daily_status_rwho_enable" in [Yy][Ee][Ss]) rwho=$(echo /var/rwho/*) - if [ -x /usr/bin/rwho -a -f "${rwho%% *}" ] + if [ -f "${rwho%% *}" ] then echo "" echo "Local network system status:" - ruptime + prog=ruptime else echo "" echo "Local system status:" - uptime + prog=uptime + fi + rc=$($prog | tee /dev/stderr | wc -l) + if [ $? -eq 0 ] + then + [ $rc -gt 1 ] && rc=1 + else + rc=3 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/440.status-mailq b/etc/periodic/daily/440.status-mailq index fd2a443..17bc710 100755 --- a/etc/periodic/daily/440.status-mailq +++ b/etc/periodic/daily/440.status-mailq @@ -13,21 +13,35 @@ fi case "$daily_status_mailq_enable" in [Yy][Ee][Ss]) - if [ -x /usr/bin/mailq -a -d /var/spool/mqueue ] + if [ ! -x /usr/bin/mailq ] then + echo '$daily_status_mailq_enable is set but /usr/bin/mailq' \ + "isn't executable" + rc=2 + elif [ ! -d /var/spool/mqueue ] + then + echo '$daily_status_mailq_enable is set but /var/spool/mqueue' \ + "doesn't exist" + rc=2 + else echo "" echo "Mail in local queue:" - case "$daily_status_mailq_shorten" in + rc=$(case "$daily_status_mailq_shorten" in [Yy][Ee][Ss]) - mailq | + rc=$(mailq | perl -ne 'print if /^\s+\S+@/' | sort | uniq -c | sort -nr | - awk '$1 > 1 {print $1, $2}';; + awk '$1 > 1 {print $1, $2}');; *) mailq;; - esac + esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l) + [ $rc -gt 1 ] && rc=1 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/450.status-security b/etc/periodic/daily/450.status-security index 8ca962d..61fcf8b 100755 --- a/etc/periodic/daily/450.status-security +++ b/etc/periodic/daily/450.status-security @@ -13,30 +13,33 @@ fi case "$daily_status_security_enable" in [Yy][Ee][Ss]) - if [ -f /etc/security -a -x /usr/sbin/sendmail ] - then - echo "" - echo "Security check:" - - case "$daily_status_security_noamd" in - [Yy][Ee][Ss]) - args=-a;; - *) - args=;; - esac - - case "$daily_status_security_nomfs" in - [Yy][Ee][Ss]) - args="$args -m";; - esac - - case "$daily_status_security_inline" in - [Yy][Ee][Ss]) - sh /etc/security -s $args;; - - *) + echo "" + echo "Security check:" + + case "$daily_status_security_noamd" in + [Yy][Ee][Ss]) + args=-a;; + *) + args=;; + esac + + case "$daily_status_security_nomfs" in + [Yy][Ee][Ss]) + args="$args -m";; + esac + + case "$daily_status_security_inline" in + [Yy][Ee][Ss]) + sh /etc/security -s $args + rc=$?;; + + *) echo " (output mailed separately)" - sh /etc/security $args 2>&1 | sendmail root;; - esac - fi;; + sh /etc/security $args 2>&1 | + sendmail root && rc=0 || rc=3;; + esac;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/460.status-mail-rejects b/etc/periodic/daily/460.status-mail-rejects index 7d6ef1a..22eae94 100755 --- a/etc/periodic/daily/460.status-mail-rejects +++ b/etc/periodic/daily/460.status-mail-rejects @@ -13,15 +13,28 @@ fi case "$daily_status_mail_rejects_enable" in [Yy][Ee][Ss]) - if [ -d /etc/mail -a -f /var/log/maillog -a \ - "$daily_status_mail_rejects_logs" -gt 0 ] + if [ ! -d /etc/mail ] then + echo '$daily_status_mail_rejects_enable is set but /etc/mail' \ + "doesn't exist" + rc=2 + elif [ ! -f /var/log/maillog ] + then + echo '$daily_status_mail_rejects_enable is set but ' \ + "/var/log/maillog doesn't exist" + rc=2 + elif [ "$daily_status_mail_rejects_logs" -le 0 ] + then + echo '$daily_status_mail_rejects_enable is set but ' \ + '$daily_status_mail_rejects_logs is not greater than zero' + rc=2 + else echo echo Checking for rejected mail hosts: start=`date -v-1d '+%b %d' | sed 's/0\(.\)$/ \1/'` n=$(($daily_status_mail_rejects_logs - 2)) - { + rc=$({ while [ $n -ge 0 ] do if [ -f /var/log/maillog.$n ] @@ -37,6 +50,11 @@ case "$daily_status_mail_rejects_enable" in } | perl -ne "print \"\$2\n\" if (/reject=/ and /^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);" | - sort | uniq -c | sort -nr + sort | uniq -c | sort -nr | tee /dev/stderr | wc -l) + [ $rc -gt 0 ] && rc=1 fi;; + + *) rc=0;; esac + +exit $rc diff --git a/etc/periodic/daily/999.local b/etc/periodic/daily/999.local index 307ff19..099f293 100755 --- a/etc/periodic/daily/999.local +++ b/etc/periodic/daily/999.local @@ -14,6 +14,7 @@ then source_periodic_confs fi +rc=0 for script in $daily_local do case "$script" in @@ -23,7 +24,15 @@ do echo "" echo "Running $script:" - sh $script + sh $script || rc=3 + else + echo "$script: No such file" + [ $rc -lt 2 ] && rc=2 fi;; + *) + echo "$script: Not an absolute path" + [ $rc -lt 2 ] && rc=2;; esac done + +exit $rc |