11.1Scgd#!/bin/sh - 21.1Scgd# 31.32Skre# $NetBSD: weekly,v 1.32 2018/09/23 23:12:21 kre 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.31Sdarcy echo "Can't cd to $WEEKLYDIR; aborting." 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.32Skre#if [ -d /usr/src ] && 481.32Skre# [ -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.25Sjoergif checkyesno rebuild_mandb; then 831.25Sjoerg echo "" 841.32Skre if [ -f /etc/man.conf ] && [ -x /usr/sbin/makemandb ]; then 851.25Sjoerg echo "Rebuilding man page index:" 861.29Swiz (umask 022; nice -n 5 /usr/sbin/makemandb -f -Q) 871.25Sjoerg else 881.25Sjoerg echo "Not rebuilding man page index" 891.25Sjoerg fi 901.25Sjoergfi 911.25Sjoerg 921.14Sadif [ -f /etc/weekly.local ]; then 931.19Skim . /etc/weekly.local > $TMP 2>&1 941.19Skim if [ -s $TMP ] ; then 951.19Skim printf "\nRunning /etc/weekly.local:\n" 961.19Skim cat $TMP 971.19Skim fi 981.19Skim rm -f $TMP 991.4Scgdfi 100