New feature: list of databases to exclude
1 files changed, 31 insertions(+), 4 deletions(-)

M fetch-sanesecurity-sigs
M fetch-sanesecurity-sigs +31 -4
@@ 11,7 11,7 @@ 
 # $Date$
 #
 # -----------------------------------------------------------------------------
-# Copyright (C) 2009 Malcolm Scott
+# Copyright (C) 2009-2011 Malcolm Scott
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License version 2 as published by the

          
@@ 70,6 70,12 @@ cache_dir="/var/cache/sanesecurity"
 # mirror)
 mirror="rsync://rsync.sanesecurity.net/sanesecurity"
 
+# Signatures we don't want, as a space-separated list
+# (If this is empty we will load all signatures available on the mirror.
+# See http://www.sanesecurity.co.uk/databases.htm for guidance on which
+# signatures to choose.)
+exclude="INetMsg-SpamDomains-2m.ndb winnow_phish_complete.ndb"
+
 # Extra options for rsync
 # The default, --contimeout=30, makes for faster recovery if a mirror is
 # blocking your connection (e.g. if you connect too frequently).  However

          
@@ 180,8 186,15 @@ fi
 # Update the cache
 if [ "$exclude_ldb" = "1" ]
 then
-	rsync_extra_opts="$rsync_extra_opts --exclude=*.ldb"
-	rm -f "$cache_dir"/*.ldb
+	exclude="$exclude *.ldb"
+fi
+if [ "$exclude" ]
+then
+	for i in $exclude
+	do
+		rsync_extra_opts="$rsync_extra_opts --exclude=$i --exclude=$i.*"
+		rm -vf "$cache_dir"/$i "$cache_dir"/$i.*
+	done
 fi
 if ! rsync --progress --delete -rt $rsync_extra_opts "$mirror/." "$cache_dir/"
 then

          
@@ 235,10 248,24 @@ do
 		installed=$((installed+1))
 
 		# Clean up stuff left behind by old scripts
-		rm -f "$clamd_dbdir/$db_name"*
+		rm -vf "$clamd_dbdir/$db_name"*
 	fi
 done
 
+# Clean up any databases which are now excluded but weren't previously
+if [ "$exclude" ]
+then
+	for i in $exclude
+	do
+		db_live="$clamd_dbdir/sanesecurity-$i"
+		if [ -f "$db_live" ]
+		then
+			rm -vf "$db_live"*
+			installed=$((installed+1))
+		fi
+	done
+fi
+
 # Finished; display summary and perhaps reload clamd
 echo
 if [ "$installed" -gt 0 ]