Chris wrote:
On Monday 05 March 2007 12:08 am, Dennis Peterson wrote:

I ran it twice and both times it downloaded a new .hdb and .ndb file at
least the 'modified' times were within a couple of minutes of the current
time. I've commented out the
I just now realized you're moving the downloaded file to the ClamAV
working directory rather than copying it. By doing this you defeat one
of the truly great things about rsync - intelligent copies. For small
files this isn't a big deal but for for very large files rsync has to
download the entire thing even though it may have only changed in the
last few lines. I'll give you an example - stop me if you've heard this...

Dennis, being someone that is greatly lacking in the area of scripting, how should the script read to download just the changes?

# =========================================================
# Check for new DB files.  If new, download, test & process
# =========================================================
curl -R -s -z scam.ndb.gz -o $tmp_dir/scam.ndb.gz \
   http://www.sanesecurity.com/clamav/scam.ndb.gz
      test -s $tmp_dir/scam.ndb.gz && \
      gunzip -cdf $tmp_dir/scam.ndb.gz > $tmp_dir/scam.ndb && \
      mv -f $tmp_dir/scam.ndb.gz . && \
      clamscan --quiet -d $tmp_dir/scam.ndb && \
      cp --reply=yes scam.ndb scam.ndb-bak && \
      mv -f $tmp_dir/scam.ndb .

curl -R -s -z phish.ndb.gz -o $tmp_dir/phish.ndb.gz \
   http://www.sanesecurity.com/clamav/phish.ndb.gz
      test -s $tmp_dir/phish.ndb.gz && \
      gunzip -cdf $tmp_dir/phish.ndb.gz > $tmp_dir/phish.ndb && \
      mv -f $tmp_dir/phish.ndb.gz . && \
      clamscan --quiet -d $tmp_dir/phish.ndb && \
      cp --reply=yes phish.ndb phish.ndb-bak && \
      mv -f $tmp_dir/phish.ndb .

rsync -aq --files-from=/usr/local/bin/msrbl.list \
rsync://rsync.mirror.msrbl.com/msrbl/ /var/tmp/clamdb
# curl -R -s -z MSRBL-SPAM.ndb -o $tmp_dir/MSRBL-SPAM.ndb \
#    http://download.mirror.msrbl.com/MSRBL-SPAM.ndb
      test -s $tmp_dir/MSRBL-SPAM.ndb && \
      clamscan --quiet -d $tmp_dir/MSRBL-SPAM.ndb && \
      cp --reply=yes MSRBL-SPAM.ndb MSRBL-SPAM.ndb-bak && \
      mv -f $tmp_dir/MSRBL-SPAM.ndb .

# curl -R -s -z MSRBL-Images.hdb -o $tmp_dir/MSRBL-Images.hdb \
#    http://download.mirror.msrbl.com/MSRBL-Images.hdb
      test -s $tmp_dir/MSRBL-Images.hdb && \
      clamscan --quiet -d $tmp_dir/MSRBL-Images.hdb && \
      cp --reply=yes MSRBL-Images.hdb MSRBL-Images.hdb-bak && \
      mv -f $tmp_dir/MSRBL-Images.hdb .

I've included the whole download portion of the script including Steves.
Thanks for the assistance.

The mv -f ... statement should be a cp ... statement. That will leave the msrbl files in the directory that rsync uses for downloading and for comparing versions.

FWIW, you should probably do the same with Steve's gz file as well. By leaving it in the download directory, curl can determine if the file has changed or not, and if not it won't bother downloading an identical copy. You're already using the -c argument to gunzip which says don't modify the zip file when extracting. Same suggestion applies for folks who use wget - these tools are smart enough to not waste bandwidth if the previous copy is left in place to test.

If you use wget rather than curl you can grab both of Steve's files in one connection rather than two. I'll submit my script to Steve when I get caught up on things here. It pulls down Sanesecurity and MSRBL files.

dp
_______________________________________________
Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net
http://lurker.clamav.net/list/clamav-users.html

Reply via email to