[Logcheck-commits] CVS logcheck/src

CVS User maks-guest logcheck-devel@lists.alioth.debian.org
Sat, 29 May 2004 01:44:53 -0600


Update of /cvsroot/logcheck/logcheck/src
In directory haydn:/tmp/cvs-serv24575/src

Modified Files:
	logcheck 
Log Message:

improve error checking (bugfixes):
*) remove -p mkdir switch inside of cleanrules,
   mkdir(8) states "no error if existing"
   bonus: only create that directory on the first run
   no need to call 4x times
*) your cat trick todd is far better, 
   previous checked failed on full partition.
   (was able to create file but not to append anything)


--- /cvsroot/logcheck/logcheck/src/logcheck	2004/05/28 10:09:03	1.42
+++ /cvsroot/logcheck/logcheck/src/logcheck	2004/05/29 07:44:53	1.43
@@ -22,7 +22,7 @@
 # along with Logcheck; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-# $Id: logcheck,v 1.42 2004/05/28 10:09:03 maks-guest Exp $
+# $Id: logcheck,v 1.43 2004/05/29 07:44:53 maks-guest Exp $
 
 
 # Set the umask
@@ -170,8 +170,10 @@
     cleaned=$2
 
     if [ -d $dir ]; then 
-	mkdir -p $cleaned \
-	    || error "Could not make dir $cleaned for cleaned rulefiles."
+        if [ ! -d $cleaned ]; then
+	    mkdir $cleaned \
+	        || error "Could not make dir $cleaned for cleaned rulefiles."
+	fi
 	for rulefile in $(run-parts --list $dir); do
 	    rulefile=$(basename $rulefile)
 	    if [ -f ${dir}/${rulefile} ]; then
@@ -267,11 +269,9 @@
     for grepfile in $(ls -1 $raise); do
 	debug "greplogoutput: $grepfile"
 
-	egrep --text -f $raise/$grepfile $TMPDIR/logoutput-sorted \
-	    > $TMPDIR/checked 
-	if [ ! -f $TMPDIR/checked ]; then
-	    error "Could not output to $TMPDIR/checked.  Disk Full?"
-	fi
+	egrep --text -f $raise/$grepfile $TMPDIR/logoutput-sorted | cat \
+	    > $TMPDIR/checked \
+	    || error "Could not output to $TMPDIR/checked.  Disk Full?"
 
 	if [ -s $TMPDIR/checked ]; then
 	    debug "greplogoutput: Entries in checked"