Category Archives: Bash Script

New DansGuardian Blacklist Update Script – by Brock M. Tice

DansguardianBrock M. Tice has generously taken the time to completely rewrite a new and superior update script for use with our blacklists and DansGuardian, and we have replaced the old script with this one, as there is essentially no use for the old one as this is far superior, and here it is.

 

It is also available for download compressed here.

 

#! /bin/bash
#
# DansGuardian Blacklist Updater Script v0.2 - Squidblacklist.org
# Thoughts or suggestions can be emailed to webmaster@squidblacklist.org
# 0.1->0.2 parameterization by Brock M. Tice
#
# Use this script to download and update blacklists for squid3 proxy
# You may need to edit this for your specific environment.
# you may optionaly wish to crontab this job so it will update at regular intervals
#
# Place this script within /etc/dansguardian/ directory
# Next, chmod +x squid-update.sh .That will make the script executable.
#
# nano /etc/crontab and add the following line
# 01 0 * * * root /etc/dansguardian/squid-update.sh
#
# Available ACLs:
#
# all
# prime
# malicious
# usg
# piracy
# porn
# dating
# ads
# proxies
# gaming
# smedia
# gambling
# cp
# blasphemy
# file
# image
# video
# pharma-rx
# new-tlds
# chanology
# dyn
# freeweb
# racism

# This is the base url for the lists -- do not edit
BASEURL=http://www.squidblacklist.org/downloads/squidblacklists/dg/

# Place the names of the sub-lists you want here, syntax enabled=( list1 list2 list3 ... listN )
enabled=( prime malicious piracy porn dating ads proxies gaming gambling cp pharma-rx chanology racism )

# squidblacklist.org username
USERNAME=userhere
PASSWORD=passhere
LISTBASE=/etc/dansguardian/lists/blacklists/

# enable dansguardian blacklist include line output
DGINCLUDEFILE=/etc/dansguardian/squidblacklist-includes.list
echo > "${DGINCLUDEFILE}"

echo Beginning squidblacklist.org Dansguardian Blacklist Update procedure... ;
cd /etc/dansguardian/ ;
echo Downloading blacklists...

# This loop uses the "enabled" list and the BASEURL to download, decompress, and move the list to the proper place for each specified list
# echos are temporary for testing
for listname in ${enabled[@]}; do
BASENAME="dg-${listname}"
wget --http-user="${USERNAME}" --http-password="${PASSWORD}" --auth-no-challenge "${BASEURL}${BASENAME}.tar.gz"
tar -xvf "${BASENAME}.tar.gz"
if [ ! -d "${LISTBASE}${listname}" ] && [ ! -f "${LISTBASE}${listname}" ]; then
mkdir -p "${LISTBASE}${listname}"
elif [ -f "${LISTBASE}${listname}" ]; then
printf "WARNING: Skipping list %s, %s already exists but is not a directory\n" "${listname}" "${LISTBASE}${listname}" >&2
continue
fi
mv "${BASENAME}.acl" "${LISTBASE}${listname}/domains"

# update include file
echo ".Include<${LISTBASE}${listname}/domains>" >> "${DGINCLUDEFILE}"

rm "${BASENAME}.tar.gz"
done

echo "Reloading Dansguardian Service... "
service dansguardian restart
echo "Done."

echo "If you have not already, add .Include<${DGINCLUDEFILE}> to your /etc/dansguardian/lists/bannedsitelist>"


Subscribe Today – Paypal or Credit Card Accepted.

Flat rate subscription. Select a membership option & subscribe.



Select Payment Option



  • You will be issued a username and password.
  • You will be granted access to our member area.
  • 5 Year Membership Option now available.
  • For lifetime membership options click here.clipart
  • Contact us if you would like a pre order invoice.

Disclaimer: All sales are final, we do not issue refunds. Cancel your subscription anytime.

How To Update Blacklists For DansGuardian – Update Script

I just tossed together a simple bash script for updating Blacklists from Squidblacklist.org for DansGuardian under GNU/Linux or I suppose any platform with a bash shell would suffice, it isnt really that sophisticated, it is rather crude and gets the job done.

The blacklist update script for DansGuardian can be downloaded here. Remember that a valid username and password will be required for basic http authentication. To download these files one must subscribe. Get your own username and password today by subscribing to Squidblacklist.org here..

Here is the blacklist update script in plain text form.


#! /bin/bash
#
# DansGuardian Blacklist Updater Script v0.1 - Squidblacklist.org
# Thoughts or suggestions can be emailed to webmaster@squidblacklist.org
# You will need to change the wget line with your user account for authentication
#
# EXAMPLE:
# wget --http-user=USERNAME --http-password=PASSHERE --auth-no-challenge http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-prime.tar.gz
#
# Use this script to download and update blacklists for squid3 proxy
# You may need to edit this for your specific environment.
# you may optionaly wish to crontab this job so it will update at regular intervals
#
# Create the directories you want
# EXAMPLE: 'mkdir /etc/dansguardian/lists/blacklists/porn'
#
# Place this script within /etc/dansguardian/ directory
# Next, chmod +x squid-update.sh .That will make the script executable.
#
# nano /etc/crontab and add the following line
# 01 0 * * * root /etc/dansguardian/dg-update.sh
#
# URLS for DG ACL blacklists Are listed below.
#
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-all.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-prime.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-malicious.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-usg.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-piracy.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-porn.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-dating.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-ads.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-proxies.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-gaming.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-smedia.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-gambling.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-cp.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-blasphemy.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-file.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-image.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-video.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-pharma-rx.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-new-tlds.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-chanology.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-dyn.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-freeweb.tar.gz
# http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-racism.tar.gz
#
# Happy Updating.

echo Beginning squidblacklist.org Dansguardian Blacklist Update procedure... ;
cd /etc/dansguardian/ ;
echo Downloading blacklists...
# Easy to download blacklists, decompress and move to the proper directory.
wget --http-user=USERNAME --http-password=PASSHERE --auth-no-challenge http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-porn.tar.gz ;
tar -xvf dg-porn.tar.gz ;
mv dg-porn.acl /etc/dansguardian/lists/blacklists/porn/domains ;
wget --http-user=USERNAME --http-password=PASSHERE --auth-no-challenge http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-ads.tar.gz ;
tar -xvf dg-ads.tar.gz ;
mv dg-ads.acl /etc/dansguardian/lists/blacklists/ads/domains ;
wget --http-user=USERNAME --http-password=PASSHERE --auth-no-challenge http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-malicious.tar.gz ;
tar -xvf dg-malicious.tar.gz ;
mv dg-malicious.acl /etc/dansguardian/lists/blacklists/malicious/domains ;
wget --http-user=USERNAME --http-password=PASSHERE --auth-no-challenge http://www.squidblacklist.org/downloads/squidblacklists/dg/dg-chanology.tar.gz ;
tar -xvf dg-chanology.tar.gz ;
mv dg-chanology.acl /etc/dansguardian/lists/blacklists/chanology/domains ;
echo Cleaning up temporary files... ;
rm *.tar.gz ;
echo Reloading Dansguardian Service... ;
service dansguardian stop ;
service dansguardian start ;
echo Done.


Subscribe Today – Paypal or Credit Card Accepted.

Flat rate subscription. Select a membership option & subscribe.



Select Payment Option



  • You will be issued a username and password.
  • You will be granted access to our member area.
  • 5 Year Membership Option now vvailable.
  • For lifetime membership options click here.clipart
  • Contact us if you would like a pre order invoice.

Disclaimer: All sales are final, we do not issue refunds. Cancel your subscription anytime.