Script/method to download and update an external .CF file

Use this forum for discussions about SpamAssassin and anti-spam in general.
Post Reply
User avatar
jimimaseye
Moderator
Moderator
Posts: 8132
Joined: 2011-09-08 17:48

Script/method to download and update an external .CF file

Post by jimimaseye » 2017-12-13 23:57

Im interested in this KAM.cf rules: http://www.pccc.com/downloads/SpamAssas ... rib/KAM.cf

However, the only method I have been offfered in updating it is for a unix box/bash shell script.

Anyone any ideas on how to implement a script or method to do a periodical check for updates of this file?
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 20143
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Script/method to download and update an external .CF file

Post by mattg » 2017-12-14 01:20

Can The Jam Variant have multiple .cf files?

If so just a script to periodically delete that file, download the new one, and restart SpamAssassin should work...I'd guess that even every few weeks would be OK
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
mattg
Moderator
Moderator
Posts: 20143
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Script/method to download and update an external .CF file

Post by mattg » 2017-12-14 01:29

I take that time frame back. He says he updates multiple times per day...

What are the details of the bash shell script? This may be able to be converted to a Windows shell script...
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8132
Joined: 2011-09-08 17:48

Re: Script/method to download and update an external .CF file

Post by jimimaseye » 2017-12-14 01:45

Code: Select all

#!/bin/sh
PATH=$PATH:/usr/local/bin
URL="http://www.peregrinehw.com/downloads/SpamAssassin/contrib/KAM.cf"
URL2="http://www.peregrinehw.com/downloads/SpamAssassin/contrib/nonKAMrules.cf"
PRODFILE="/usr/local/etc/mail/spamassassin/KAM.cf"
PRODFILE2="/usr/local/etc/mail/spamassassin/nonKAMrules.cf"
mkdir /tmp/KAM
cd /tmp/KAM
fetch -q ${URL}
RC=$?
if [ ${RC} -ne 0 ]; then
     cd /
     echo "NON-ZERO RC from fetch(1): " ${RC}
     rm -rf /tmp/KAM
     exit ${RC}
fi
fetch -q ${URL2}
RC=$?
if [ ${RC} -ne 0 ]; then
     cd /
     echo "NON-ZERO RC from fetch(1): " ${RC}
     rm -rf /tmp/KAM
     exit ${RC}
fi
diff -q ${PRODFILE} KAM.cf  >/dev/null 2>&1
RC=$?
diff -q ${PRODFILE2} nonKAMrules.cf  >/dev/null 2>&1
RC2=$?
 
case ${RC}${RC2} in
     00) ;;
     10 | 01 | 11 ) mv KAM.cf ${PRODFILE}
        mv nonKAMrules.cf ${PRODFILE2}
        /usr/local/bin/sa-compile
        kill -1 `cat /var/run/spamd/spamd.pid`
        cd `dirname ${PRODFILE}`
        git commit -a -m "KAM update `date '+%Y-%m-%d %H:%M'`"
        ;;
     20 | 02 | 22 ) echo "ISSUES WITH DIFF -- CHECK IT";;
esac
cd /
rm -rf /tmp/KAM
exit 0
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
jimimaseye
Moderator
Moderator
Posts: 8132
Joined: 2011-09-08 17:48

Re: Script/method to download and update an external .CF file

Post by jimimaseye » 2017-12-14 01:46

I don't km know how to download and place the cf from the website link. I know it's doable in vbs but need guidance.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 20143
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Script/method to download and update an external .CF file

Post by mattg » 2017-12-14 02:45

https://superuser.com/questions/25538/h ... et-or-curl
There is some powershell info there


Or a WGET for windows variant here >> http://gnuwin32.sourceforge.net/packages/wget.htm

Nice rules set - thanks for sharing
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
SorenR
Senior user
Senior user
Posts: 3191
Joined: 2006-08-21 15:38
Location: Denmark

Re: Script/method to download and update an external .CF file

Post by SorenR » 2017-12-14 14:35

SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

User avatar
jimimaseye
Moderator
Moderator
Posts: 8132
Joined: 2011-09-08 17:48

Re: Script/method to download and update an external .CF file

Post by jimimaseye » 2017-12-14 15:04

:mrgreen:

(Mind you, Ive decided just to take the MAILSPLOIT rule - Im ok with what I have from default rules. But will remember KAM.cf if it provides more use to me).
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply