less weekly-update-of-squidguard-database.md
SquidGuard DataBase: Weekly Update
# historical archive — written years ago, kept as it was. Some info is dated.
On some of my servers I installed Squid3 together with SquidGuard. This need arose because I set up a wi-fi hotspot. The hotspot and how it was built are another story that maybe one day we’ll get into. What interests us today, however, is answering the following question:
“Given that I have Squid3 and SquidGuard up and running, do I really have to update my blacklist DBs manually?”
Answer: “No, absolutely not — we can automate the process and forget about it 😉”
Here’s what I did, starting from a few assumptions:
- Squid3 is active and working;
- Thanks to SquidGuard, Squid3 blocks access to certain types of websites;
- To do its job, SquidGuard uses the Shalla’s Blacklists.
Now every week my server connects, downloads the updated blacklists and takes care of updating SquidGuard! All of this through a simple script to place in the /etc/cron.weekly folder of your Debian server. Use your favorite editor, copy and save the text below and remember to give execute permissions (a+x) to the file, please!!!
#!/bin/sh
LISTS="COPYRIGHT global_usage adv aggressive drugs hacking gamble porn redirector sex spyware violence warez"
SGDIRDB=/var/lib/squidguard/db/shalla/
echo downloading blacklist...
cd /var/tmp/
rm -rf BL
#wget -nv http://ftp.ost.eltele.no/pub/www/proxy/squidGuard/contrib/blacklists.tar.gz~
wget -nv "http://www.shallalist.de/Downloads/shallalist.tar.gz"
tar -zxf shallalist.tar.gz
cd BL
find . -perm 750 -exec chmod 2750 {} ;
chown -R proxy:proxy *
for dir in $LISTS; do cp -arf $dir $SGDIRDB; done
echo Updating SquidGuard
update-squidguard
echo Cleaning temp directory
rm -rf /var/tmp/BL
rm -rf /var/tmp/shallalist.tar.gz
echo Finished.
Here are a few explanations:
- The $LISTS variable takes care of identifying the categories of domains and urls to put on the blacklist;
- the $SGDIRDB variable identifies the directory where squidGuard will look for its DBs;
- update-squidguard takes care of updating the DBs and reloading squidGuard.
…the rest of the script is really simple and I don’t think it needs any further clarification.
Am I being too optimistic?!