Created
December 1, 2014 12:44
-
-
Save jaypeche/53149673b9c7cd6e2804 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Copyright 1999-2012 Gentoo Foundation | |
| # Distributed under the terms of the GNU General Public License v2 | |
| # $Header: https://raw.github.com/jaypeche/SquidGuarg_AU/master/SquidGuard_AU, v0.0.2 2012/06/24 16:53.23 jaypeche Exp $ | |
| DESCRIPTION="This script is used to update your SquidGuard database" | |
| HOMEPAGE="http://www.squidguard.org" | |
| SRC_URI="ftp://ftp.univ-tlse1.fr/blacklist" | |
| DATABASE="/etc/squidGuard/db/blacklists" | |
| CONFIGFILE="/etc/squidGuard/squidGuard.conf" | |
| SQUIDUSER="squid" | |
| SQUIDPID="/var/run/squid.pid" | |
| LOGFILE="/var/log/squidGuard" | |
| # Highlight colors | |
| MESG="\e[1;32m *\e[0;39m" | |
| WARN="\a\e[1;33m * WARNING:\e[0;39m" | |
| echo | |
| echo -e "$MESG ${DESCRIPTION}" | |
| echo -e "$MESG Look at \e[1;34m${HOMEPAGE} \e[0;39mfor more information" | |
| echo | |
| # Pre-processing tests | |
| [ $EUID != 0 ] && echo -e "$WARN This script must be run as root, exiting !" && exit 1 | |
| [ ! -f ${CONFIGFILE} ] && echo -e "$WARN The configuration file ${CONFIGFILE} does not exist !" && exit 1 | |
| [ ! -e ${SQUIDPID} ] && echo -e "$WARN Squid is not running !" && exit 1 | |
| for base in `awk '$1 == "dest" { print $2 }' ${CONFIGFILE} | sort` # Parse squidGuard config file | |
| do | |
| echo -e "$MESG Downloading the database ${base} ..." | |
| cd /tmp | |
| wget --continue --quiet --timeout=30 ${SRC_URI}/${base}.tar.gz | |
| if [ ! -e ${base}.tar.gz ]; then | |
| echo | |
| echo -e "$WARN The base \"${base}\" was not found on this server ..." | |
| echo " Please make your checks !" | |
| exit 1 | |
| fi | |
| tar -xvzf ${base}.tar.gz -C ${DATABASE} | |
| rm /tmp/${base}.tar.gz | |
| echo | |
| done | |
| echo -e "$MESG Generating database ... This could take a while, please wait ..." | |
| /usr/bin/squidGuard -C all || exit 1 | |
| echo -e "$MESG Checking permissions ..." | |
| chown -R ${SQUIDUSER}:${SQUIDUSER} ${DATABASE} | |
| chown -R ${SQUIDUSER}:${SQUIDUSER} ${LOGFILE} | |
| /etc/init.d/squid reload | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment