137396Sbostic#!/bin/sh - 237396Sbostic# 3*65891Sbostic# @(#)daily 8.2 (Berkeley) 01/25/94 437396Sbostic# 551804SkarelsPATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin 652151Sbostichost=`hostname` 737396Sbosticecho "Subject: $host daily run output" 837396Sbosticbak=/var/backups 937396Sbostic 1037396Sbosticecho "" 1137396Sbosticecho "Removing scratch and junk files:" 1237396Sbosticif [ -d /tmp ]; then 1340243Skarels cd /tmp && { 1449870Sbostic find . -type f -atime +3 -exec rm -f -- {} \; 1549870Sbostic find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 1649870Sbostic >/dev/null 2>&1; } 1737396Sbosticfi 1837396Sbostic 1951804Skarelsif [ -d /var/tmp -a "X$CLEANVARTMP" = X1 ]; then 2040243Skarels cd /var/tmp && { 2149870Sbostic find . ! -name . -atime +7 -exec rm -f -- {} \; 2249870Sbostic find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 2349870Sbostic >/dev/null 2>&1; } 2440243Skarelsfi 2537396Sbostic 2637396Sbosticif [ -d /scratch ]; then 2740243Skarels cd /scratch && { 2849870Sbostic find . ! -name . -atime +1 -exec rm -f -- {} \; 2949870Sbostic find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 3049870Sbostic >/dev/null 2>&1; } 3137396Sbosticfi 3237396Sbostic 3337396Sbosticif [ -d /var/preserve ]; then 3440243Skarels cd /var/preserve && { 3549870Sbostic find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 3637396Sbosticfi 3737396Sbostic 3838566Sbosticif [ -d /var/rwho ] ; then 3940243Skarels cd /var/rwho && { 4049870Sbostic find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 4137396Sbosticfi 4237396Sbostic 4340243Skarelscd /tmp 4451125SbosticTMP=daily.$$ 4551125Sbosticfind / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \ 4663113Sbostic -name 'lost+found' -a -prune -o \ 47*65891Sbostic -name '*.core' -a -print -o \ 4851125Sbostic \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 4937396Sbostic -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 5051125Sbostic -a -atime +3 -a -exec rm -f -- {} \; -a -print > $TMP 5151125Sbosticecho "" 5255555Sbosticecho "Possible core dumps:" 53*65891Sbosticegrep '\.core' $TMP 5451125Sbostic 5551125Sbosticecho "" 5651125Sbosticecho "Deleted files:" 57*65891Sbosticegrep -v '\.core' $TMP 5851125Sbostic 5951125Sbosticrm -f $TMP 6051125Sbostic 6137396Sbosticmsgs -c 6240243Skarelsif [ -f /etc/news.expire ]; then 6340243Skarels /etc/news.expire 6437396Sbosticfi 6537396Sbostic 6637396Sbosticecho "" 6737396Sbosticecho "Purging accounting records:" 6840243Skarelsmv /var/account/acct.2 /var/account/acct.3 6940243Skarelsmv /var/account/acct.1 /var/account/acct.2 7040243Skarelsmv /var/account/acct.0 /var/account/acct.1 7140243Skarelscp /var/account/acct /var/account/acct.0 7237396Sbosticsa -s > /dev/null 7337396Sbostic 7451804Skarels# If ROOTBACKUP is set to 1 in the environment, and 7551804Skarels# if filesystem named /altroot is type ufs, on /dev/* and mounted "xx", 7651125Sbostic# use it as a backup root filesystem to be updated daily. 7751804Skarels[ "X$ROOTBACKUP" = X1 ] && { 7851125Sbostic rootdev=`awk '$2 == "/" && $1 ~ /^\/dev\// && $3 == "ufs" && \ 7951125Sbostic $4 == "rw" \ 8051125Sbostic { print substr($1, 6) }' < /etc/fstab` 8151125Sbostic rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ufs" && \ 8251125Sbostic $4 == "xx" \ 8351125Sbostic { print substr($1, 6) }' < /etc/fstab` 8451125Sbostic [ X$rootdev != X -a X$rootbak != X ] && { 8551125Sbostic sync 8651804Skarels echo "" 8751804Skarels echo "Backing up root filesystem:" 8851125Sbostic echo "copying /dev/r$rootdev to /dev/r$rootbak" 8951125Sbostic dd if=/dev/r$rootdev of=/dev/r$rootbak bs=16b seek=1 skip=1 \ 9051125Sbostic conv=noerror,sync 9151125Sbostic fsck -y /dev/r$rootbak 9251125Sbostic } 9351125Sbostic} 9451125Sbostic 9537396Sbosticecho "" 9637396Sbosticecho "Running calendar:" 9740243Skarelscalendar -a 9837396Sbostic 9937396Sbosticecho "" 10038566Sbosticecho "Rotating mail log:" 10138484Sbosticcd /var/log 10238566Sbosticrm -f maillog.7 10338566Sbosticif [ -f maillog.6 ]; then mv -f maillog.6 maillog.7; fi 10438566Sbosticif [ -f maillog.5 ]; then mv -f maillog.5 maillog.6; fi 10538566Sbosticif [ -f maillog.4 ]; then mv -f maillog.4 maillog.5; fi 10638566Sbosticif [ -f maillog.3 ]; then mv -f maillog.3 maillog.4; fi 10738566Sbosticif [ -f maillog.2 ]; then mv -f maillog.2 maillog.3; fi 10838566Sbosticif [ -f maillog.1 ]; then mv -f maillog.1 maillog.2; fi 10938566Sbosticif [ -f maillog.0 ]; then mv -f maillog.0 maillog.1; fi 11038566Sbosticmv -f maillog maillog.0 11138566Sbosticcp /dev/null maillog 11238566Sbosticchmod 644 maillog 11337435Sbostickill -1 `cat /var/run/syslog.pid` 11437396Sbosticcd / 11537396Sbostic 11640243Skarelsif [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then 11737396Sbostic echo "" 11837396Sbostic echo "Cleaning up UUCP:" 11940243Skarels echo /etc/uuclean.daily | su daemon 12037396Sbosticfi 12137396Sbostic 12237396Sbosticecho "" 12337396Sbosticecho "" 12437396Sbosticecho "Checking subsystem status:" 12537396Sbosticecho "" 12637396Sbosticecho "disks:" 12756119Sbosticenv BLOCKSIZE=1k df 12837396Sbosticecho "" 12937396Sbosticdump W 13037396Sbosticecho "" 13137396Sbostic 13237396Sbostic 13337396Sbosticecho "" 13437396Sbosticecho "mail:" 13537396Sbosticmailq 13637396Sbostic 13737396Sbosticif [ -d /var/spool/uucp ]; then 13837396Sbostic echo "" 13937396Sbostic echo "uucp:" 14037396Sbostic uusnap 14137396Sbosticfi 14237396Sbostic 14337396Sbosticecho "" 14437396Sbosticecho "network:" 14537396Sbosticnetstat -i 14637396Sbosticecho "" 14737396Sbosticruptime 14837396Sbostic 14937396Sbosticecho "" 15038566Sbosticecho "Checking filesystems:" 15138566Sbosticfsck -n | grep -v '^\*\* Phase' 15238566Sbostic 15338566Sbosticecho "" 15437396Sbosticif [ -f /etc/Distfile ]; then 15537396Sbostic echo "Running rdist:" 15651125Sbostic if [ -d /var/log/rdist ]; then 15751125Sbostic logf=`date | awk '{printf "%s.%s.%s", $6, $2, $3}'` 15851125Sbostic rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf 15951125Sbostic else 16051125Sbostic rdist -f /etc/Distfile 16151125Sbostic fi 16237396Sbosticfi 16344775Sbostic 16451899Skarelssh /etc/security 2>&1 | mail -s "$host daily insecurity output" root 165