#!/bin/sh
#
#       update-squidguard  -  db update script for SquidGuard
#
#       Copyright 2003 Ivan E. Moore II <rkrusty at debian.org>
#       Copyright 2010 Joachim Wiedorn <ad_debian at joonet.de>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License version 2 as 
#       published by the Free Software Foundation.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

echo -n "Double checking directory and file permissions..."
chown -R proxy.proxy /var/lib/squidguard/db >/dev/null 2>&1
chmod 2770 /var/lib/squidguard/db >/dev/null 2>&1
echo "done!"

echo -n "Re-building SquidGuard db files..."
su - proxy -c "squidGuard -C all" >/dev/null 2>&1
su - proxy -c "squidGuard -u" >/dev/null 2>&1
echo "done!"

if [ -e /etc/init.d/squid3 ]; then
	echo -n "Reloading Squid3..."
	/etc/init.d/squid3 reload >/dev/null 2>&1
	echo "done!"
elif [ -e /etc/init.d/squid ]; then
	echo -n "Reloading Squid..."
	/etc/init.d/squid reload >/dev/null 2>&1
	echo "done!"
else
	echo "No init script found for reloading!"
fi

