Subversion Repositories ALCASAR

Rev

Rev 313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 313 Rev 314
Line 1... Line 1...
1
#/bin/sh
1
#/bin/sh
2
# $Id: alcasar-bl.sh 313 2010-11-08 22:41:19Z richard $
2
# $Id: alcasar-bl.sh 314 2010-11-09 22:51:05Z richard $
3
 
3
 
4
# Script de gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via dansguardian)
4
# Script de gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via dansguardian)
5
# By 3abtux & rexy
5
# By 3abtux & rexy
6
 
6
 
7
DIR_tmp="/tmp/blacklists"
7
DIR_tmp="/tmp/blacklists"
Line 61... Line 61...
61
	$SED "/\.Include/d" $DIR_DANSGUARDIAN/bannedsitelist $DIR_DANSGUARDIAN/bannedurllist
61
	$SED "/\.Include/d" $DIR_DANSGUARDIAN/bannedsitelist $DIR_DANSGUARDIAN/bannedurllist
62
	# on adapte le fichier $BL_CATEGORIES au choix de catégorie 
62
	# on adapte le fichier $BL_CATEGORIES au choix de catégorie 
63
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES # on commente ce qui ne l'est pas
63
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES # on commente ce qui ne l'est pas
64
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
64
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
65
	do
65
	do
66
		$SED "/^.*$ENABLE_CATEGORIE/d" $BL_CATEGORIES
66
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
67
		$SED "1i\/etc\/dansguardian\/lists\/blacklist\/$ENABLE_CATEGORIE" $BL_CATEGORIES
67
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
68
	done
68
	done
69
	sort -o $FILE_tmp $BL_CATEGORIES 
69
	sort -k2n $BL_CATEGORIES > $FILE_tmp
70
	mv $FILE_tmp $BL_CATEGORIES
70
	mv $FILE_tmp $BL_CATEGORIES
71
	# on affecte les catégories à dansguardian et dnsmasq
71
	# on affecte les catégories à dansguardian et dnsmasq
72
	for i in `cat $BL_CATEGORIES_ENABLED`
72
	for i in `cat $BL_CATEGORIES_ENABLED`
73
		do
73
		do
74
		ln -s $DIR_DNS_FILTER_AVAILABLE/$i.conf $DIR_DNS_FILTER_ENABLED/$i
74
		ln -s $DIR_DNS_FILTER_AVAILABLE/$i.conf $DIR_DNS_FILTER_ENABLED/$i
Line 125... Line 125...
125
	-reload)
125
	-reload)
126
		# pour Dansguardian
126
		# pour Dansguardian
127
		chown -R dansguardian:apache $DIR_DANSGUARDIAN/blacklists/ossi
127
		chown -R dansguardian:apache $DIR_DANSGUARDIAN/blacklists/ossi
128
		chmod -R g+w $DIR_DANSGUARDIAN/blacklists/ossi
128
		chmod -R g+w $DIR_DANSGUARDIAN/blacklists/ossi
129
		cat_choice
129
		cat_choice
130
		service dansguardian reload
130
		service dansguardian restart
131
		# pour dnsmasq (noms de domaine réhabilités)
131
		# pour dnsmasq (noms de domaine réhabilités)
132
		if [ `wc -w $DIR_DANSGUARDIAN/exceptionsitelist|cut -d " " -f1` != "0" ]
132
		if [ `wc -w $DIR_DANSGUARDIAN/exceptionsitelist|cut -d " " -f1` != "0" ]
133
		then
133
		then
134
			for i in `cat $DIR_DANSGUARDIAN/exceptionsitelist`
134
			for i in `cat $DIR_DANSGUARDIAN/exceptionsitelist`
135
			do
135
			do
136
				$SED "/$i/d" $DIR_DNS_FILTER_AVAILABLE/*
136
				$SED "/$i/d" $DIR_DNS_FILTER_AVAILABLE/*
137
			done
137
			done
138
		fi
138
		fi
139
		cp -f $DIR_DANSGUARDIAN/blacklists/ossi/domains $DIR_DNS_FILTER_AVAILABLE/ossi.conf
139
		cp -f $DIR_DANSGUARDIAN/blacklists/ossi/domains $DIR_DNS_FILTER_AVAILABLE/ossi.conf
140
		$SED "s?.*?address=/&/$IP_RETOUR?g" $DIR_DNS_FILTER_AVAILABLE/ossi.conf
140
		$SED "s?.*?address=/&/$IP_RETOUR?g" $DIR_DNS_FILTER_AVAILABLE/ossi.conf
141
		service dnsmasq reload
141
		service dnsmasq restart
142
;;
142
;;
143
	*)
143
	*)
144
		echo "Argument inconnu :$1";
144
		echo "Argument inconnu :$1";
145
		echo "$usage"
145
		echo "$usage"
146
		exit 1
146
		exit 1