weekly revision 1.19
11.1Scgd#!/bin/sh - 21.1Scgd# 31.19Skim# $NetBSD: weekly,v 1.19 2004/04/09 17:35:21 kim Exp $ 41.7Smikel# from: @(#)weekly 8.2 (Berkeley) 1/2/94 51.1Scgd# 61.1Scgd 71.11Smycroftexport PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/libexec 81.12Slukemumask 077 91.12Slukem 101.12Slukemif [ -s /etc/weekly.conf ]; then 111.12Slukem . /etc/weekly.conf 121.12Slukemfi 131.12Slukem 141.10Slukemhost=`hostname` 151.12Slukemdate=`date` 161.18Sjmmvrcvar_manpage='weekly.conf(5)' 171.1Scgd 181.12Slukemecho "To: ${MAILTO:-root}" 191.12Slukemecho "Subject: $host weekly output for $date" 201.12Slukemecho "" 211.6Smrg 221.10Slukemif [ -f /etc/rc.subr ]; then 231.10Slukem . /etc/rc.subr 241.10Slukemelse 251.10Slukem echo "Can't read /etc/rc.subr; aborting." 261.10Slukem exit 1; 271.6Smrgfi 281.6Smrg 291.19SkimWEEKLYDIR=`mktemp -d /tmp/_weekly.XXXXXX` || exit 1 301.19Skim 311.19Skimtrap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT QUIT PIPE 321.19Skim 331.19Skimif ! cd "$WEEKLYDIR"; then 341.19Skim echo "Can not cd to $WEEKLYDIR". 351.19Skim exit 1 361.19Skimfi 371.19Skim 381.19SkimTMP=weekly.$$ 391.19Skim 401.1Scgd#echo "" 411.1Scgd#echo "Removing old .o files:" 421.1Scgd#find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \; 431.1Scgd 441.1Scgd# see if /usr/src exists and is local 451.1Scgd# before looking there for checked-out files 461.1Scgd 471.2Scgd#if [ -d /usr/src -a \ 481.8Smycroft# -n "`find -f /usr/src ! -fstype local -prune -or -type d -print -prune`" ]; 491.2Scgd#then 501.16Skim# echo "" 511.16Skim# echo "Looking for checked out files:" 521.2Scgd# 531.17Slukem# TDIR=`mktemp -d /tmp/_checkout.XXXXXX` || exit 1 541.17Slukem# trap "/bin/rm -rf $TDIR ; exit 0" EXIT INT QUIT 551.2Scgd# for file in `find -f /usr/src ! -fstype local -prune -or \ 561.2Scgd# -name 'p.*' -print | egrep 'SCCS/p\.'`; do 571.2Scgd# owner=`awk '{ print $3 }' $file` 581.2Scgd# echo "$owner $file" 591.17Slukem# echo $file >> "$TDIR/$owner" 601.2Scgd# done | sed -e 's,SCCS/p.,,' 611.7Smikel# if test -n "`ls $TDIR`"; then 621.7Smikel# for file in $TDIR/*; do 631.7Smikel# sed -e 's,SCCS/p.,,' $file | \ 641.15Slukem# Mail -s 'checked out files' ${file##*/} 651.7Smikel# done 661.7Smikel# fi 671.2Scgd#fi 681.1Scgd 691.10Slukemif checkyesno clean_uucp && [ -f /usr/libexec/uucp/clean.weekly ]; then 701.1Scgd echo "" 711.1Scgd echo "Cleaning up UUCP:" 721.9Slukem su daemon -c /usr/libexec/uucp/clean.weekly 731.1Scgdfi 741.1Scgd 751.16Skimif checkyesno rebuild_locatedb; then 761.16Skim echo "" 771.16Skim if [ -f /var/db/locate.database ]; then 781.16Skim echo "Rebuilding locate database:" 791.16Skim chmod 644 /var/db/locate.database 801.16Skim chown nobody:nobody /var/db/locate.database 811.16Skim nice -5 su -m nobody -c /usr/libexec/locate.updatedb 2>/dev/null 821.16Skim chown root:wheel /var/db/locate.database 831.16Skim else 841.16Skim echo "Not rebuilding locate database; no /var/db/locate.database" 851.16Skim fi 861.14Sadfi 871.14Sad 881.14Sadif [ -f /etc/weekly.local ]; then 891.19Skim . /etc/weekly.local > $TMP 2>&1 901.19Skim if [ -s $TMP ] ; then 911.19Skim printf "\nRunning /etc/weekly.local:\n" 921.19Skim cat $TMP 931.19Skim fi 941.19Skim rm -f $TMP 951.4Scgdfi 96