INN commit: trunk/scripts (innreport.in news.daily.in scanlogs.in)

INN Commit rra at isc.org
Wed Nov 11 10:55:27 UTC 2009


    Date: Wednesday, November 11, 2009 @ 02:55:27
  Author: iulius
Revision: 8737

news.daily:  don't send superfluous mails when "nomail" is given

Make sure that when news.daily is called with "nomail", mail is only
sent when there is real output.  Previously, there would always be
headings and empty lines useful to structure the full report, which are
now ommitted.

Also, postexec has been moved up to be included in the regular mail,
and the "nomail" definition of ${MAIL} is no longer overwritten with
the default.

Thanks to Florian Schlichting for this patch.

Modified:
  trunk/scripts/innreport.in
  trunk/scripts/news.daily.in
  trunk/scripts/scanlogs.in

---------------+
 innreport.in  |    4 +++-
 news.daily.in |   50 +++++++++++++++++++++++++++++++-------------------
 scanlogs.in   |   12 ++++++++----
 3 files changed, 42 insertions(+), 24 deletions(-)

Modified: innreport.in
===================================================================
--- innreport.in	2009-11-11 10:34:53 UTC (rev 8736)
+++ innreport.in	2009-11-11 10:55:27 UTC (rev 8737)
@@ -2073,7 +2073,9 @@
     $Title =~ s/\&/&/go;
     $Title =~ s/\</</go;
     $Title =~ s/\>/>/go;
-    print "$Title from $first_date to $last_date\n\n";
+    print "$Title from $first_date to $last_date\n\n"
+      if ((defined $$h{'default'}{'text'})
+          and ($$h{'default'}{'text'} =~ m/^true$/io));
   }
 
   if ($HTML) {

Modified: news.daily.in
===================================================================
--- news.daily.in	2009-11-11 10:34:53 UTC (rev 8736)
+++ news.daily.in	2009-11-11 10:55:27 UTC (rev 8737)
@@ -146,8 +146,8 @@
 	DOLOGS=false
 	;;
     Xnomail)
-	DOMAIL=false
-	MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/'"
+        DOMAIL=false
+        DOSTAT=false
 	;;
     Xnoprocbatch)
         DOPROCBATCH=false
@@ -184,8 +184,12 @@
 else
    MAILSUBJ="${HOSTNAME} intermediate Usenet report for ${DATE}"
 fi
-MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/' | \
-    ${MAILCMD} -s '$MAILSUBJ' ${NEWSMASTER}"
+if ${DOMAIL} ; then
+   MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/' | \
+      ${MAILCMD} -s '${MAILSUBJ}' ${NEWSMASTER}"
+else
+   MAIL="cut -c 1-1022 | ${SED} -e 's/^~/~~/'"
+fi
 
 ##  Sanity check.  Shouldn't we just bail out here with an error
 ##  instead of trying to patch things up?
@@ -272,14 +276,18 @@
 ##  Run any user programs.
 if [ -n "${PROGRAMS}" ] ; then
     for P in ${PROGRAMS} ; do
-	echo ''
-	echo "${P}:"
-	eval ${P}
+        if ${DOMAIL} ; then
+            echo ''
+            echo "${P}:"
+        fi
+        eval ${P}
     done
 fi
 
 ${DOLOGS} && {
-    echo ''
+    if ${DOMAIL} ; then
+        echo ''
+    fi
     scanlogs ${SCANARG}
 }
 
@@ -491,8 +499,10 @@
 
 ##  Renumber the active file.
 if ${DORENUMBER} ; then
-    echo ''
-    echo 'Renumbering active file.'
+    if ${DOMAIL} ; then
+        echo ''
+        echo 'Renumbering active file.'
+    fi
     if [ -z "${RENUMBER}" ] ;then
 	ctlinnd -s -t`wc -l <${ACTIVE}` renumber '' 2>&1
     else
@@ -520,6 +530,17 @@
     echo ''
 }
 
+##  Run any user programs.
+if [ -n "${POSTPROGRAMS}" ] ; then
+    for P in ${POSTPROGRAMS} ; do
+        if ${DOMAIL} ; then
+            echo ''
+            echo "${P}:"
+        fi
+        eval ${P}
+    done
+fi
+
 ##  Mail the report.
 if ${DOMAIL} ; then
     ##  Stop using the temp file, and mail captured output.
@@ -529,15 +550,6 @@
     rm -f ${TEMP}
 fi
 
-##  Run any user programs.
-if [ -n "${POSTPROGRAMS}" ] ; then
-    for P in ${POSTPROGRAMS} ; do
-	echo ''
-	echo "${P}:"
-	eval ${P}
-    done
-fi
-
 ##  All done
 if ${DAILY} ; then
     date >${PATHDB}/.news.daily

Modified: scanlogs.in
===================================================================
--- scanlogs.in	2009-11-11 10:34:53 UTC (rev 8736)
+++ scanlogs.in	2009-11-11 10:55:27 UTC (rev 8737)
@@ -266,12 +266,16 @@
 ##  and summarize syslog information.
 BASE=`basename ${SYSLOG_NOTICE}`
 OLD_SYSLOG=${OLD}/${BASE}.0
+INNREPORT=${TMPDIR}/innreport$$
 if [ -s ${OLD_SYSLOG} -o -s ${OLD_LOG} ] ; then
-    ${PATHBIN}/innreport -f ${PATHETC}/innreport.conf ${OLD_SYSLOG} ${OLD_LOG}
-    echo ---------
-    echo ''
+    ${PATHBIN}/innreport -f ${PATHETC}/innreport.conf ${OLD_SYSLOG} ${OLD_LOG} > ${INNREPORT}
+    if [ -s ${INNREPORT} ] ; then
+        cat ${INNREPORT}
+        echo ---------
+        echo ''
+    fi
 fi
-rm -f ${OLD_LOG} ${OLD_SYSLOG}
+rm -f ${OLD_LOG} ${OLD_SYSLOG} ${INNREPORT}
 
 ##  Now that innreport has finished, we can move unwanted.log.  This
 ##  file is not reset because it keeps the count of unwanted newsgroups.




More information about the inn-committers mailing list