Subversion Repositories ALCASAR

Rev

Rev 40 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
1 root 1
#/bin/sh
63 franck 2
# $Id: alcasar-bl.sh 63 2010-04-08 19:56:10Z franck $
3
 
1 root 4
# Gestion des Blacklists/Whitelists
5
 
6
DIR_tmp="/root/blacklists"
7
DIR_DANSGUARDIAN="/etc/dansguardian/lists/"
8
BL_SERVER="cri.univ-tlse1.fr"
9
SED="/bin/sed -i"
10
 
11
function transfert () {
12
	mkdir -p $DIR_tmp
13
	cd $DIR_tmp
14
	wget http://$BL_SERVER/blacklists/download/blacklists.tar.gz
15
}
16
 
17
function install () {
18
	[ -d $DIR_DANSGUARDIAN ] || mkdir -p $DIR_DANSGUARDIAN
19
	[ -d $DIR_DANSGUARDIAN/blacklists/ossi ] && mv -f $DIR_DANSGUARDIAN/blacklists/ossi $DIR_tmp
20
	tar zxvf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DANSGUARDIAN
21
	[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DANSGUARDIAN/blacklists/
22
	cd /root
23
	rm -rf $DIR_tmp
24
}
25
 
26
usage="Usage: alcasar-bl.sh -on | -off | -download| -reload"
27
nb_args=$#
28
args=$1
29
if [ $nb_args -eq 0 ]
30
then
31
	nb_args=1
32
	args="-h"
33
fi
34
case $args in
35
	-\? | -h* | --h*)
36
		echo "$usage"
37
		exit 0
38
		;;
39
	-on)	
40
		# activation du filtrage
41
		$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
42
		service dansguardian reload
43
		;;
44
	-off)
45
		# désactivation du filtrage
46
		$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
47
		service dansguardian reload
48
		;;
49
	-download)
50
		# Mise a jour de la blacklist 'Toulouse' et compilation de la base
51
		rm -rf /tmp/con_ok.html
52
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
53
		if [ ! -e /tmp/con_ok.html ]
54
		then
55
			echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
56
		else 
57
			transfert
58
			install
59
			chown -R dansguardian:apache $DIR_DANSGUARDIAN
60
			chmod -R g+w $DIR_DANSGUARDIAN
61
			service dansguardian reload
62
			DATE=`date '+%d %B %Y - %Hh%M'`
34 richard 63
			echo "Univ-tlse du $DATE " > /var/www/html/VERSION-BL
1 root 64
			rm -rf /tmp/con_ok.html
65
		fi
66
		;;		
67
	-reload)
68
		# regénération de la base OSSI/RSSI
69
		chown -R dansguardian:apache $DIR_DANSGUARDIAN/blacklists/ossi
70
		chmod -R g+w $DIR_DANSGUARDIAN/blacklists/ossi
71
		service dansguardian reload
72
		;;
73
	*)
74
		echo "Argument inconnu :$1";
75
		echo "$usage"
76
		exit 1
77
		;;
78
esac
79