[BACK]Return to monthly CVS log [TXT][DIR] Up to [local] / src / etc

File: [local] / src / etc / monthly (download)

Revision 1.12, Mon May 25 21:31:24 2009 UTC (15 years ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.11: +4 -1 lines

polish comments, no functional change:
1) advertise *.local and next_part near the top of the three scripts
2) daily: mention smtpd(8) mailq behaviour (like for sendmail, postfix, exim)
3) weekly: drop a comment trivially rehashing the next two lines of code
documenting next_part in the scripts was suggested by jmc@
ok sthen@ okan@ halex@; "i won't object" ajacoutot@

#
#	$OpenBSD: monthly,v 1.12 2009/05/25 21:31:24 schwarze Exp $
#
# For local additions, create the file /etc/monthly.local.
# To get section headers, use the function next_part in monthly.local.
#
umask 022

PARTOUT=/var/log/monthly.part
MAINOUT=/var/log/monthly.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 monthly.local:"
run_script "monthly.local"

end_part
rm -f $PARTOUT
                        
[ -s $MAINOUT ] && mail -s "`hostname` monthly output" root < $MAINOUT