1df930be7Sderaadt# 2*dd6e8aa1Sjung# $OpenBSD: weekly,v 1.30 2020/02/12 20:51:49 jung Exp $ 358a1e7f8Sschwarze# 458a1e7f8Sschwarze# For local additions, create the file /etc/weekly.local. 558a1e7f8Sschwarze# To get section headers, use the function next_part in weekly.local. 6df930be7Sderaadt# 76e67fba8Sajacoutotumask 022 8df930be7Sderaadt 903446679SschwarzePARTOUT=/var/log/weekly.part 1003446679SschwarzeMAINOUT=/var/log/weekly.out 1103446679Sschwarzeinstall -o 0 -g 0 -m 600 /dev/null $PARTOUT 1203446679Sschwarzeinstall -o 0 -g 0 -m 600 -b /dev/null $MAINOUT 13c2003419Sdavid 1403446679Sschwarzestart_part() { 1503446679Sschwarze TITLE=$1 1603446679Sschwarze exec > $PARTOUT 2>&1 1703446679Sschwarze} 1803446679Sschwarze 1903446679Sschwarzeend_part() { 2003446679Sschwarze exec >> $MAINOUT 2>&1 2103446679Sschwarze test -s $PARTOUT || return 22df930be7Sderaadt echo "" 2303446679Sschwarze echo "$TITLE" 2403446679Sschwarze cat $PARTOUT 2503446679Sschwarze} 2603446679Sschwarze 2703446679Sschwarzenext_part() { 2803446679Sschwarze end_part 2903446679Sschwarze start_part "$1" 3003446679Sschwarze} 3103446679Sschwarze 3203446679Sschwarzerun_script() { 3303446679Sschwarze f=/etc/$1 3403446679Sschwarze test -e $f || return 3503446679Sschwarze if [ `stat -f '%Sp%u' $f | cut -b1,6,9,11-` != '---0' ]; then 3603446679Sschwarze echo "$f has insecure permissions, skipping:" 3703446679Sschwarze ls -l $f 3803446679Sschwarze return 3903446679Sschwarze fi 4003446679Sschwarze . $f 4103446679Sschwarze} 4203446679Sschwarze 4304bf5079Sschwarzestart_part "Running weekly.local:" 4403446679Sschwarzerun_script "weekly.local" 4503446679Sschwarze 4603446679Sschwarzenext_part "Rebuilding locate database:" 47df930be7Sderaadtif [ -f /var/db/locate.database ]; then 4822baa516Sguenther if TMP=`mktemp /var/db/locate.database.XXXXXXXXXX`; then 49dc35e6a9Shugh trap 'rm -f $TMP; exit 1' 0 1 15 50e3d20181Smickey UPDATEDB="/usr/libexec/locate.updatedb" 51*dd6e8aa1Sjung echo "${UPDATEDB} --fcodes=-" | \ 52cedd04acSespie nice -5 su -m nobody 1>$TMP 53cedd04acSespie if [ $? -ne 0 ]; then 54cedd04acSespie echo "Rebuilding locate database failed" 55cedd04acSespie elif ! locate -d $TMP /etc/weekly >/dev/null; then 56cedd04acSespie echo "Not installing invalid locate database" 57cedd04acSespie else 58e294ac80Smillert chmod 444 $TMP 592f7ca374Smillert chown root:wheel $TMP 60e294ac80Smillert mv -f $TMP /var/db/locate.database 61e294ac80Smillert fi 62e294ac80Smillert else 63e294ac80Smillert echo "Not rebuilding locate database; can't create temp file" 64e294ac80Smillert fi 65df930be7Sderaadtfi 66e751edb1Salex 6703446679Sschwarzenext_part "Rebuilding whatis databases:" 6878be3774Sschwarze/usr/sbin/makewhatis $MAKEWHATISARGS 69ca608fafSjmc 7003446679Sschwarzenext_part "Doing login accounting:" 71b3755313Sajacoutot[ "X$LOGINACCOUNTING" = X1 ] && { 72b3755313Sajacoutot ac -p | sort -nr -k 2 73b3755313Sajacoutot} 7403446679Sschwarze 7503446679Sschwarzeend_part 7603446679Sschwarzerm -f $PARTOUT 7703446679Sschwarze 7803446679Sschwarze[ -s $MAINOUT ] && mail -s "`hostname` weekly output" root < $MAINOUT 79