summaryrefslogtreecommitdiff
path: root/etc/weekly
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2009-05-09 17:15:50 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2009-05-09 17:15:50 +0000
commit5b2769fd2610db19e0f601aa68fb736aa17eb701 (patch)
treea8e4e244bd339d44ac0149980feacffaa089e84e /etc/weekly
parent6a0f971e887cf324c3d90a90f5401030ddde6b66 (diff)
make weekly and monthly silent by default
add the same infrastructure to daily; silencing daily needs another step discussed with ajacoutot@ okan@ todd@ sthen@ deraadt@ jmc@ "immediately commit" deraadt@ (without seeing the final diff)
Diffstat (limited to 'etc/weekly')
-rw-r--r--etc/weekly58
1 files changed, 44 insertions, 14 deletions
diff --git a/etc/weekly b/etc/weekly
index 1a0152a0035..ec22dccae6a 100644
--- a/etc/weekly
+++ b/etc/weekly
@@ -1,24 +1,53 @@
-#!/bin/sh -
#
-# $OpenBSD: weekly,v 1.19 2007/02/02 14:52:48 ajacoutot Exp $
+# $OpenBSD: weekly,v 1.20 2009/05/09 17:15:49 schwarze Exp $
#
umask 022
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH
-if [ -f /etc/weekly.local ]; then
+PARTOUT=/var/log/weekly.part
+MAINOUT=/var/log/weekly.out
+install -o 0 -g 0 -m 600 /dev/null $PARTOUT
+install -o 0 -g 0 -m 600 -b /dev/null $MAINOUT
+
+start_part() {
+ TITLE=$1
+ exec > $PARTOUT 2>&1
+}
+
+end_part() {
+ exec >> $MAINOUT 2>&1
+ test -s $PARTOUT || return
echo ""
- echo "Running weekly.local:"
- . /etc/weekly.local
-fi
+ echo "$TITLE"
+ cat $PARTOUT
+}
+
+next_part() {
+ end_part
+ start_part "$1"
+}
-echo ""
+run_script() {
+ f=/etc/$1
+ test -e $f || return
+ if [ `stat -f '%Sp%u' $f | cut -b1,6,9,11-` != '---0' ]; then
+ echo "$f has insecure permissions, skipping:"
+ ls -l $f
+ return
+ fi
+ . $f
+}
+
+start_part "Running /etc/weekly.local:"
+run_script "weekly.local"
+
+next_part "Rebuilding locate database:"
if [ -f /var/db/locate.database ]; then
TMP=`mktemp /var/db/locate.database.XXXXXXXXXX`
if [ $? -eq 0 ]; then
trap 'rm -f $TMP; exit 1' 0 1 15
- echo "Rebuilding locate database:"
UPDATEDB="/usr/libexec/locate.updatedb"
echo "${UPDATEDB} --fcodes=- --tmpdir=${TMPDIR:-/var/tmp}" | \
nice -5 su -m nobody 2>/dev/null 1>$TMP
@@ -32,18 +61,19 @@ if [ -f /var/db/locate.database ]; then
else
echo "Not rebuilding locate database; can't create temp file"
fi
-else
- echo "Not rebuilding locate database; no /var/db/locate.database"
fi
-echo ""
-echo "Rebuilding whatis databases:"
+next_part "Rebuilding whatis databases:"
makewhatis
# If LOGINACCOUNTING is set to 1 in the environment, report user
# accounting information
+next_part "Doing login accounting:"
[ "X$LOGINACCOUNTING" = X1 ] && {
- echo ""
- echo "Doing login accounting:"
ac -p | sort -nr -k 2
}
+
+end_part
+rm -f $PARTOUT
+
+[ -s $MAINOUT ] && mail -s "`hostname` weekly output" root < $MAINOUT