Annotation of src/etc/weekly, Revision 1.30
1.1 deraadt 1: #
1.30 ! jung 2: # $OpenBSD: weekly,v 1.29 2019/12/30 16:49:51 espie Exp $
1.23 schwarze 3: #
4: # For local additions, create the file /etc/weekly.local.
5: # To get section headers, use the function next_part in weekly.local.
1.1 deraadt 6: #
1.18 ajacouto 7: umask 022
1.1 deraadt 8:
1.20 schwarze 9: PARTOUT=/var/log/weekly.part
10: MAINOUT=/var/log/weekly.out
11: install -o 0 -g 0 -m 600 /dev/null $PARTOUT
12: install -o 0 -g 0 -m 600 -b /dev/null $MAINOUT
13:
14: start_part() {
15: TITLE=$1
16: exec > $PARTOUT 2>&1
17: }
18:
19: end_part() {
20: exec >> $MAINOUT 2>&1
21: test -s $PARTOUT || return
1.2 david 22: echo ""
1.20 schwarze 23: echo "$TITLE"
24: cat $PARTOUT
25: }
26:
27: next_part() {
28: end_part
29: start_part "$1"
30: }
31:
32: run_script() {
33: f=/etc/$1
34: test -e $f || return
35: if [ `stat -f '%Sp%u' $f | cut -b1,6,9,11-` != '---0' ]; then
36: echo "$f has insecure permissions, skipping:"
37: ls -l $f
38: return
39: fi
40: . $f
41: }
42:
1.21 schwarze 43: start_part "Running weekly.local:"
1.20 schwarze 44: run_script "weekly.local"
1.1 deraadt 45:
1.20 schwarze 46: next_part "Rebuilding locate database:"
1.1 deraadt 47: if [ -f /var/db/locate.database ]; then
1.25 guenther 48: if TMP=`mktemp /var/db/locate.database.XXXXXXXXXX`; then
1.17 hugh 49: trap 'rm -f $TMP; exit 1' 0 1 15
1.9 mickey 50: UPDATEDB="/usr/libexec/locate.updatedb"
1.30 ! jung 51: echo "${UPDATEDB} --fcodes=-" | \
1.29 espie 52: nice -5 su -m nobody 1>$TMP
53: if [ $? -ne 0 ]; then
54: echo "Rebuilding locate database failed"
55: elif ! locate -d $TMP /etc/weekly >/dev/null; then
56: echo "Not installing invalid locate database"
57: else
1.6 millert 58: chmod 444 $TMP
1.13 millert 59: chown root:wheel $TMP
1.6 millert 60: mv -f $TMP /var/db/locate.database
61: fi
62: else
63: echo "Not rebuilding locate database; can't create temp file"
64: fi
1.1 deraadt 65: fi
1.10 alex 66:
1.20 schwarze 67: next_part "Rebuilding whatis databases:"
1.28 schwarze 68: /usr/sbin/makewhatis $MAKEWHATISARGS
1.15 jmc 69:
1.20 schwarze 70: next_part "Doing login accounting:"
1.19 ajacouto 71: [ "X$LOGINACCOUNTING" = X1 ] && {
72: ac -p | sort -nr -k 2
73: }
1.20 schwarze 74:
75: end_part
76: rm -f $PARTOUT
1.24 david 77:
1.20 schwarze 78: [ -s $MAINOUT ] && mail -s "`hostname` weekly output" root < $MAINOUT