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

Julian Field MailScanner at ecs.soton.ac.uk
Tue Sep 8 16:42:42 IST 2009



On 08/09/2009 16:14, Mark Sapiro wrote:
> 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)
>    
I added another line of output to it in the case where the backup 
restore succeeds, but otherwise mine is now basically the same as yours.

Thanks!

Jules

-- 
Julian Field MEng CITP CEng
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store

Need help customising MailScanner?
Contact me!
Need help fixing or optimising your systems?
Contact me!
Need help getting you started solving new requirements from your boss?
Contact me!

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
Follow me at twitter.com/JulesFM and twitter.com/MailScanner


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the MailScanner mailing list