daily revision 1.27
1#!/bin/sh - 2# 3# $NetBSD: daily,v 1.27 1998/07/16 05:21:56 mycroft Exp $ 4# @(#)daily 8.2 (Berkeley) 1/25/94 5# 6 7export PATH=/bin:/usr/bin:/sbin:/usr/sbin 8host=`hostname` 9echo "Subject: $host daily run output" 10 11umask 077 12 13if [ -f /etc/rc.subr ]; then 14 . /etc/rc.subr 15else 16 echo "Can't read /etc/rc.subr; aborting." 17 exit 1; 18fi 19 20if [ -z "$MAILTO" -o "$USER" != "root" ]; then 21 MAILTO=root 22fi 23 24if [ -s /etc/daily.conf ]; then 25 . /etc/daily.conf 26fi 27 28echo "" 29echo "Uptime: " `uptime` 30 31#echo "" 32#echo "Removing scratch and junk files:" 33#if [ -d /tmp -a ! -h /tmp ]; then 34# cd /tmp && { 35# find . -type f -atime +3 -exec rm -f -- {} \; 36# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 37# >/dev/null 2>&1; } 38#fi 39 40#if [ -d /var/tmp -a ! -h /var/tmp ]; then 41# cd /var/tmp && { 42# find . ! -name . -atime +7 -exec rm -f -- {} \; 43# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 44# >/dev/null 2>&1; } 45#fi 46 47# Additional junk directory cleanup would go like this: 48#if [ -d /scratch -a ! -h /scratch ]; then 49# cd /scratch && { 50# find . ! -name . -atime +1 -exec rm -f -- {} \; 51# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 52# >/dev/null 2>&1; } 53#fi 54 55#if [ -d /var/rwho -a ! -h /var/rwho ] ; then 56# cd /var/rwho && { 57# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 58#fi 59 60TMPDIR=/tmp/_daily.$$ 61 62if ! mkdir $TMPDIR; then 63 echo can not create $TMPDIR. 64 exit 1 65fi 66 67if ! cd $TMPDIR; then 68 echo can not cd to $TMPDIR. 69 exit 1 70fi 71 72TMP=daily.$$ 73TMP2=daily2.$$ 74 75if checkyesno find_core; then 76 find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ 77 -o -fstype kernfs -o -fstype procfs \) -a -prune -o \ 78 -name 'lost+found' -a -prune -o \ 79 \( -name '*.core' -o -name 'core' \) -a -print > $TMP 80# \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 81# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 82# -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP 83 84 egrep '\.core$|^core$' $TMP > $TMP2 85 if [ -s $TMP2 ]; then 86 echo "" 87 echo "Possible core dumps:" 88 cat $TMP2 89 fi 90 91# egrep -v '\.core' $TMP > $TMP2 92# if [ -s $TMP2 ]; then 93# echo "" 94# echo "Deleted files:" 95# cat $TMP2 96# fi 97 98 rm -f $TMP $TMP2 99fi 100 101if checkyesno run_msgs; then 102 msgs -c 103fi 104 105if checkyesno expire_news && [ -f /etc/news.expire ]; then 106 /etc/news.expire 107fi 108 109if checkyesno purge_accounting && [ -f /var/account/acct ]; then 110 echo "" 111 echo "Purging accounting records:" 112 mv /var/account/acct.2 /var/account/acct.3 113 mv /var/account/acct.1 /var/account/acct.2 114 mv /var/account/acct.0 /var/account/acct.1 115 cp /var/account/acct /var/account/acct.0 116 sa -sq 117fi 118 119if checkyesno run_calendar; then 120 calendar -a > $TMP 121 if [ -s $TMP ]; then 122 echo "" 123 echo "Running calendar:" 124 cat $TMP 125 fi 126 rm -f $TMP 127fi 128 129if checkyesno check_uucp && \ 130 [ -d /var/spool/uucp -a -f /usr/libexec/uucp/clean.daily ]; then 131 echo "" 132 echo "Cleaning up UUCP:" 133 su daemon -c /usr/libexec/uucp/clean.daily 134fi 135 136if checkyesno check_disks; then 137 df -k > $TMP 138 dump W > $TMP2 139 if [ -s $TMP -o -s $TMP2 ]; then 140 echo "" 141 echo "Checking subsystem status:" 142 echo "" 143 echo "disks:" 144 if [ -s $TMP ]; then 145 cat $TMP 146 echo "" 147 fi 148 if [ -s $TMP2 ]; then 149 cat $TMP2 150 echo "" 151 fi 152 echo "" 153 fi 154fi 155 156rm -f $TMP $TMP2 157 158if checkyesno check_mailq; then 159 mailq > $TMP 160 if ! grep -q "^Mail queue is empty$" $TMP; then 161 echo "" 162 echo "mail:" 163 cat $TMP 164 fi 165fi 166 167rm -f $TMP 168 169if checkyesno check_uucp && [ -d /var/spool/uucp ]; then 170 uustat -a > $TMP 171 if [ -s $TMP ]; then 172 echo "" 173 echo "uucp:" 174 cat $TMP 175 fi 176fi 177 178rm -f $TMP 179 180if checkyesno check_network; then 181 echo "" 182 echo "network:" 183 netstat -i 184 echo "" 185 t=/var/rwho/* 186 if [ "$t" != '/var/rwho/*' ]; then 187 ruptime 188 fi 189fi 190 191if checkyesno run_fsck; then 192 echo "" 193 echo "Checking filesystems:" 194 fsck -n | grep -v '^\*\* Phase' 195fi 196 197echo "" 198if checkyesno run_rdist && [ -f /etc/Distfile ]; then 199 echo "Running rdist:" 200 if [ -d /var/log/rdist ]; then 201 logf=`date +%Y.%b.%e` 202 rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf 203 else 204 rdist -f /etc/Distfile 205 fi 206fi 207 208if checkyesno run_security; then 209 sh /etc/security 2>&1 | mail -s "$host daily insecurity output" $MAILTO 210fi 211 212rm -rf $TMPDIR 213