#!/bin/sh
#
# Sample script to update databases of domains to block
#
BLOCK="porn drugs religion sex/education sex/lingerie"
DB_DIR=/var/lib/squid/block

# blocklists:
# ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidGuard/contrib/blacklists.tar.gz
# http://www.shallalist.de/Downloads/shallalist.tar.gz
# http://cri.univ-tlse1.fr/blacklists/

tmpdir=$(mktemp -d)

for i in ${BLOCK}; do block_dirs+=BL/${i}' '; done
wget -q -O- http://www.shallalist.de/Downloads/shallalist.tar.gz | tar xzf - -C ${tmpdir} ${block_dirs} || exit 1

for i in ${BLOCK}; do
	sed 's/$/\n/g' ${tmpdir}/BL/${i}/domains | db_load -T -t hash "$DB_DIR"/$(echo ${i}|tr / _).db
done

# this signal makes squid_db reload the databases
pkill -HUP squid_db

rm -rf ${tmpdir}
