Suggested change to http://www.mailscanner.info/files/4/KAM.cf.sh script

Mark Sapiro mark at msapiro.net
Tue Sep 8 16:14:34 IST 2009


Julian Field wrote!
>
>I basically like it. You've got 2 small problems
>1) The "if [ reload ==1 ]; then" line should of course read "if [ 
>"$reload" = "1" ]; then"
>(i.e. you mean "=" for comparing strings (though == does appear to work, 
>it's not documented in test(1)), and you missed the "$" off the front of 
>$reload which is rather more critical! :-)


Ouch! Obviously a case of sloppy coding plus inadequate testing (only
testing the case where it was intended not to reload.


>2) What happens if the downloaded file is bad and you haven't already 
>got a backup of it?
>I have solved that one by deleting the downloaded file in that case.


Again, this is clearly more robust than mine, but what about the case
where wget fails and there is no backup? Consider

@@ -51,7 +51,14 @@
   fi
 else
   echo It failed to complete properly
-  cp -f KAM.cf.backup KAM.cf
+  if [ -r KAM.cf.backup ]; then
+    cp -f KAM.cf.backup KAM.cf
+  else
+    # No backup file present, so delete file if any
+    echo ERROR: wget of KAM.cf failed and no backup
+    rm -f KAM.cf
+    reload=0
+  fi
 fi

 # Reload MailScanner only if we need to.

(patched file attached)


-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: KAM.cf.sh.zip
Type: application/x-zip-compressed
Size: 914 bytes
Desc: not available
Url : http://lists.mailscanner.info/pipermail/mailscanner/attachments/20090908/9fb269b2/KAM.cf.sh.bin


More information about the MailScanner mailing list