-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/12/2003 00:50,  Gary Smith wrote:

> I'm actually a windows guy who has been converting to linux for some
time so my scripting is rusty and primitive (cause that's what I know)
but it works.
>
> This came from my /etc/cron.hourly/bigevil.sh file.
>
> #!/bin/sh
> # This file updates the big evil policy file for spam assassin
> DATE=`date +"%Y%m%d-%H%M"`
> if [ -f bigevil.cf ]
> then
>         rm -f bigevil.cf
> fi
> if [ -f /tmp/bigevil.cf ]
> then
>         rm -f bigevil.cf
> fi
> wget -N http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf
<http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf>  \
>         -O /tmp/bigevil.cf \
>         2>&1 | grep -q 'saved'
> if [ $? = 0 ] ; then
>         cmp /tmp/bigevil.cf /etc/mail/spamassassin/bigevil.cf
>/dev/null 2>&1
>         if [ $? -ne 0 ]
>         then
>                 mv /etc/mail/spamassassin/bigevil.cf
/etc/mail/spamassassin/bigevil.cf.$DATE
>                 mv /tmp/bigevil.cf /etc/mail/spamassassin/bigevil.cf
>                 echo "BIG EVIL has changed on `hostname`.  The new
evil is `head -n 1 /etc/mail/spamassassin/bigevil.cf`" \
>                         | mutt [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  \
>                         -s "The big evil policy has been updated" -a
/etc/mail/spamassassin/bigevil.cf
>                 /etc/init.d/spamd restart > /dev/null 2>&1 /dev/null
>         #else
>                 #files are the same
>         fi
> fi
>
> I added some logic so I could keep a copy of the origial bigevil.cf
scipt in case I needed to roll back or something.
>

All this unix/linux stuff is great and one day I might get round to
setting up a mail server on linux.

At the moment I am running Mercury/32 on Windows 2000 Server and Gary's
script inspired me to write a vb script that could be run with the
scheduler to update the file as often as you want under Windows.

I'm just learning this stuff, so there are probably more elegent ways of
doing this, so if anyone can improve it, please do.

'*********************************************************
' VBScript to update bigevil.cf from Chris Santerre's website at:
' http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf
'
' This script requires the windows version of wget from:
' http://www.interlog.com/~tcharron/wgetwin.html
'
' This script also requires the windows version of recode from the
' Win32 Unix utilities that can be found at:
' http://wwweickel.in.tum.de/pub/sw/UnxUtils.html
'
' Copy wget.exe and recode.exe into the %SystemRoot%\system32 folder
'
'
' Edit the paths in the section "Paths to be edited" below to match
'your configuration.
' Also ensure you edit the path in the change format command towards
' the end of the script.
'
'*********************************************************
' Variables

Dim objFSO, objShell, objFile
Dim strFName
Dim strFtype
Dim strHour
Dim strMin
Dim strSec
Dim strYear
Dim strMonth
Dim strDay
Dim strNewFileName
Dim strSApath
Dim strSAbackup
Dim strBigName

' Creat FileSystemObject Object
Set objFSO = CreateObject("scripting.filesystemobject")

' Create WSH Shell Object
Set objShell = CreateObject("wscript.shell")

' Create the file name elements
strHour = Hour(Now)
strMin = Minute(Now)
strSec = Second(Now)
strYear = Year(Now)
strMonth = Month(Now)
strDay = Day(Now)
strFName = "bigevil_"
strFtype = ".cf"

' Create the Date and Time stamped file name
strNewFileName = strFName & strYear & strMonth & strDay & "_" & strHour
& strMin & strSec & strFtype


'*********************************************************
' Paths to be edited
strSApath = "d:\perl\etc\mail\spamassassin\"
strSAbackup = "d:\perl\etc\mail\backup\"


'*********************************************************
' Main


' Get the latest bigevil.cf file from Chris Santerre's site
    objShell.Run "cmd /c wget -N
http://www.merchantsoverseas.com/wwwroot/gorilla/bigevil.cf -O
c:\bigevil.cf"

' Don't continue until the Output file exists
    Do Until objFSO.FileExists("c:\bigevil.cf")
    WScript.Sleep 20000
    Loop

' Apply Date and Time stamped name to new bigevil.cf
    objFSO.MoveFile "c:\bigevil.cf", "c:\"+strNewFileName

' Make a backup of the current bigevil*.cf file in d:\perl\etc\mail\backup
    objFSO.CopyFile strSApath & "bigevil*.cf", strSAbackup

' Delete the current bigevil*.cf file in d:\perl\etc\mail\spamassassin
    objFSO.DeleteFile strSApath & "bigevil*.cf"

' Copy the new bigevil*.cf file to d:\perl\etc\mail\spamassassin\bigevil*.cf
    objFSO.CopyFile "c:\bigevil*.cf", strSApath

' Clean up C:\ for next time
    objFSO.DeleteFile "c:\bigevil*.cf"

' Change the format from Unix LF to PC CR-LF format
' Edit the path here to match your configuration
    objShell.Run "cmd /c recode -v -t ..MSDOS/CR-LF
d:\perl\etc\mail\spamassassin\bigevil*.cf"


'*********************************************************
' Clear Objects

Set objFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing

' End Script


- --
Regards
Barry


I used to have an open mind but my brains kept falling out.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3-nr1 (Windows XP)

iD8DBQE/0oPW3wKVPLs2unURAtdyAJ4pNTanFYNYl6X8Bsf5zoVYv00cbgCfUWFt
5VGNMVPMbwBbQoA6XyyM86A=
=EriQ
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to