etc/monthly
author kim <kim@NetBSD.org>
Fri, 09 Apr 2004 17:35:21 +0000
branchtrunk
changeset 125981 2f850760443b
parent 125761 d6de26b19154
child 159489 2529aec9aa9c
child 261401 3afaa45e3ead
child 266390 4698abe02ae1
child 287338 f982a33971cf
child 289073 c55f3df57f55
child 289282 416debee58a1
permissions -rw-r--r--
Avoid the output "Running xxx.local" if the "xxx.local" script does not produce any output. This matches what /etc/security already does with /etc/security.local output.

#!/bin/sh -
#
#	$NetBSD: monthly,v 1.10 2004/04/09 17:35:21 kim Exp $
#	from: @(#)monthly	8.1 (Berkeley) 6/9/93
#

export PATH=/bin:/usr/bin:/sbin:/usr/sbin
umask 077

if [ -s /etc/monthly.conf ]; then
	. /etc/monthly.conf
fi

host=`hostname`
date=`date`
rcvar_manpage='monthly.conf(5)'

echo "To: ${MAILTO:-root}"
echo "Subject: $host monthly output for $date"
echo ""

MONTHLYDIR=`mktemp -d /tmp/_monthly.XXXXXX` || exit 1

trap "/bin/rm -rf $MONTHLYDIR ; exit 0" EXIT INT QUIT PIPE

if ! cd "$MONTHLYDIR"; then
	echo "Can not cd to $MONTHLYDIR".
	exit 1
fi

TMP=monthly.$$

# echo ""
# echo "Doing login accounting:"
# ac -p | sort -nr +1

if [ -f /etc/monthly.local ]; then
	. /etc/monthly.local > $TMP 2>&1
	if [ -s $TMP ] ; then
		printf "\nRunning /etc/monthly.local:\n"
		cat $TMP
	fi
	rm -f $TMP
fi