summaryrefslogtreecommitdiff
blob: 72b89fcabce945fc7d31b7c05a5c8157c4654a67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-perl/Mail-SpamAssassin-Plugin-GoogleSafeBrowsing/files/update_google_safebrowsing.sh,v 1.1 2007/10/17 08:47:41 robbat2 Exp $
# This cron script updates the Google SafeBrowsing lists for the use of the
# Mail-SpamAssassin-Plugin-GoogleSafeBrowsing plugin.
# It should be run every 25-30 minutes! http://code.google.com/apis/safebrowsing/developers_guide.html#AcceptableUsage
CONFFILE="/etc/mail/spamassassin/24_google_safebrowsing.cf"
OUTDIR="$(awk '/^google_safebrowsing_dir/{print $2}' "${CONFFILE}")"
APIKEY="$(awk '/^google_safebrowsing_apikey/{print $2}' "${CONFFILE}")"
LISTS="$(awk '/^google_safebrowsing_blocklist/{printf "%s ",$2}' "${CONFFILE}")"
# Wait a little while, to avoid hammering the server
sleep $(($RANDOM % 120))
# Use LISTS unquoted!
for LIST in ${LISTS}; do
	blocklist_updater --apikey "$APIKEY" --blocklist ${LIST} --dbfile ${OUTDIR}/${LIST}-db
done