date and time created 89/04/11 18:12:36 by bostic
[unix-history] / usr / src / etc / daily
#!/bin/sh -
#
# @(#)daily 5.1 (Berkeley) %G%
#
PATH=/usr/local:/usr/ucb:/bin:/usr/bin:/etc:/sbin:/usr/sbin
export PATH
host=`hostname -s`
echo "Subject: $host daily run output"
bak=/var/backups
echo ""
echo "Removing scratch and junk files:"
if [ -d /tmp ]; then
cd /tmp
find . ! -name . -atime +3 -exec rm -f {} \;
find . ! -name . -type d -mtime +1 -exec rmdir {} \; >/dev/null 2>&1
fi
#if [ -d /var/tmp ]; then
# cd /var/tmp
# find . ! -name . -atime +7 -exec rm -f {} \;
# find . ! -name . -type d -mtime +1 -exec rmdir {} \; >/dev/null 2>&1
#fi
if [ -d /scratch ]; then
cd /scratch
find . ! -name . -atime +1 -exec rm -f {} \;
find . ! -name . -type d -mtime +1 -exec rmdir {} \; >/dev/null 2>&1
fi
if [ -d /var/preserve ]; then
cd /var/preserve
find . ! -name . -mtime +7 -exec rm -f {} \;
fi
if [ -d /var/spool/rwho ] ; then
cd /var/spool/rwho
find . -mtime +7 -exec rm -f {} \;
fi
find / \( -name '[#,]*' -o -name '.#*' -o -name a.out -o -name core \
-o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
-a -atime +3 -exec rm -f {} \;
msgs -c
if [ -f /usr/new/lib/news/expire ]; then
/usr/new/lib/news/expire
fi
echo ""
echo "Purging accounting records:"
cp /var/account/acct /var/account/acct.yesterday
sa -s > /dev/null
echo ""
echo "Backup passwd and group files:"
if cmp $bak/master.passwd.bak /etc/master.passwd >/dev/null; then :; else
echo "$host passwd diffs:"
diff $bak/master.passwd.bak /etc/master.passwd
mv $bak/master.passwd.bak $bak/master.passwd.bak2
cp -p /etc/master.passwd $bak/master.passwd.bak
chmod 600 $bak/master.passwd.bak $bak/master.passwd.bak2
fi
if cmp $bak/group.bak /etc/group >/dev/null; then :; else
mv $bak/group.bak $bak/group.bak2
cp -p /etc/group $bak/group.bak
fi
if [ -f /etc/Distfile ]; then
if cmp $bak/Distfile.bak /etc/Distfile >/dev/null; then :; else
mv $bak/Distfile.bak $bak/Distfile.bak2
cp /etc/Distfile $bak/Distfile.bak
fi
fi
echo ""
echo "Running calendar:"
calendar -
echo ""
echo "Rotating mail syslog:"
cd /var/spool/mqueue
rm -f syslog.7
if [ -f syslog.6 ]; then mv -f syslog.6 syslog.7; fi
if [ -f syslog.5 ]; then mv -f syslog.5 syslog.6; fi
if [ -f syslog.4 ]; then mv -f syslog.4 syslog.5; fi
if [ -f syslog.3 ]; then mv -f syslog.3 syslog.4; fi
if [ -f syslog.2 ]; then mv -f syslog.2 syslog.3; fi
if [ -f syslog.1 ]; then mv -f syslog.1 syslog.2; fi
if [ -f syslog.0 ]; then mv -f syslog.0 syslog.1; fi
mv -f syslog syslog.0
cp /dev/null syslog
chmod 644 syslog
kill -1 `cat /etc/syslog.pid`
cd /
if [ -d /var/spool/uucp -a -f /usr/lib/uucp/clean.daily ]; then
echo ""
echo "Cleaning up UUCP:"
echo /usr/lib/uucp/clean.daily | su daemon
fi
echo ""
echo ""
echo "Checking subsystem status:"
echo ""
echo "disks:"
df
echo ""
dump W
echo ""
sync
fsck -n | grep -v '^\*\* Phase'
echo ""
echo "mail:"
mailq
if [ -d /var/spool/uucp ]; then
echo ""
echo "uucp:"
uusnap
fi
echo ""
echo "network:"
netstat -i
echo ""
ruptime
echo ""
echo "SECURITY CHECKS:"
echo ""
echo "checking setuid files in root filesystem:"
ncheck -s `awk -F: '$2=="/" {print $1}' /etc/fstab` | grep -v ' /dev/' \
> $bak/check.today
chmod 400 $bak/check.today
if [ -f $bak/check.yesterday ]
then
if diff $bak/check.today $bak/check.yesterday > /tmp/dif; then :; else
echo "*** New setuid files in root filesystem:"
cat /tmp/dif
mv $bak/check.today $bak/check.yesterday
fi
rm /tmp/dif
else
cat $bak/check.today
mv $bak/check.today $bak/check.yesterday
fi
echo ""
echo "checking for uids of 0:"
awk 'BEGIN {FS=":"} $3=="0" {print $1,$3}' /etc/master.passwd
echo ""
if [ -f /etc/Distfile ]; then
echo "Running rdist:"
rdist -f /etc/Distfile
fi