Folks, Here's a script in between RulesDuJour and the one showin in this post in terms of complexity. I've been using it to update rulesets, and just added a bit of security checking for people who are interested. It was designed to run interactively, but could happily run out of cron with a | mail. It can trivally restart whatever you want at the end. It requires ksh and a relatively standard set of UNIX tools. And it uses GET.
Enjoy. David. ----- SNIP ----- #!/bin/ksh # # $Id: rules_update,v 1.8 2004-02-06 23:48:28-05 root Exp $ # # ------ # # Install directories # TMPDIR=/tmp RULEDIR=/etc/spamassassin # # Max changes to a ruleset before you get worried # MAXCHANGE=200 # # Timeout to HTTP GET in seconds. # TIMEOUT=10 # # Your rules here. # RULES=" http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf http://www.emtinc.net/includes/backhair.cf http://www.emtinc.net/includes/chickenpox.cf http://www.yackley.org/sa-rules/evilnumbers.cf " # # End of configuration # # -------------------- # # Meat begins here # if [[ ! -d $TMPDIR ]]; then print -u2 "No temporary directory $TMPDIR." exit 1 fi if [[ ! -d $RULEDIR ]]; then print -u2 "No rules directory $RULEDIR." exit 1 fi for RULE in $RULES; do RULENAME=${RULE##*/} rm -f $TMPDIR/.$RULENAME if [[ $? -ne 0 ]]; then print -u2 "Unable to remove exiting $TMPDIR/.$RULENAME - security hole! Exiting...." exit 1 fi # # Get it with a $TIMEOUT # print "Going after $RULENAME...." print " URL: $RULE" print -n " " GET -t $TIMEOUT $RULE > $TMPDIR/.$RULENAME 2> $TMPDIR/.$RULENAME.err if [[ $? = 0 ]]; then print "...got it!" if [[ ! -f $RULEDIR/$RULENAME ]]; then # # Just install it here # print " Fresh install of this rule." mv $TMPDIR/.$RULENAME $RULEDIR/$RULENAME if [[ $? -ne 0 ]]; then print "Install into $RULEDIR/$RULENAME failed (mv status $?)." exit 1 fi CHECK=1 else # # Check to see how different it is.... # SIZE=$( diff $TMPDIR/.$RULENAME $RULEDIR/$RULENAME | wc -l | awk '{print $1}' ) if [[ $SIZE -eq 0 ]]; then print " Skipping $RULENAME - no change." elif [[ $SIZE -gt 100 ]]; then print " $RULENAME has more than 100 changes ($SIZE) - please validate manually." print " $RULENAME in $TMPDIR/.$RULENAME for checking." else print " Updating $RULENAME - $SIZE or so changes." rm -f $RULEDIR/$RULENAME mv $TMPDIR/.$RULENAME $RULEDIR/$RULENAME if [[ $? -ne 0 ]]; then print "Install into $RULEDIR/$RULENAME failed (mv status $?)." exit 1 fi CHECK=1 fi fi else print "failed to get $RULENAME; error text in $TMPDIR/.$RULENAME.err." fi done # # Lint check # if [[ $CHECK -eq 1 ]]; then print -n "Lint checking rules..." spamassassin --lint > $TMPDIR/lint.out 2>&1 if [[ $? -ne 0 ]]; then print -u2 "WARNING: lint check failed. Output in $TMPDIR/lint.out" exit 1 fi print "looks good!" else print "No rules change, nothing to do." exit 0 fi # # Restart things here. # /etc/init.d/spamd restart ----- FINI ----- On Thu, 5 Feb 2004 [EMAIL PROTECTED] wrote: > Hi All, > Just like to say thanks to whoever wrote these scripts. i've majorly > simplified mine now with that loop... > > regards > M > > > ------------------ > #!/bin/sh > > files=" > http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf > http://www.merchantsoverseas.com/wwwroot/gorilla/99_FVGT_Tripwire.cf > http://www.emtinc.net/includes/backhair.cf > http://www.emtinc.net/includes/chickenpox.cf > http://www.emtinc.net/includes/weeds_2.cf > http://www.yackley.org/sa-rules/evilnumbers.cf > http://mywebpages.comcast.net/mkettler/sa/antidrug.cf > " > > cd /etc/mail/spamassassin > > for file in $files; do > if [ "$file" != "" ]; then > wget -Nv "$file" 2>&1 | grep saved > fi > done > > if [ $? = 0 ] ; then > /etc/init.d/MailScanner restart > fi > ----------------- > > -----Original Message----- > From: Jack L. Stone [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 05, 2004 8:53 AM > To: Andrew Ott; [EMAIL PROTECTED] > Subject: RE: Auto-download of *.cf files > > > At 02:50 PM 2.4.2004 -0700, Andrew Ott wrote: > > Check out the Rules Du Jour Script to auto download custom rule sets. > > > >http://www.exit0.us/index.php/RulesDuJour > > > > > >-----Original Message----- > >From: Evan Platt [mailto:[EMAIL PROTECTED] > >Sent: Wednesday, February 04, 2004 1:11 PM > >To: [EMAIL PROTECTED] > >Subject: Re: Auto-download of *.cf files > > > >-----Original Message----- > >From: "Carl Chipman" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Date: Wed, 4 Feb 2004 13:54:33 -0600 > >Subject: Auto-download of *.cf files > > > >> I remember some people talking about using a perl script to download > >> new cf files daily. > >> > >> Does anyone have a vb or javascript version of it? I'm loath to > >> install perl on my mailserver if there's already another version. > > > >Ditto on that - "Add me to your list". Or actually... I missed that thread. > >I have Perl, so if someone has that script (I missed that thread), please > >let me know! > > > >Thanks. > > > > Here's another than runs under Bourne shell (sh), a portion of which I got > from an earlier post. The interactive part after the LINTing could be > modified to use with cron because it will abort if not given a 'yes' within > 30 secs. A lot less code...... > > START----------------------------------------------------------- > #!/bin/sh > MOVE="bigevil.cf 99_FVGT_Tripwire.cf backhair.cf chickenpox.cf weeds_2.cf > evilnumbers.cf antidrug.cf" > > # List of files to grab > files=" > http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf > > http://www.merchantsoverseas.com/wwwroot/gorilla/99_FVGT_Tripwire.cf > http://www.emtinc.net/includes/backhair.cf > http://www.emtinc.net/includes/chickenpox.cf > http://www.emtinc.net/includes/weeds_2.cf > http://www.yackley.org/sa-rules/evilnumbers.cf > http://mywebpages.comcast.net/mkettler/sa/antidrug.cf > " > # Save backup of current set of rules > /bin/cp -fv ${MOVE} /usr/local/etc/mail/save > > # change to the spamassassin config directory > cd /usr/local/etc/mail/spamassassin > > # Grab all of the requested files > restart=0 > for file in $files; do > if [ "$file" != "" ]; then > wget -Nv "$file" 2>&1 | grep saved > # Do we want SA to restart? > if [ $? = 0 ]; then > restart=1 > fi > fi > done > > # Restart spamassassin > if [ $restart = 1 ] ; then > cd /usr/local/etc/mail/spamassassin > /usr/local/bin/spamassassin --lint > get_yes_no() { > while true > do > echo -n "$1 (Y/N) ? " > read -t 30 a > if [ $? != 0 ]; then > a="No"; > return; > fi > case $a in > [Yy]) a="Yes"; > return;; > [Nn]) a="No"; > return;; > *);; > esac > done > } > > get_yes_no "Do you want to continue......" > > [ $a = 'No' ] && exit 1 > > echo ".....starting NOW!............" > /usr/local/bin/spamass > echo "Restarted SpamAssassin" > fi > END----------------------------------------------------------- > > Best regards, > Jack L. Stone, > Administrator > > Sage American > http://www.sage-american.com > [EMAIL PROTECTED] > >
