Avoid the output "Running xxx.local" if the "xxx.local" script trunk
authorkim <kim@NetBSD.org>
Fri, 09 Apr 2004 17:35:21 +0000
branchtrunk
changeset 125981 2f850760443b
parent 125980 3ed943f94165
child 125982 874c1f8c00ab
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.
etc/daily
etc/monthly
etc/weekly
--- a/etc/daily	Fri Apr 09 17:33:35 2004 +0000
+++ b/etc/daily	Fri Apr 09 17:35:21 2004 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: daily,v 1.59 2004/04/02 13:13:47 jmmv Exp $
+#	$NetBSD: daily,v 1.60 2004/04/09 17:35:21 kim Exp $
 #	@(#)daily	8.2 (Berkeley) 1/25/94
 #
 
@@ -284,7 +284,10 @@
 fi
 
 if [ -f /etc/daily.local ]; then
-	echo ""
-	echo "Running /etc/daily.local:"
-	. /etc/daily.local
+	. /etc/daily.local > $TMP 2>&1
+	if [ -s $TMP ] ; then
+		printf "\nRunning /etc/daily.local:\n"
+		cat $TMP
+	fi
+	rm -f $TMP
 fi
--- a/etc/monthly	Fri Apr 09 17:33:35 2004 +0000
+++ b/etc/monthly	Fri Apr 09 17:35:21 2004 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: monthly,v 1.9 2004/04/02 13:13:47 jmmv Exp $
+#	$NetBSD: monthly,v 1.10 2004/04/09 17:35:21 kim Exp $
 #	from: @(#)monthly	8.1 (Berkeley) 6/9/93
 #
 
@@ -19,12 +19,26 @@
 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
-	echo ""
-	echo "Running /etc/monthly.local:"
-	. /etc/monthly.local
+	. /etc/monthly.local > $TMP 2>&1
+	if [ -s $TMP ] ; then
+		printf "\nRunning /etc/monthly.local:\n"
+		cat $TMP
+	fi
+	rm -f $TMP
 fi
--- a/etc/weekly	Fri Apr 09 17:33:35 2004 +0000
+++ b/etc/weekly	Fri Apr 09 17:35:21 2004 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: weekly,v 1.18 2004/04/02 13:13:47 jmmv Exp $
+#	$NetBSD: weekly,v 1.19 2004/04/09 17:35:21 kim Exp $
 #	from: @(#)weekly	8.2 (Berkeley) 1/2/94
 #
 
@@ -26,6 +26,17 @@
 	exit 1;
 fi
 
+WEEKLYDIR=`mktemp -d /tmp/_weekly.XXXXXX` || exit 1
+
+trap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT QUIT PIPE
+
+if ! cd "$WEEKLYDIR"; then
+	echo "Can not cd to $WEEKLYDIR".
+	exit 1
+fi
+
+TMP=weekly.$$
+
 #echo ""
 #echo "Removing old .o files:"
 #find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \;
@@ -75,7 +86,10 @@
 fi
 
 if [ -f /etc/weekly.local ]; then
-	echo ""
-	echo "Running /etc/weekly.local:"
-	. /etc/weekly.local
+	. /etc/weekly.local > $TMP 2>&1
+	if [ -s $TMP ] ; then
+		printf "\nRunning /etc/weekly.local:\n"
+		cat $TMP
+	fi
+	rm -f $TMP
 fi