Martin, > I do something similar on my SA rules development system (I also have SA > installed on this laptop but it is normally not running, which has the > side effect of disabling the standard Fedora sa-update cron job because > this won't run sa-update if it can't find the spamd daemon). My more > complex equivalent is a bash script rather than Perl which starts and > stops SA after a successful update in order to check that all is in > order. This is it. I think the use of the case...esac construct makes it > easier to read:
But you don't do a -lint before restarting SA: if an update was to break SA (like a big Perl syntax error in a rule, or you are working on a plugin on your production system, you feel safe because as long as you don't restart spamd, any bad modification you make will not break SA), you have stoppped the one that is currently working (and that could keep working despite the update) amd you find yourself trying to restart a broken version of SA. Best regards, Olivier > =========================================================================== > #!/bin/bash > # > # Update the Spamassassin rules > # > sau=/usr/bin/sa-update > > if [ -x $sau ] > then > $sau > err=$? > case $err in > 0) echo "Spamassassin rules update completed."; > service spamassassin restart; > service spamassassin stop; > echo "Spamassassin restarted and then stopped." ;; > > 1) echo "No Spamassassin rule updates available.";; > > 2) echo "Spamassassin rules updates available"; > echo "Site pre files lint check failed."; > echo "Fix the files and try again.";; > > *) echo "Spamassassin rules update failed: error=$err" > esac > else > echo "Error: $sau does not exist" > exit 0 > fi > =========================================================================== > >> And in any case, send myself an email if something went wrong. >> > I get the mail 'for free' because I run logwatch, which picks up > anything logged by crond (i.e. anything sent to stdout and stderr by a > cron job) and mails it to root and, of course, I set up the mail aliases > so mail sent to root is redirected to my usual login. > >> Being executed only once a day, the extra load of a Perl script is >> neglectible. >> > Agreed. > > > Martin > > > > --