version 1.16, 1997/01/03 22:51:26 |
version 1.17, 1997/01/17 06:18:19 |
|
|
#!/bin/sh - |
#!/bin/sh - |
# |
# |
# $OpenBSD$ |
# $OpenBSD$ |
|
# From: @(#)daily 8.2 (Berkeley) 1/25/94 |
# |
# |
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local |
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin |
host=`hostname -s` |
host=`hostname -s` |
echo "Subject: $host daily run output" |
echo "Subject: $host daily run output" |
|
bak=/var/backups |
|
|
if [ -f /etc/daily.local ];then |
if [ -f /etc/daily.local ];then |
echo "" |
echo "" |
|
|
trap 'rm -f $TMP' 0 1 15 |
trap 'rm -f $TMP' 0 1 15 |
|
|
echo "" |
echo "" |
echo "NOT Removing scratch and junk files." |
echo "Removing scratch and junk files:" |
#echo "Removing scratch and junk files:" |
if [ -d /tmp -a ! -h /tmp ]; then |
# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED" |
cd /tmp && { |
#if [ -d /tmp -a ! -h /tmp ]; then |
find . -type f -atime +3 -execdir rm -f -- {} \; |
# cd /tmp && { |
find . ! -name . -type d -mtime +1 -execdir rmdir -- {} \; \ |
# find . -type f -atime +3 -exec rm -f -- {} \; |
>/dev/null 2>&1; } |
# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ |
fi |
# >/dev/null 2>&1; } |
|
#fi |
|
|
|
# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED |
if [ -d /var/tmp -a ! -h /var/tmp ]; then |
#if [ -d /var/tmp -a ! -h /var/tmp ]; then |
cd /var/tmp && { |
# cd /var/tmp && { |
find . ! -name . -atime +7 -execdir rm -f -- {} \; |
# find . ! -name . -atime +7 -exec rm -f -- {} \; |
find . ! -name . -type d -mtime +1 -execdir rmdir -- {} \; \ |
# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ |
>/dev/null 2>&1; } |
# >/dev/null 2>&1; } |
fi |
#fi |
|
|
|
# Additional junk directory cleanup would go like this: |
# Additional junk directory cleanup would go like this: |
#if [ -d /scratch -a ! -h /scratch ]; then |
#if [ -d /scratch -a ! -h /scratch ]; then |
# cd /scratch && { |
# cd /scratch && { |
# find . ! -name . -atime +1 -exec rm -f -- {} \; |
# find . ! -name . -atime +1 -execdir rm -f -- {} \; |
# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ |
# find . ! -name . -type d -mtime +1 -execdir rmdir -- {} \; \ |
# >/dev/null 2>&1; } |
# >/dev/null 2>&1; } |
#fi |
#fi |
|
|
#if [ -d /var/rwho -a ! -h /var/rwho ] ; then |
if [ -d /var/preserve -a ! -h /var/preserve ]; then |
# cd /var/rwho && { |
cd /var/preserve && { |
# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED |
find . ! -name . -mtime +7 -execdir rm -f -- {} \; ; } |
# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } |
fi |
#fi |
|
|
|
|
if [ -d /var/rwho -a ! -h /var/rwho ] ; then |
|
cd /var/rwho && { |
|
find . ! -name . -mtime +7 -execdir rm -f -- {} \; ; } |
|
fi |
|
|
find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ |
find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ |
-o -fstype kernfs -o -fstype procfs \) -a -prune -o \ |
-o -fstype kernfs -o -fstype procfs \) -a -prune -o \ |
-name 'lost+found' -a -prune -o \ |
-name 'lost+found' -a -prune -o \ |
-name '*.core' -a -print > $TMP |
-name '*.core' -a -print -o \ |
# \( -name '[#,]*' -o -name '.#*' -o -name a.out \ |
\( -name '[#,]*' -o -name '.#*' -o -name a.out \ |
# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ |
-o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ |
# -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP |
-a -atime +3 -a -execdir rm -f -- {} \; -a -print > $TMP |
|
|
if egrep -q '\.core$' $TMP; then |
if egrep -q '\.core$' $TMP; then |
echo "" |
echo "" |
echo "Possible core dumps:" |
echo "Possible core dumps:" |
egrep '\.core$' $TMP |
egrep '\.core$' $TMP |
|
fi |
|
|
# XXX - we aren't deleting files due to security bug mentioned above |
if egrep -qv '\.core$' $TMP; then |
#echo "" |
echo "" |
#echo "Deleted files:" |
echo "Deleted files:" |
#egrep -v '\.core$' $TMP |
egrep -v '\.core$' $TMP |
fi |
fi |
|
|
msgs -c |
msgs -c |
|
|
if [ -f /etc/news.expire ]; then |
if [ -s /etc/news.expire ]; then |
/etc/news.expire |
/etc/news.expire |
fi |
fi |
|
|
if [ -f /var/account/acct ]; then |
if [ -f /var/account/acct ]; then |
echo "" ; |
echo "" |
echo "Purging accounting records:" ; |
echo "Purging accounting records:" |
mv /var/account/acct.2 /var/account/acct.3 ; |
mv /var/account/acct.2 /var/account/acct.3 |
mv /var/account/acct.1 /var/account/acct.2 ; |
mv /var/account/acct.1 /var/account/acct.2 |
mv /var/account/acct.0 /var/account/acct.1 ; |
mv /var/account/acct.0 /var/account/acct.1 |
cp /var/account/acct /var/account/acct.0 ; |
cp /var/account/acct /var/account/acct.0 |
sa -sq ; |
sa -sq |
fi |
fi |
|
|
|
# If ROOTBACKUP is set to 1 in the environment, and |
|
# if filesystem named /altroot is type ffs, on /dev/* and mounted "xx", |
|
# use it as a backup root filesystem to be updated daily. |
|
[ "X$ROOTBACKUP" = X1 ] && { |
|
rootdev=`awk '$2 == "/" && $1 ~ /^\/dev\// && $3 == "ffs" && \ |
|
$4 == "rw" \ |
|
{ print substr($1, 6) }' < /etc/fstab` |
|
rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ffs" && \ |
|
$4 == "xx" \ |
|
{ print substr($1, 6) }' < /etc/fstab` |
|
[ X$rootdev != X -a X$rootbak != X ] && { |
|
sync |
|
echo "" |
|
echo "Backing up root filesystem:" |
|
echo "copying /dev/r$rootdev to /dev/r$rootbak" |
|
dd if=/dev/r$rootdev of=/dev/r$rootbak bs=16b seek=1 skip=1 \ |
|
conv=noerror,sync |
|
fsck -y /dev/r$rootbak |
|
} |
|
} |
|
|
echo "" |
echo "" |
if [ -d /var/yp/binding -a ! -d /var/yp/`domainname` ]; then |
if [ -d /var/yp/binding -a ! -d /var/yp/`domainname` ]; then |
echo "Not running calendar, (yp client)." |
echo "Not running calendar, (yp client)." |
else |
else |
echo "Running calendar." |
echo "Running calendar." |
|
|
|
|
t=/var/rwho/* |
t=/var/rwho/* |
if [ "$t" != '/var/rwho/*' ]; then |
if [ "$t" != '/var/rwho/*' ]; then |
|
echo "" |
ruptime |
ruptime |
fi |
fi |
|
|
echo "" |
# If CHECKFILESYSTEMS is set to 1 in the environment, run fsck |
echo "NOT checking filesystems." |
# with the no-write flag. |
#echo "Checking filesystems:" |
[ "X$CHECKFILESYSTEMS" = X1 ] && { |
#fsck -n | grep -v '^\*\* Phase' |
echo "" |
|
echo "Checking filesystems:" |
|
fsck -n | grep -v '^\*\* Phase' |
|
} |
|
|
echo "" |
|
if [ -f /etc/Distfile ]; then |
if [ -f /etc/Distfile ]; then |
|
echo "" |
echo "Running rdist:" |
echo "Running rdist:" |
rdist -f /etc/Distfile |
if [ -d /var/log/rdist ]; then |
|
logf=`date | awk '{printf "%s.%s.%s", $6, $2, $3}'` |
|
rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf |
|
else |
|
rdist -f /etc/Distfile |
|
fi |
fi |
fi |
|
|
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" root |
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" root |