weekly revision 1.25
11.1Scgd#!/bin/sh - 21.1Scgd# 31.25Sjoerg# $NetBSD: weekly,v 1.25 2012/02/07 19:13:30 joerg 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.24Schristoshost="$(hostname)" 151.24Schristosdate="$(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.23SmarttiWEEKLYDIR=$(mktemp -d -t _weekly) || 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.24Schristos# -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.23Smartti# TDIR=$(mktemp -d -t _checkout) || exit 1 541.17Slukem# trap "/bin/rm -rf $TDIR ; exit 0" EXIT INT QUIT 551.24Schristos# for file in $(find -f /usr/src ! -fstype local -prune -or \ 561.24Schristos# -name 'p.*' -print | egrep 'SCCS/p\.'); do 571.24Schristos# 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.24Schristos# 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.16Skimif checkyesno rebuild_locatedb; then 701.16Skim echo "" 711.16Skim if [ -f /var/db/locate.database ]; then 721.16Skim echo "Rebuilding locate database:" 731.16Skim chmod 644 /var/db/locate.database 741.16Skim chown nobody:nobody /var/db/locate.database 751.20Slukem (cd / && nice -5 su -m nobody -c /usr/libexec/locate.updatedb 2>/dev/null) 761.16Skim chown root:wheel /var/db/locate.database 771.16Skim else 781.16Skim echo "Not rebuilding locate database; no /var/db/locate.database" 791.16Skim fi 801.14Sadfi 811.14Sad 821.22Sreedif checkyesno rebuild_whatisdb; then 831.22Sreed echo "" 841.25Sjoerg if [ -x /usr/libexec/makewhatis -a \( -f /etc/man.conf -o \ 851.25Sjoerg -o -d /usr/share/man \) ]; then 861.22Sreed echo "Rebuilding whatis databases:" 871.22Sreed nice -n 5 /usr/libexec/makewhatis -f 881.22Sreed else 891.22Sreed echo "Not rebuilding whatis databases" 901.22Sreed fi 911.22Sreedfi 921.22Sreed 931.25Sjoergif checkyesno rebuild_mandb; then 941.25Sjoerg echo "" 951.25Sjoerg if [ -f /etc/man.conf -a -x /usr/sbin/makemandb ]; then 961.25Sjoerg echo "Rebuilding man page index:" 971.25Sjoerg nice -n 5 /usr/sbin/makemandb -f 981.25Sjoerg else 991.25Sjoerg echo "Not rebuilding man page index" 1001.25Sjoerg fi 1011.25Sjoergfi 1021.25Sjoerg 1031.14Sadif [ -f /etc/weekly.local ]; then 1041.19Skim . /etc/weekly.local > $TMP 2>&1 1051.19Skim if [ -s $TMP ] ; then 1061.19Skim printf "\nRunning /etc/weekly.local:\n" 1071.19Skim cat $TMP 1081.19Skim fi 1091.19Skim rm -f $TMP 1101.4Scgdfi 111