Subversion Repositories ALCASAR

Rev

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

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