daily revision 1.16
1#!/bin/sh - 2# 3# $OpenBSD: daily,v 1.16 1997/01/03 22:51:26 millert Exp $ 4# 5PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local 6host=`hostname -s` 7echo "Subject: $host daily run output" 8 9if [ -f /etc/daily.local ];then 10 echo "" 11 echo "Running daily.local:" 12 . /etc/daily.local 13fi 14 15TMP=`mktemp /tmp/_daily.XXXXXX` || exit 1 16 17trap 'rm -f $TMP' 0 1 15 18 19echo "" 20echo "NOT Removing scratch and junk files." 21#echo "Removing scratch and junk files:" 22# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED" 23#if [ -d /tmp -a ! -h /tmp ]; then 24# cd /tmp && { 25# find . -type f -atime +3 -exec rm -f -- {} \; 26# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 27# >/dev/null 2>&1; } 28#fi 29 30# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED 31#if [ -d /var/tmp -a ! -h /var/tmp ]; then 32# cd /var/tmp && { 33# find . ! -name . -atime +7 -exec rm -f -- {} \; 34# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 35# >/dev/null 2>&1; } 36#fi 37 38# Additional junk directory cleanup would go like this: 39#if [ -d /scratch -a ! -h /scratch ]; then 40# cd /scratch && { 41# find . ! -name . -atime +1 -exec rm -f -- {} \; 42# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 43# >/dev/null 2>&1; } 44#fi 45 46#if [ -d /var/rwho -a ! -h /var/rwho ] ; then 47# cd /var/rwho && { 48# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED 49# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 50#fi 51 52find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ 53 -o -fstype kernfs -o -fstype procfs \) -a -prune -o \ 54 -name 'lost+found' -a -prune -o \ 55 -name '*.core' -a -print > $TMP 56# \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 57# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 58# -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP 59 60if egrep -q '\.core$' $TMP; then 61 echo "" 62 echo "Possible core dumps:" 63 egrep '\.core$' $TMP 64 65 # XXX - we aren't deleting files due to security bug mentioned above 66 #echo "" 67 #echo "Deleted files:" 68 #egrep -v '\.core$' $TMP 69fi 70 71msgs -c 72 73if [ -f /etc/news.expire ]; then 74 /etc/news.expire 75fi 76 77if [ -f /var/account/acct ]; then 78 echo "" ; 79 echo "Purging accounting records:" ; 80 mv /var/account/acct.2 /var/account/acct.3 ; 81 mv /var/account/acct.1 /var/account/acct.2 ; 82 mv /var/account/acct.0 /var/account/acct.1 ; 83 cp /var/account/acct /var/account/acct.0 ; 84 sa -sq ; 85fi 86 87echo "" 88if [ -d /var/yp/binding -a ! -d /var/yp/`domainname` ]; then 89 echo "Not running calendar, (yp client)." 90else 91 echo "Running calendar." 92 calendar -a 93fi 94 95# Rotation of mail log now handled automatically by cron and 'newsyslog' 96 97if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then 98 echo "" 99 echo "Cleaning up UUCP:" 100 echo /etc/uuclean.daily | su daemon 101fi 102 103echo "" 104echo "Checking subsystem status:" 105echo "" 106echo "disks:" 107df -k 108echo "" 109dump W 110echo "" 111 112mailq > $TMP 113if ! grep -q "^Mail queue is empty$" $TMP; then 114 echo "" 115 echo "mail:" 116 cat $TMP 117fi 118 119if [ -d /var/spool/uucp ]; then 120 uustat -a > $TMP 121 if [ -s $TMP ]; then 122 echo "" 123 echo "uucp:" 124 cat $TMP 125 fi 126fi 127 128echo "" 129echo "network:" 130netstat -i 131echo "" 132 133t=/var/rwho/* 134if [ "$t" != '/var/rwho/*' ]; then 135 ruptime 136fi 137 138echo "" 139echo "NOT checking filesystems." 140#echo "Checking filesystems:" 141#fsck -n | grep -v '^\*\* Phase' 142 143echo "" 144if [ -f /etc/Distfile ]; then 145 echo "Running rdist:" 146 rdist -f /etc/Distfile 147fi 148 149sh /etc/security 2>&1 | mail -s "$host daily insecurity output" root 150