Page 1 of 1

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

Posted: 2017-12-13 23:57
by jimimaseye
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?

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

Posted: 2017-12-14 01:20
by mattg
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

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

Posted: 2017-12-14 01:29
by mattg
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...

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

Posted: 2017-12-14 01:45
by jimimaseye

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

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

Posted: 2017-12-14 01:46
by jimimaseye
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.

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

Posted: 2017-12-14 02:45
by mattg
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

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

Posted: 2017-12-14 14:35
by SorenR

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

Posted: 2017-12-14 15:04
by jimimaseye
: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).