Home | History | Annotate | Line # | Download | only in etc
weekly revision 1.25.2.3
      1       1.1       cgd #!/bin/sh -
      2       1.1       cgd #
      3  1.25.2.1       riz #	$NetBSD: weekly,v 1.25.2.3 2012/11/18 19:07:00 msaitoh Exp $
      4       1.7     mikel #	from: @(#)weekly	8.2 (Berkeley) 1/2/94
      5       1.1       cgd #
      6       1.1       cgd 
      7      1.11   mycroft export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/libexec
      8      1.12     lukem umask 077
      9      1.12     lukem 
     10      1.12     lukem if [ -s /etc/weekly.conf ]; then
     11      1.12     lukem 	. /etc/weekly.conf
     12      1.12     lukem fi
     13      1.12     lukem 
     14      1.24  christos host="$(hostname)"
     15      1.24  christos date="$(date)"
     16      1.18      jmmv rcvar_manpage='weekly.conf(5)'
     17       1.1       cgd 
     18      1.12     lukem echo "To: ${MAILTO:-root}"
     19      1.12     lukem echo "Subject: $host weekly output for $date"
     20      1.12     lukem echo ""
     21       1.6       mrg 
     22      1.10     lukem if [ -f /etc/rc.subr ]; then
     23      1.10     lukem 	. /etc/rc.subr
     24      1.10     lukem else
     25      1.10     lukem 	echo "Can't read /etc/rc.subr; aborting."
     26      1.10     lukem 	exit 1;
     27       1.6       mrg fi
     28       1.6       mrg 
     29      1.23    martti WEEKLYDIR=$(mktemp -d -t _weekly) || exit 1
     30      1.19       kim 
     31      1.19       kim trap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT QUIT PIPE
     32      1.19       kim 
     33      1.19       kim if ! cd "$WEEKLYDIR"; then
     34      1.19       kim 	echo "Can not cd to $WEEKLYDIR".
     35      1.19       kim 	exit 1
     36      1.19       kim fi
     37      1.19       kim 
     38      1.19       kim TMP=weekly.$$
     39      1.19       kim 
     40       1.1       cgd #echo ""
     41       1.1       cgd #echo "Removing old .o files:"
     42       1.1       cgd #find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \;
     43       1.1       cgd 
     44       1.1       cgd # see if /usr/src exists and is local
     45       1.1       cgd # before looking there for checked-out files
     46       1.1       cgd 
     47       1.2       cgd #if [ -d /usr/src -a \
     48      1.24  christos #  -n "$(find -f /usr/src ! -fstype local -prune -or -type d -print -prune)" ];
     49       1.2       cgd #then
     50      1.16       kim #	echo ""
     51      1.16       kim #	echo "Looking for checked out files:"
     52       1.2       cgd #
     53      1.23    martti #	TDIR=$(mktemp -d -t _checkout) || exit 1
     54      1.17     lukem #	trap "/bin/rm -rf $TDIR ; exit 0" EXIT INT QUIT
     55      1.24  christos #	for file in $(find -f /usr/src ! -fstype local -prune -or \
     56      1.24  christos #	    -name 'p.*' -print | egrep 'SCCS/p\.'); do
     57      1.24  christos #		owner=$(awk '{ print $3 }' $file)
     58       1.2       cgd #		echo "$owner	$file"
     59      1.17     lukem #		echo $file >> "$TDIR/$owner"
     60       1.2       cgd #	done | sed -e 's,SCCS/p.,,'
     61      1.24  christos #	if test -n "$(ls $TDIR)"; then
     62       1.7     mikel #		for file in $TDIR/*; do
     63       1.7     mikel #			sed -e 's,SCCS/p.,,' $file | \
     64      1.15     lukem #			    Mail -s 'checked out files' ${file##*/}
     65       1.7     mikel #		done
     66       1.7     mikel #	fi
     67       1.2       cgd #fi
     68       1.1       cgd 
     69      1.16       kim if checkyesno rebuild_locatedb; then
     70      1.16       kim 	echo ""
     71      1.16       kim 	if [ -f /var/db/locate.database ]; then
     72      1.16       kim 		echo "Rebuilding locate database:"
     73      1.16       kim 		chmod 644 /var/db/locate.database
     74      1.16       kim 		chown nobody:nobody /var/db/locate.database
     75      1.20     lukem 		(cd / && nice -5 su -m nobody -c /usr/libexec/locate.updatedb 2>/dev/null)
     76      1.16       kim 		chown root:wheel /var/db/locate.database
     77      1.16       kim 	else
     78      1.16       kim 		echo "Not rebuilding locate database; no /var/db/locate.database"
     79      1.16       kim 	fi
     80      1.14        ad fi
     81      1.14        ad 
     82      1.22      reed if checkyesno rebuild_whatisdb; then
     83      1.22      reed 	echo ""
     84  1.25.2.3   msaitoh 	if [ -x /usr/libexec/makewhatis -a \( -f /etc/man.conf \
     85      1.25     joerg 	     -o -d /usr/share/man \) ]; then
     86      1.22      reed 		echo "Rebuilding whatis databases:"
     87      1.22      reed 		nice -n 5 /usr/libexec/makewhatis -f
     88      1.22      reed 	else
     89      1.22      reed 		echo "Not rebuilding whatis databases"
     90      1.22      reed 	fi
     91      1.22      reed fi
     92      1.22      reed 
     93      1.25     joerg if checkyesno rebuild_mandb; then
     94      1.25     joerg 	echo ""
     95      1.25     joerg 	if [ -f /etc/man.conf -a -x /usr/sbin/makemandb ]; then
     96      1.25     joerg 		echo "Rebuilding man page index:"
     97  1.25.2.2    martin 		(umask 022; nice -n 5 /usr/sbin/makemandb -f -q)
     98      1.25     joerg 	else
     99      1.25     joerg 		echo "Not rebuilding man page index"
    100      1.25     joerg 	fi
    101      1.25     joerg fi
    102      1.25     joerg 
    103      1.14        ad if [ -f /etc/weekly.local ]; then
    104      1.19       kim 	. /etc/weekly.local > $TMP 2>&1
    105      1.19       kim 	if [ -s $TMP ] ; then
    106      1.19       kim 		printf "\nRunning /etc/weekly.local:\n"
    107      1.19       kim 		cat $TMP
    108      1.19       kim 	fi
    109      1.19       kim 	rm -f $TMP
    110       1.4       cgd fi
    111