Rev 63 | Blame | Last modification | View Log
#/bin/sh
# $Id: alcasar-bl.sh 260 2010-09-16 21:32:38Z richard $
# Gestion des Blacklists/Whitelists
DIR_tmp="/root/blacklists"
DIR_DANSGUARDIAN="/etc/dansguardian/lists/"
BL_SERVER="cri.univ-tlse1.fr"
SED="/bin/sed -i"
function transfert () {
mkdir -p $DIR_tmp
cd $DIR_tmp
wget http://$BL_SERVER/blacklists/download/blacklists.tar.gz
}
function install () {
[ -d $DIR_DANSGUARDIAN ] || mkdir -p $DIR_DANSGUARDIAN
[ -d $DIR_DANSGUARDIAN/blacklists/ossi ] && mv -f $DIR_DANSGUARDIAN/blacklists/ossi $DIR_tmp
tar zxvf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DANSGUARDIAN
[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DANSGUARDIAN/blacklists/
cd /root
rm -rf $DIR_tmp
}
usage="Usage: alcasar-bl.sh -on | -off | -download| -reload"
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
then
nb_args=1
args="-h"
fi
case $args in
-\? | -h* | --h*)
echo "$usage"
exit 0
;;
-on)
# activation du filtrage
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
service dansguardian reload
/usr/local/bin/alcasar-dnsfilter-activate.sh
service dnsmasq restart
;;
-off)
# désactivation du filtrage
$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
service dansguardian reload
/usr/local/bin/alcasar-dnsfilter-activate.sh
service dnsmasq restart
;;
-download)
# Mise a jour de la blacklist 'Toulouse' et compilation de la base
rm -rf /tmp/con_ok.html
`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
if [ ! -e /tmp/con_ok.html ]
then
echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
else
transfert
install
chown -R dansguardian:apache $DIR_DANSGUARDIAN
chmod -R g+w $DIR_DANSGUARDIAN
service dansguardian reload
DATE=`date '+%d %B %Y - %Hh%M'`
echo "Univ-tlse du $DATE " > /var/www/html/VERSION-BL
rm -rf /tmp/con_ok.html
fi
;;
-reload)
# regénération de la base OSSI/RSSI
chown -R dansguardian:apache $DIR_DANSGUARDIAN/blacklists/ossi
chmod -R g+w $DIR_DANSGUARDIAN/blacklists/ossi
service dansguardian reload
;;
*)
echo "Argument inconnu :$1";
echo "$usage"
exit 1
;;
esac