ce3196e8dd
the same user as the daily output. If $USER is not root or MAILTO is not set, MAILTO is set to root. Closes PR 2409.
205 lines
3.9 KiB
Bash
205 lines
3.9 KiB
Bash
#!/bin/sh -
|
|
#
|
|
# $NetBSD: daily,v 1.23 1997/07/11 00:36:55 phil Exp $
|
|
# @(#)daily 8.2 (Berkeley) 1/25/94
|
|
#
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
|
host=`hostname`
|
|
echo "Subject: $host daily run output"
|
|
|
|
umask 077
|
|
|
|
if [ -z "$MAILTO" -o "$USER" != "root" ]; then
|
|
MAILTO=root
|
|
fi
|
|
|
|
if [ -s /etc/daily.conf ]; then
|
|
. /etc/daily.conf
|
|
fi
|
|
|
|
echo ""
|
|
echo "Uptime: " `uptime`
|
|
|
|
#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
|
|
|
|
# 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
|
|
|
|
#if [ -d /var/rwho -a ! -h /var/rwho ] ; then
|
|
# cd /var/rwho && {
|
|
# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
|
|
#fi
|
|
|
|
TMPDIR=/tmp/_daily.$$
|
|
|
|
if ! mkdir $TMPDIR; then
|
|
echo can not create $TMPDIR.
|
|
exit 1
|
|
fi
|
|
|
|
if ! cd $TMPDIR; then
|
|
echo can not cd to $TMPDIR.
|
|
exit 1
|
|
fi
|
|
|
|
TMP=daily.$$
|
|
TMP2=daily2.$$
|
|
|
|
if [ "$find_core" != NO ] ; then
|
|
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
|
|
|
|
if [ "$run_msgs" != NO ]; then
|
|
msgs -c
|
|
fi
|
|
|
|
if [ "$expire_news" != NO -a -f /etc/news.expire ]; then
|
|
/etc/news.expire
|
|
fi
|
|
|
|
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
|
|
fi
|
|
|
|
if [ "$run_calendar" != NO ]; then
|
|
calendar -a > $TMP
|
|
if [ -s $TMP ]; then
|
|
echo ""
|
|
echo "Running calendar:"
|
|
cat $TMP
|
|
fi
|
|
rm -f $TMP
|
|
fi
|
|
|
|
if [ "$check_uucp" != NO -a -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
|
|
echo ""
|
|
echo "Cleaning up UUCP:"
|
|
echo /etc/uuclean.daily | su daemon
|
|
fi
|
|
|
|
if [ "$check_disks" != NO ]; then
|
|
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
|
|
|
|
rm -f $TMP $TMP2
|
|
|
|
if [ "$check_mailq" != NO ]; then
|
|
mailq > $TMP
|
|
if ! grep -q "^Mail queue is empty$" $TMP; then
|
|
echo ""
|
|
echo "mail:"
|
|
cat $TMP
|
|
fi
|
|
fi
|
|
|
|
rm -f $TMP
|
|
|
|
if [ "$check_uucp" != NO -a -d /var/spool/uucp ]; then
|
|
uustat -a > $TMP
|
|
if [ -s $TMP ]; then
|
|
echo ""
|
|
echo "uucp:"
|
|
cat $TMP
|
|
fi
|
|
fi
|
|
|
|
rm -f $TMP
|
|
|
|
if [ "$check_network" != NO ]; then
|
|
echo ""
|
|
echo "network:"
|
|
netstat -i
|
|
echo ""
|
|
t=/var/rwho/*
|
|
if [ "$t" != '/var/rwho/*' ]; then
|
|
ruptime
|
|
fi
|
|
fi
|
|
|
|
if [ "$run_fsck" != NO ]; then
|
|
echo ""
|
|
echo "Checking filesystems:"
|
|
fsck -n | grep -v '^\*\* Phase'
|
|
fi
|
|
|
|
echo ""
|
|
if [ "$run_rdist" != NO -a -f /etc/Distfile ]; then
|
|
echo "Running rdist:"
|
|
if [ -d /var/log/rdist ]; then
|
|
logf=`date +%Y.%b.%e`
|
|
rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf
|
|
else
|
|
rdist -f /etc/Distfile
|
|
fi
|
|
fi
|
|
|
|
if [ "$run_security" != NO ]; then
|
|
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" $MAILTO
|
|
fi
|
|
|
|
rm -rf $TMPDIR
|