You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Michael Weber <mw...@alliednational.com> on 2004/04/08 23:24:31 UTC
A present for the SA community
Here's a script to automatically download your own set of cf files and
check them before putting them into production.
I'm not a shell script guru, trust me! But this script seems to do
what I wanted. It grabs all of RulesEmporium into a source directory,
puts only the files I want to run, one at a time, into the production
directory and runs lint on them. If the lint fails, it rolls the
ruleset back and tries the next ruleset. Finally it HUPs spamd.
If anyone cares to improve on my idea (shouldn't be hard) go for it.
I'm releasing it to the public under a "If you lilke it, you don't have
to send me any money, if it blows up your system don't send me any
blame" license.
Final warning: This was tested on my mail server and it worked.
Consider it alpha code. Don't just plug it in unless you can read
shell scripts and know what it's going to do.
Feedback is appreciated.
Here it is, with many thanks to the entire SA community for the
thousands of spams that never reached my users...
#!/bin/sh
# Script to get the latest rules from Chris Santerre's site...
# Released under the WYSIWYG license.
#
# "What You See Is What You Get". Do with it what you want, just
# don't complain to me if it blows up your system, turns your
# coffee maker off or starts WW3.
#
base=/etc/mail/spamassassin
RE_source=$base/RulesEmporium/www.rulesemporium.com/rules
source=$base/source
destination=$base
bad=$base/bad
archive=$base/archive
log=$base/update.log
# Insert any other sites here and put the .cf files in the $source
directory
# or list the files in the only_use.conf file
RE_site=http://www.rulesemporium.com/rules/
wget -q -r -I rules -A *.cf -w 3 $RE_site
# Let's keep the log file manageable
# kill this section if you would rather use logrotate
tail -100 $log > $log.short
rm -f $log
mv $log.short $log
# Empty out the source directory
rm -f $source/*
# If there is a "only_use.conf" file, it is a list of .cf files to use
# If the file doesn't exist, default to all files in the $source
folder
if [[ -f $base/only_use.conf ]]
then
for file in $(cat $base/only_use.conf)
do
if [[ -f $file ]]
then
cp $file $source
fi
done
else
cp $RE_source/*.cf $source
fi
spamassassin --lint
if (( $? > 0 ))
then
echo "Initial lint failed! Cannot continue with update." >>
$log
exit 1
fi
cd $source
for file in *
do
rm -f ${archive}/$file
mv ${destination}/$file ${archive}/$file
mv $file ${destination}/$file
spamassassin --lint >& $log.tmp
if (( $? > 0 ))
then
# If the file is non-zero size, there were errors
cat $log.tmp >> $log
echo "Lint failed, rolling back last change..." >>
$log
mv ${destination}/$file ${bad}/$file
mv ${archive}/$file ${destination}/$file
echo "Check ${bad}/$file for errors" >> $log
fi
done
# Restart the spamd daemon with the new config files
service spamassassin restart
Re: A present for the SA community
Posted by "Shaun T. Erickson" <st...@smxy.org>.
Michael Weber wrote:
> Here's a script to automatically download your own set of cf files and
> check them before putting them into production.
I don't mean to rain on your parade, but aren't you re-inventing the
wheel? Doesn't the rules_du_jour script already do this?
-ste