Subversion Repositories ALCASAR

Rev

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

Rev 615 Rev 634
Line 1... Line 1...
1
#/bin/sh
1
#/bin/sh
2
# $Id: alcasar-bl.sh 615 2011-05-24 21:47:25Z richard $
2
# $Id: alcasar-bl.sh 634 2011-06-13 17:23:46Z 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
CONF_FILE="/usr/local/etc/alcasar.conf"
7
CONF_FILE="/usr/local/etc/alcasar.conf"
Line 11... Line 11...
11
DIR_DG_BL="$DIR_DG/blacklists"
11
DIR_DG_BL="$DIR_DG/blacklists"
12
BL_CATEGORIES="/usr/local/etc/alcasar-bl-categories"
12
BL_CATEGORIES="/usr/local/etc/alcasar-bl-categories"
13
BL_CATEGORIES_ENABLED="/usr/local/etc/alcasar-bl-categories-enabled"
13
BL_CATEGORIES_ENABLED="/usr/local/etc/alcasar-bl-categories-enabled"
14
DIR_DNS_FILTER_AVAILABLE="/usr/local/etc/alcasar-dnsfilter-available"
14
DIR_DNS_FILTER_AVAILABLE="/usr/local/etc/alcasar-dnsfilter-available"
15
DIR_DNS_FILTER_ENABLED="/usr/local/etc/alcasar-dnsfilter-enabled"
15
DIR_DNS_FILTER_ENABLED="/usr/local/etc/alcasar-dnsfilter-enabled"
16
IP_RETOUR="192.168.182.1"
16
IP_RETOUR="20.0.0.1"
17
BL_SERVER="cri.univ-tlse1.fr"
17
BL_SERVER="cri.univ-tlse1.fr"
18
SED="/bin/sed -i"
18
SED="/bin/sed -i"
19
# Récupération de l'archive de la BL Toulouse
19
# Récupération de l'archive de la BL Toulouse
20
function transfert () {
20
function transfert () {
21
	mkdir -p $DIR_tmp
21
	mkdir -p $DIR_tmp
Line 100... Line 100...
100
	$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
100
	$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
101
	$SED "s?^[^#]?#&?g" $DIR_DG/urlregexplist # Disable 'safesearch'
101
	$SED "s?^[^#]?#&?g" $DIR_DG/urlregexplist # Disable 'safesearch'
102
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
102
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
103
	then
103
	then
104
		service dansguardian restart
104
		service dansguardian restart
-
 
105
		service dnsmasq restart
105
		/usr/local/bin/alcasar-iptables.sh
106
		/usr/local/bin/alcasar-iptables.sh
106
	fi
107
	fi
107
}
108
}
108
usage="Usage: alcasar-bl.sh {-on or --on} | { -off or --off } | { -download or --download } | { -reload or --reload } | { -conf or --conf}"
109
usage="Usage: alcasar-bl.sh {-on or --on} | { -off or --off } | { -download or --download } | { -reload or --reload }"
109
nb_args=$#
110
nb_args=$#
110
args=$1
111
args=$1
111
if [ $nb_args -eq 0 ]
112
if [ $nb_args -eq 0 ]
112
then
113
then
-
 
114
	DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
-
 
115
	DNS_FILTERING=${DNS_FILTERING:=off}
-
 
116
	echo "Set BlackList Filtering to $DNS_FILTERING"
-
 
117
	if [ $DNS_FILTERING = on ]; then
-
 
118
		cat_choice
113
	nb_args=1
119
		bl_enable
114
	args="-h"
120
	else
-
 
121
		bl_disable
-
 
122
	fi
-
 
123
	exit 0
115
fi
124
fi
116
case $args in
125
case $args in
117
	-\? | -h* | --h*)
126
	-\? | -h* | --h*)
118
		echo "$usage"
127
		echo "$usage"
119
		exit 0
128
		exit 0
Line 127... Line 136...
127
	# désactivation du filtrage
136
	# désactivation du filtrage
128
	-off | --off)
137
	-off | --off)
129
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=off?g" $CONF_FILE
138
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=off?g" $CONF_FILE
130
		bl_disable
139
		bl_disable
131
		;;
140
		;;
132
	-conf | --conf)
-
 
133
		DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
-
 
134
		DNS_FILTERING=${DNS_FILTERING:=off}
-
 
135
		if [ $DNS_FILTERING = on ]; then
-
 
136
			cat_choice
-
 
137
			bl_enable
-
 
138
		else
-
 
139
			bl_disable
-
 
140
		fi
-
 
141
		;;	
-
 
142
	# Mise a jour de la blacklist 'Toulouse' et adaptation à dansguardian et dnsmasq
141
	# Mise a jour de la blacklist 'Toulouse' et adaptation à dansguardian et dnsmasq
143
	-download | --download)
142
	-download | --download)
144
		rm -rf /tmp/con_ok.html
143
		rm -rf /tmp/con_ok.html
145
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
144
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
146
		if [ ! -e /tmp/con_ok.html ]
145
		if [ ! -e /tmp/con_ok.html ]
Line 162... Line 161...
162
		adapt
161
		adapt
163
		# pour Dansguardian
162
		# pour Dansguardian
164
		chown -R dansguardian:apache $DIR_DG_BL/ossi
163
		chown -R dansguardian:apache $DIR_DG_BL/ossi
165
		chmod -R g+w $DIR_DG_BL/ossi
164
		chmod -R g+w $DIR_DG_BL/ossi
166
		cat_choice
165
		cat_choice
167
		service dansguardian restart
-
 
168
		# pour dnsmasq (noms de domaine réhabilités)
166
		# pour dnsmasq (noms de domaine réhabilités)
169
		if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
167
		if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
170
		then
168
		then
171
			for i in `cat $DIR_DG/exceptionsitelist`
169
			for i in `cat $DIR_DG/exceptionsitelist`
172
			do
170
			do
173
				$SED "/$i/d" $DIR_DNS_FILTER_AVAILABLE/*
171
				$SED "/$i/d" $DIR_DNS_FILTER_AVAILABLE/*
174
			done
172
			done
175
		fi
173
		fi
176
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_FILTER_AVAILABLE/ossi.conf
174
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_FILTER_AVAILABLE/ossi.conf
177
		$SED "s?.*?address=/&/$IP_RETOUR?g" $DIR_DNS_FILTER_AVAILABLE/ossi.conf
175
		$SED "s?.*?address=/&/$IP_RETOUR?g" $DIR_DNS_FILTER_AVAILABLE/ossi.conf
-
 
176
		DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
-
 
177
		DNS_FILTERING=${DNS_FILTERING:=off}
-
 
178
		if [ $DNS_FILTERING = on ]; then
-
 
179
			bl_enable
-
 
180
		else
178
		service dnsmasq restart
181
			bl_disable
-
 
182
		fi
179
		;;
183
		;;
180
	*)
184
	*)
181
		echo "Argument inconnu :$1";
185
		echo "Argument inconnu :$1";
182
		echo "$usage"
186
		echo "$usage"
183
		exit 1
187
		exit 1