daily revision 1.19
1#!/bin/sh -
2#
3#	$NetBSD: daily,v 1.19 1997/01/09 05:44:46 mikel Exp $
4#
5# from: @(#)daily	5.12 (Berkeley) 5/24/91
6#
7
8PATH=/bin:/usr/bin:/sbin:/usr/sbin
9host=`hostname -s`
10echo "Subject: $host daily run output"
11
12umask 077
13
14if [ -s /etc/daily.conf ]; then
15	. /etc/daily.conf
16fi
17
18#echo ""
19#echo "Removing scratch and junk files:"
20#if [ -d /tmp -a ! -h /tmp ]; then
21#	cd /tmp && {
22#	find . -type f -atime +3 -exec rm -f -- {} \;
23#	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
24#	    >/dev/null 2>&1; }
25#fi
26
27#if [ -d /var/tmp -a ! -h /var/tmp ]; then
28#	cd /var/tmp && {
29#	find . ! -name . -atime +7 -exec rm -f -- {} \;
30#	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
31#	    >/dev/null 2>&1; }
32#fi
33
34# Additional junk directory cleanup would go like this:
35#if [ -d /scratch -a ! -h /scratch ]; then
36#	cd /scratch && {
37#	find . ! -name . -atime +1 -exec rm -f -- {} \;
38#	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
39#	    >/dev/null 2>&1; }
40#fi
41
42#if [ -d /var/rwho -a ! -h /var/rwho ] ; then
43#	cd /var/rwho && {
44#	find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
45#fi
46
47TMPDIR=/tmp/_daily.$$
48
49if ! mkdir $TMPDIR; then
50	echo can not create $TMPDIR.
51	exit 1
52fi
53
54if ! cd $TMPDIR; then
55	echo can not cd to $TMPDIR.
56	exit 1
57fi
58
59TMP=daily.$$
60TMP2=daily2.$$
61
62if [ x"$find_core" != xNO ] ; then
63	find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \
64		-o -fstype kernfs -o -fstype procfs \) -a -prune -o \
65		-name 'lost+found' -a -prune -o \
66		-name '*.core' -a -print > $TMP
67#		\( -name '[#,]*' -o -name '.#*' -o -name a.out \
68#		   -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
69#			-a -atime +3 -exec rm -f -- {} \; -a -print > $TMP
70
71	egrep '\.core' $TMP > $TMP2
72	if [ -s $TMP2 ]; then
73		echo ""
74		echo "Possible core dumps:"
75		cat $TMP2
76	fi
77
78#	egrep -v '\.core' $TMP > $TMP2
79#	if [ -s $TMP2 ]; then
80#		echo ""
81#		echo "Deleted files:"
82#		cat $TMP2
83#	fi
84
85	rm -f $TMP $TMP2
86fi
87
88if [ x"$run_msgs" != xNO ]; then
89	msgs -c
90fi
91
92if [ x"$expire_news" != xNO -a -f /etc/news.expire ]; then
93	/etc/news.expire
94fi
95
96if [ x"$purge_accounting" != xNO -a -f /var/account/acct ]; then
97	echo "" ;
98	echo "Purging accounting records:" ;
99	mv /var/account/acct.2 /var/account/acct.3 ;
100	mv /var/account/acct.1 /var/account/acct.2 ;
101	mv /var/account/acct.0 /var/account/acct.1 ;
102	cp /var/account/acct /var/account/acct.0 ;
103	sa -sq ;
104fi
105
106if [ x"$run_calendar" != xNO ]; then
107	calendar -a > $TMP
108	if [ -s $TMP ]; then
109		echo ""
110		echo "Running calendar:"
111		cat $TMP
112	fi
113	rm -f $TMP
114fi
115
116if [ x"$check_uucp" != xNO -a -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
117	echo ""
118	echo "Cleaning up UUCP:"
119	echo /etc/uuclean.daily | su daemon
120fi
121
122if [ x"$check_disks" != xNO ]; then
123	df -k > $TMP 
124	dump W > $TMP2
125	if [ -s $TMP -o -s $TMP2 ]; then
126		echo ""
127		echo "Checking subsystem status:"
128		echo ""
129		echo "disks:"
130		if [ -s $TMP ]; then
131			cat $TMP
132			echo ""
133		fi
134		if [ -s $TMP2 ]; then
135			cat $TMP2
136			echo ""
137		fi
138		echo ""
139	fi
140fi
141
142rm -f $TMP $TMP2
143
144if [ x"$check_mailq" != xNO ]; then
145	mailq > $TMP
146	if ! grep -q "^Mail queue is empty$" $TMP; then
147		echo ""
148		echo "mail:"
149		cat $TMP
150	fi
151fi
152
153rm -f $TMP
154
155if [ x"$check_uucp" != xNO -a -d /var/spool/uucp ]; then
156	uustat -a > $TMP
157	if [ -s $TMP ]; then
158		echo ""
159		echo "uucp:"
160	fi
161fi
162
163rm -f $TMP
164
165if [ x"$check_network" != xNO ]; then
166	echo ""
167	echo "network:"
168	netstat -i
169	echo ""
170	t=/var/rwho/*
171	if [ "$t" != '/var/rwho/*' ]; then
172		ruptime
173	fi
174fi
175
176if [ x"$run_fsck" != xNO ]; then
177	echo ""
178	echo "Checking filesystems:"
179	fsck -n | grep -v '^\*\* Phase'
180fi
181
182echo ""
183if [ x"$run_rdist" != xNO -a -f /etc/Distfile ]; then
184	echo "Running rdist:"
185	rdist -f /etc/Distfile
186fi
187
188if [ x"$run_security" != xNO ]; then
189	sh /etc/security 2>&1 | mail -s "daily insecurity output" root
190fi
191
192rm -rf $TMPDIR
193
194exit
195