1993-03-21 12:45:37 +03:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1997-07-11 04:36:55 +04:00
|
|
|
# $NetBSD: daily,v 1.23 1997/07/11 00:36:55 phil Exp $
|
1997-05-30 09:18:59 +04:00
|
|
|
# @(#)daily 8.2 (Berkeley) 1/25/94
|
1993-03-21 12:45:37 +03:00
|
|
|
#
|
1997-01-05 14:21:09 +03:00
|
|
|
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
1997-02-15 13:02:07 +03:00
|
|
|
host=`hostname`
|
1993-03-21 12:45:37 +03:00
|
|
|
echo "Subject: $host daily run output"
|
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
umask 077
|
|
|
|
|
1997-07-11 04:36:55 +04:00
|
|
|
if [ -z "$MAILTO" -o "$USER" != "root" ]; then
|
|
|
|
MAILTO=root
|
|
|
|
fi
|
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
if [ -s /etc/daily.conf ]; then
|
|
|
|
. /etc/daily.conf
|
|
|
|
fi
|
|
|
|
|
1997-06-23 05:45:21 +04:00
|
|
|
echo ""
|
|
|
|
echo "Uptime: " `uptime`
|
|
|
|
|
1996-07-03 03:10:35 +04:00
|
|
|
#echo ""
|
|
|
|
#echo "Removing scratch and junk files:"
|
|
|
|
#if [ -d /tmp -a ! -h /tmp ]; then
|
|
|
|
# cd /tmp && {
|
|
|
|
# find . -type f -atime +3 -exec rm -f -- {} \;
|
|
|
|
# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
|
|
|
|
# >/dev/null 2>&1; }
|
|
|
|
#fi
|
|
|
|
|
|
|
|
#if [ -d /var/tmp -a ! -h /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
|
1994-02-19 10:54:08 +03:00
|
|
|
|
1996-03-25 12:23:15 +03:00
|
|
|
# Additional junk directory cleanup would go like this:
|
|
|
|
#if [ -d /scratch -a ! -h /scratch ]; then
|
|
|
|
# cd /scratch && {
|
|
|
|
# find . ! -name . -atime +1 -exec rm -f -- {} \;
|
|
|
|
# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
|
|
|
|
# >/dev/null 2>&1; }
|
|
|
|
#fi
|
1994-02-19 10:54:08 +03:00
|
|
|
|
1996-07-03 03:10:35 +04:00
|
|
|
#if [ -d /var/rwho -a ! -h /var/rwho ] ; then
|
|
|
|
# cd /var/rwho && {
|
|
|
|
# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
|
|
|
|
#fi
|
1994-02-19 10:54:08 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
TMPDIR=/tmp/_daily.$$
|
1994-02-19 10:54:08 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
if ! mkdir $TMPDIR; then
|
|
|
|
echo can not create $TMPDIR.
|
|
|
|
exit 1
|
|
|
|
fi
|
1994-02-19 10:54:08 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
if ! cd $TMPDIR; then
|
|
|
|
echo can not cd to $TMPDIR.
|
|
|
|
exit 1
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
TMP=daily.$$
|
|
|
|
TMP2=daily2.$$
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$find_core" != NO ] ; then
|
1997-01-05 14:21:09 +03:00
|
|
|
find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \
|
|
|
|
-o -fstype kernfs -o -fstype procfs \) -a -prune -o \
|
|
|
|
-name 'lost+found' -a -prune -o \
|
|
|
|
-name '*.core' -a -print > $TMP
|
|
|
|
# \( -name '[#,]*' -o -name '.#*' -o -name a.out \
|
|
|
|
# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
|
|
|
|
# -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP
|
|
|
|
|
|
|
|
egrep '\.core' $TMP > $TMP2
|
|
|
|
if [ -s $TMP2 ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Possible core dumps:"
|
|
|
|
cat $TMP2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# egrep -v '\.core' $TMP > $TMP2
|
|
|
|
# if [ -s $TMP2 ]; then
|
|
|
|
# echo ""
|
|
|
|
# echo "Deleted files:"
|
|
|
|
# cat $TMP2
|
|
|
|
# fi
|
|
|
|
|
|
|
|
rm -f $TMP $TMP2
|
|
|
|
fi
|
1994-02-19 10:56:02 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$run_msgs" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
msgs -c
|
|
|
|
fi
|
1994-02-18 08:40:22 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$expire_news" != NO -a -f /etc/news.expire ]; then
|
1993-03-21 12:45:37 +03:00
|
|
|
/etc/news.expire
|
|
|
|
fi
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$purge_accounting" != NO -a -f /var/account/acct ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Purging accounting records:"
|
|
|
|
mv /var/account/acct.2 /var/account/acct.3
|
|
|
|
mv /var/account/acct.1 /var/account/acct.2
|
|
|
|
mv /var/account/acct.0 /var/account/acct.1
|
|
|
|
cp /var/account/acct /var/account/acct.0
|
|
|
|
sa -sq
|
1994-02-26 06:29:23 +03:00
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$run_calendar" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
calendar -a > $TMP
|
|
|
|
if [ -s $TMP ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Running calendar:"
|
|
|
|
cat $TMP
|
|
|
|
fi
|
|
|
|
rm -f $TMP
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$check_uucp" != NO -a -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
|
1993-03-21 12:45:37 +03:00
|
|
|
echo ""
|
|
|
|
echo "Cleaning up UUCP:"
|
|
|
|
echo /etc/uuclean.daily | su daemon
|
|
|
|
fi
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$check_disks" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
df -k > $TMP
|
|
|
|
dump W > $TMP2
|
|
|
|
if [ -s $TMP -o -s $TMP2 ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Checking subsystem status:"
|
|
|
|
echo ""
|
|
|
|
echo "disks:"
|
|
|
|
if [ -s $TMP ]; then
|
|
|
|
cat $TMP
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
if [ -s $TMP2 ]; then
|
|
|
|
cat $TMP2
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
rm -f $TMP $TMP2
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$check_mailq" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
mailq > $TMP
|
|
|
|
if ! grep -q "^Mail queue is empty$" $TMP; then
|
|
|
|
echo ""
|
|
|
|
echo "mail:"
|
|
|
|
cat $TMP
|
|
|
|
fi
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
rm -f $TMP
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$check_uucp" != NO -a -d /var/spool/uucp ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
uustat -a > $TMP
|
|
|
|
if [ -s $TMP ]; then
|
|
|
|
echo ""
|
|
|
|
echo "uucp:"
|
1997-05-30 09:18:59 +04:00
|
|
|
cat $TMP
|
1997-01-05 14:21:09 +03:00
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
fi
|
|
|
|
|
1997-01-05 14:21:09 +03:00
|
|
|
rm -f $TMP
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$check_network" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
echo ""
|
|
|
|
echo "network:"
|
|
|
|
netstat -i
|
|
|
|
echo ""
|
|
|
|
t=/var/rwho/*
|
|
|
|
if [ "$t" != '/var/rwho/*' ]; then
|
|
|
|
ruptime
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$run_fsck" != NO ]; then
|
1997-01-05 14:21:09 +03:00
|
|
|
echo ""
|
|
|
|
echo "Checking filesystems:"
|
|
|
|
fsck -n | grep -v '^\*\* Phase'
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
echo ""
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$run_rdist" != NO -a -f /etc/Distfile ]; then
|
1993-03-21 12:45:37 +03:00
|
|
|
echo "Running rdist:"
|
1997-02-15 13:02:07 +03:00
|
|
|
if [ -d /var/log/rdist ]; then
|
1997-05-30 09:18:59 +04:00
|
|
|
logf=`date +%Y.%b.%e`
|
1997-02-15 13:02:07 +03:00
|
|
|
rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf
|
|
|
|
else
|
|
|
|
rdist -f /etc/Distfile
|
|
|
|
fi
|
1993-03-21 12:45:37 +03:00
|
|
|
fi
|
|
|
|
|
1997-05-30 09:18:59 +04:00
|
|
|
if [ "$run_security" != NO ]; then
|
1997-07-11 04:36:55 +04:00
|
|
|
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" $MAILTO
|
1997-01-05 14:21:09 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf $TMPDIR
|