Tuesday, March 22, 2011

Squid Proxy Blacklist Auto Update Shell Script

Do necessary changes for path rest is self explanatory : 

cat Update_Blacklists

#! /bin/bash
if [ -d "/usr/local/squid/share/squidGuard"  ] ;then

    cd /usr/local/squid/share/squidGuard/
    rm -f -f bl.tar.gz
        mv /usr/local/squid/share/squidGuard/db/blacklists /usr/local/squid/share/squidGuard/db/blacklists.old
    wget -O bl.tar.gz http://ftp.tdcnorge.no/pub/www/proxy/squidGuard/contrib/blacklists.tar.gz

    tar --ungzip --extract --exclude=*.diff --directory=/usr/local/squid/share/squidGuard/db --verbose -f bl.tar.gz

    rm -f -f bl.tar.gz

    wget -O bl.tar.gz ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib/blacklists.tar.gz

    tar --ungzip --extract --exclude=*.diff --directory=/usr/local/squid/share/squidGuard/db --verbose -f bl.tar.gz

    rm -f -f bl.tar.gz

    chown -R squid:squid /usr/local/squid/share/squidGuard/db

    find /usr/local/squid/share/squidGuard/db   |xargs chmod 755
        rm -rf /usr/local/squid/share/squidGuard/db/blacklists/global_usage
    rm -rf /usr/local/squid/share/squidGuard/db/blacklists/README   

else
   echo "Error squid  may not be Installed "
       
fi

list_of_f=(`ls /usr/local/squid/share/squidGuard/db/blacklists`)
for ((  i = 0 ;  i < ${#list_of_f[*]};  i++  ))
    do
        serch=`ls /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]} |grep -w urls`
 if [ "$serch" == ""  ]; then

  echo " /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]} : urls not present "
  echo " So adding it : `touch /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]}/urls && echo "warex.com" >touch /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]}/urls`"
 else
  echo "hi $serch"
 fi

 serch1=`ls /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]} |grep -w domains`
        if [ "$serch1" == ""  ]; then

                echo " /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]} : domains not present "
  echo " So adding it : `touch /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]}/domains && echo " So adding it : `touch /usr/local/squid/share/squidGuard/db/blacklists/${list_of_f[i]}/domains`"`"
        else
                echo "hi $serch1"
        fi


done
chown -R squid:squid /usr/local/squid/share/squidGuard/db/*

        find /usr/local/squid/share/squidGuard/db/blacklists   |xargs chmod 755
        rm -rf /usr/local/squid/share/squidGuard/db/blacklists/global_usage
        rm -rf /usr/local/squid/share/squidGuard/db/blacklists/README

chmod 755 /usr/local/squid/share/squidGuard/squidGuard.conf

chmod -R 777 /usr/local/squid/share/squidGuard/db/blacklists

chmod -R 777 /usr/local/squid/share/squidGuard/log

#ind  /usr/local/squid/share/squidGuard/db/blacklists -type d -exec chmod 755 \{\} \; -print

chmod 777 /usr/local/squid/share/squidGuard/log


Best Regards

ChetanM

1 comment:

Squidblacklist said...

Hello, I was just reading this, and thought I would take the time to write a short note to inform you all that we offer blacklists tailored specifically for Squid proxy native acl, as well as alternative formats for the most widely used third party plugins. So we invite you all to check us out. We take a great deal of pride in the fact that our works offer a higher degree of quality than the freely available options. Our lists are also compatible with UrlFilterdb.

Quality Blacklists Tailored For Squid Proxy – http://www.squidblacklist.org