summaryrefslogtreecommitdiff
path: root/etc/weekly
blob: ff00fffadee4c2d8e2b00a4743412a3118268ffb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
#	$OpenBSD: weekly,v 1.24 2011/01/19 06:18:05 david Exp $
#
# For local additions, create the file /etc/weekly.local.
# To get section headers, use the function next_part in weekly.local.
#
umask 022

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 "$TITLE"
	cat $PARTOUT
}

next_part() {
	end_part
	start_part "$1"
}

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 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
		UPDATEDB="/usr/libexec/locate.updatedb"
		echo "${UPDATEDB} --fcodes=- --tmpdir=${TMPDIR:-/var/tmp}" | \
		    nice -5 su -m nobody 2>/dev/null 1>$TMP
		if [ -s "$TMP" ]; then
			chmod 444 $TMP
			chown root:wheel $TMP
			mv -f $TMP /var/db/locate.database
		else
			echo "Not installing locate database; zero size"
		fi
	else
		echo "Not rebuilding locate database; can't create temp file"
	fi
fi

next_part "Rebuilding whatis databases:"
/usr/libexec/makewhatis

next_part "Doing login accounting:"
[ "X$LOGINACCOUNTING" = X1 ] && {
	ac -p | sort -nr -k 2
}

end_part
rm -f $PARTOUT

[ -s $MAINOUT ] && mail -s "`hostname` weekly output" root < $MAINOUT