Subversion Repositories ALCASAR

Rev

Rev 1015 | Rev 1053 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1015 Rev 1042
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1015 2013-01-27 22:43:29Z richard $
3
# $Id: alcasar-bl.sh 1042 2013-03-10 17:56:30Z richard $
4
 
4
 
5
# alcasar-bl.sh
5
# alcasar-bl.sh
6
# by Franck BOUIJOUX and Richard REY
6
# by Franck BOUIJOUX and Richard REY
7
# This script is distributed under the Gnu General Public License (GPL)
7
# This script is distributed under the Gnu General Public License (GPL)
8
 
8
 
9
# Gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via Dansguardian)
9
# Gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via Dansguardian)
10
# Manage the BL for DnsBlackHole (dnsmasq) and URL filtering (Dansguardian)
10
# Manage the BL for DnsBlackHole (dnsmasq) and URL filtering (Dansguardian)
11
 
11
 
12
DIR_CONF="/usr/local/etc"
12
DIR_CONF="/usr/local/etc"
13
CONF_FILE="$DIR_CONF/alcasar.conf"
13
CONF_FILE="$DIR_CONF/alcasar.conf"
14
private_ip_mask=`grep PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
14
private_ip_mask=`grep PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
15
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
15
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
16
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1`			# ALCASAR LAN IP address
16
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1`			# ALCASAR LAN IP address
17
DIR_tmp="/tmp/blacklists"
17
DIR_tmp="/tmp/blacklists"
18
FILE_tmp="/tmp/filesfilter.txt"
18
FILE_tmp="/tmp/filesfilter.txt"
19
FILE_ip_tmp="/tmp/filesipfilter.txt"
19
FILE_ip_tmp="/tmp/filesipfilter.txt"
20
DIR_DG="/etc/dansguardian/lists"
20
DIR_DG="/etc/dansguardian/lists"
21
DIR_DG_BL="$DIR_DG/blacklists"
21
DIR_DG_BL="$DIR_DG/blacklists"
22
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories"				# list of names of the 	BL categories
22
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories"				# list of names of the 	BL categories
23
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#'	'		WL	'
23
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#'	'		WL	'
24
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled"		#	'	'	BL enabled categories
24
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled"		#	'	'	BL enabled categories
25
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled"		#	'	'	WL enabled categories
25
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled"		#	'	'	WL enabled categories
26
DIR_SHARE="/usr/local/share"
26
DIR_SHARE="/usr/local/share"
27
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl"					# all the BL in the DNSMASQ format
27
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl"					# all the BL in the DNSMASQ format
28
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl"					# all the WL	'	'	'
28
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl"					# all the WL	'	'	'
29
DIR_IP_BL="$DIR_SHARE/iptables-bl"					# all the IP addresses of the BL 
29
DIR_IP_BL="$DIR_SHARE/iptables-bl"					# all the IP addresses of the BL 
30
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled"			# symbolic link to the dnsmasq	BL (only enabled categories)
30
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled"			# symbolic link to the dnsmasq	BL (only enabled categories)
31
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled"			#	'	'	'	WL	'	'	'
31
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled"			#	'	'	'	WL	'	'	'
32
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled"			#	'	'	ip BL (only enabled categories)	
32
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled"			#	'	'	ip BL (only enabled categories)	
33
BL_SERVER="dsi.ut-capitole.fr"
33
BL_SERVER="dsi.ut-capitole.fr"
34
SED="/bin/sed -i"
34
SED="/bin/sed -i"
35
 
35
 
36
# enable/disable the BL categories
36
# enable/disable the BL & WL categories
37
function cat_choice (){
37
function cat_choice (){
38
	rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED # cleaning for dnsmasq and iptables
38
	rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED # cleaning for dnsmasq and iptables
39
	$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
39
	$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
40
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES # cleaning categories file (comment all lines)
40
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
41
	mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED 
41
	mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED 
42
	# process the file $BL_CATEGORIES with the choice of categories 
42
	# process the file $BL_CATEGORIES with the choice of categories 
43
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` 
43
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` 
44
	do
44
	do
45
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES 
45
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES 
46
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
46
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
47
		ln -s $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
47
		ln -s $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
48
		ln -s $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
48
		ln -s $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
49
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist  # we let DG filters domain in order to prevent bypass by proxy http vpn ;-)
49
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist  # we let DG filters domain in order to prevent bypass by proxy http vpn ;-)
50
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
50
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
51
	done
51
	done
52
	sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
52
	sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
53
	mv $FILE_tmp $BL_CATEGORIES
53
	mv $FILE_tmp $BL_CATEGORIES
-
 
54
	# process the file $WL_CATEGORIES with the choice of categories 
-
 
55
	for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED` 
-
 
56
	do
-
 
57
		$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES 
-
 
58
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
-
 
59
		ln -s $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
-
 
60
	done
-
 
61
	sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
-
 
62
	mv $FILE_tmp $WL_CATEGORIES
54
}
63
}
55
function bl_enable (){
64
function bl_enable (){
56
	$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
65
	$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
57
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
66
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
58
	then
67
	then
59
		service dansguardian restart
68
		service dansguardian restart
60
		service dnsmasq restart
69
		service dnsmasq restart
61
		/usr/local/bin/alcasar-iptables.sh
70
		/usr/local/bin/alcasar-iptables.sh
62
	fi
71
	fi
63
}
72
}
64
function bl_disable (){
73
function bl_disable (){
65
	rm -rf $DIR_DNS_BL_ENABLED/*
74
	rm -rf $DIR_DNS_BL_ENABLED/*
66
	$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
75
	$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
67
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
76
	if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
68
	then
77
	then
69
		service dansguardian restart
78
		service dansguardian restart
70
		service dnsmasq restart
79
		service dnsmasq restart
71
		/usr/local/bin/alcasar-iptables.sh
80
		/usr/local/bin/alcasar-iptables.sh
72
	fi
81
	fi
73
}
82
}
74
usage="Usage: alcasar-bl.sh {-on or --on} | { -off or --off } | { -download or --download } | { -reload or --reload }"
83
usage="Usage: alcasar-bl.sh {-on or --on} | { -off or --off } | { -download or --download } | { -reload or --reload }"
75
nb_args=$#
84
nb_args=$#
76
args=$1
85
args=$1
77
if [ $nb_args -eq 0 ]
86
if [ $nb_args -eq 0 ]
78
then
87
then
79
	DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
88
	DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
80
	DNS_FILTERING=${DNS_FILTERING:=off}
89
	DNS_FILTERING=${DNS_FILTERING:=off}
81
	echo "Set BlackList Filtering to $DNS_FILTERING"
90
	echo "Set BlackList Filtering to $DNS_FILTERING"
82
	if [ $DNS_FILTERING = on ]; then
91
	if [ $DNS_FILTERING = on ]; then
83
		cat_choice
92
		cat_choice
84
		bl_enable
93
		bl_enable
85
	else
94
	else
86
		bl_disable
95
		bl_disable
87
	fi
96
	fi
88
	exit 0
97
	exit 0
89
fi
98
fi
90
case $args in
99
case $args in
91
	-\? | -h* | --h*)
100
	-\? | -h* | --h*)
92
		echo "$usage"
101
		echo "$usage"
93
		exit 0
102
		exit 0
94
		;;
103
		;;
95
	# enable the filtering
104
	# enable the filtering
96
	-on | --on)	
105
	-on | --on)	
97
		cat_choice
106
		cat_choice
98
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=on?g" $CONF_FILE
107
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=on?g" $CONF_FILE
99
		bl_enable
108
		bl_enable
100
		;;
109
		;;
101
	# disable the filtering
110
	# disable the filtering
102
	-off | --off)
111
	-off | --off)
103
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=off?g" $CONF_FILE
112
		$SED "s?^DNS_FILTERING.*?DNS_FILTERING=off?g" $CONF_FILE
104
		bl_disable
113
		bl_disable
105
		;;
114
		;;
106
	# Retrieve Toulouse BL
115
	# Retrieve Toulouse BL
107
	-download | --download)
116
	-download | --download)
108
		rm -rf /tmp/con_ok.html
117
		rm -rf /tmp/con_ok.html
109
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
118
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
110
		if [ ! -e /tmp/con_ok.html ]
119
		if [ ! -e /tmp/con_ok.html ]
111
		then
120
		then
112
			echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
121
			echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
113
		else 
122
		else 
114
			rm -rf /tmp/con_ok.html $DIR_tmp
123
			rm -rf /tmp/con_ok.html $DIR_tmp
115
			mkdir $DIR_tmp
124
			mkdir $DIR_tmp
116
			wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
125
			wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
117
			md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
126
			md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
118
			chown -R apache:apache $DIR_tmp
127
			chown -R apache:apache $DIR_tmp
119
		fi
128
		fi
120
		;;		
129
		;;		
121
	# Adapt Toulouse BL to our structure (dnsmasq + DG)
130
	# Adapt Toulouse BL to our structure (dnsmasq + DG)
122
	-adapt | --adapt)
131
	-adapt | --adapt)
123
		echo -n "Toulouse BlackList migration process. Please wait : "
132
		echo -n "Toulouse BlackList migration process. Please wait : "
124
		if [ -f $DIR_tmp/blacklists.tar.gz ]
133
		if [ -f $DIR_tmp/blacklists.tar.gz ]
125
		then
134
		then
126
			[ -d $DIR_DG_BL/ossi ] && mv -f $DIR_DG_BL/ossi $DIR_tmp
135
			[ -d $DIR_DG_BL/ossi ] && mv -f $DIR_DG_BL/ossi $DIR_tmp
127
			rm -rf $DIR_DG_BL
136
			rm -rf $DIR_DG_BL
128
			mkdir $DIR_DG_BL
137
			mkdir $DIR_DG_BL
129
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
138
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
130
			[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DG_BL/
139
			[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DG_BL/
131
			rm -rf $DIR_tmp
140
			rm -rf $DIR_tmp
132
			chown -R dansguardian:apache $DIR_DG
-
 
133
			chmod -R g+w $DIR_DG
-
 
134
		fi
141
		fi
135
		rm -f $BL_CATEGORIES $WL_CATEGORIES 
142
		rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
136
		rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL
143
		rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL
137
		touch $BL_CATEGORIES $WL_CATEGORIES
144
		touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
138
		mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL
145
		mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL
-
 
146
		chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED
-
 
147
		chmod -R g+w $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED
139
		find $DIR_DG_BL/ -type f -name domains > $FILE_tmp # retrieve directory name where a domain file exist
148
		find $DIR_DG_BL/ -type f -name domains > $FILE_tmp # retrieve directory name where a domain file exist
140
		$SED "s?\/domains??g" $FILE_tmp # remove "/domains" suffix
149
		$SED "s?\/domains??g" $FILE_tmp # remove "/domains" suffix
141
		for dir_categorie in `cat $FILE_tmp` # create the blackist and the whitelist files
150
		for dir_categorie in `cat $FILE_tmp` # create the blacklist and the whitelist files
142
		do
151
		do
143
			categorie=`echo $dir_categorie|cut -d "/" -f6`
152
			categorie=`echo $dir_categorie|cut -d "/" -f6`
144
			categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
153
			categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
145
			if [ "$categorie_type" == "white" ]
154
			if [ "$categorie_type" == "white" ]
146
			then
155
			then
147
				echo "$dir_categorie" >> $WL_CATEGORIES 
156
				echo "$dir_categorie" >> $WL_CATEGORIES 
148
				echo "$dir_categorie" >> $WL_CATEGORIES_ENABLED  # by default all WL are enabled 
157
				echo `basename $dir_categorie` >> $WL_CATEGORIES_ENABLED  # by default all WL are enabled 
149
			else
158
			else
150
				echo "$dir_categorie" >> $BL_CATEGORIES
159
				echo "$dir_categorie" >> $BL_CATEGORIES
151
			fi
160
			fi
152
		done
161
		done
153
		rm -f $FILE_tmp
162
		rm -f $FILE_tmp
154
		# Creation of DNSMASQ BL and WL
163
		# Creation of DNSMASQ BL and WL
155
		for LIST in $BL_CATEGORIES $WL_CATEGORIES	# for each list (bl and wl)
164
		for LIST in $BL_CATEGORIES $WL_CATEGORIES	# for each list (bl and wl)
156
		do
165
		do
157
			for PATH_FILE in `cat $LIST` # for each category
166
			for PATH_FILE in `cat $LIST` # for each category
158
			do
167
			do
159
				DOMAINE=`basename $PATH_FILE`
168
				DOMAINE=`basename $PATH_FILE`
160
				echo -n "$DOMAINE, "
169
				echo -n "$DOMAINE, "
161
		  		if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
170
		  		if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
162
				then
171
				then
163
					touch $PATH_FILE/urls
172
					touch $PATH_FILE/urls
164
					chown dansguardian:apache $PATH_FILE/urls
173
					chown dansguardian:apache $PATH_FILE/urls
165
				fi
174
				fi
166
				$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
175
				$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
167
				# retrieve the ip addresses for iptables
176
				# retrieve the ip addresses for iptables
168
				egrep  "([0-9]{1,3}\.){3}[0-9]{1,3}" $PATH_FILE/domains > $FILE_ip_tmp
177
				egrep  "([0-9]{1,3}\.){3}[0-9]{1,3}" $PATH_FILE/domains > $FILE_ip_tmp
169
				# for dnsmask, remove IP addesses, accented characters and commented lines.
178
				# for dnsmask, remove IP addesses, accented characters and commented lines.
170
				egrep  -v "([0-9]{1,3}\.){3}[0-9]{1,3}" $PATH_FILE/domains > $FILE_tmp
179
				egrep  -v "([0-9]{1,3}\.){3}[0-9]{1,3}" $PATH_FILE/domains > $FILE_tmp
171
				$SED "/[äâëêïîöôüû]/d" $FILE_tmp
180
				$SED "/[äâëêïîöôüû]/d" $FILE_tmp
172
				$SED "/^#.*/d" $FILE_tmp
181
				$SED "/^#.*/d" $FILE_tmp
173
				# adapt to the dnsmasq syntax
182
				# adapt to the dnsmasq syntax
174
				$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp 
183
				$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp 
175
				if [ "$LIST" == "$BL_CATEGORIES" ]
184
				if [ "$LIST" == "$BL_CATEGORIES" ]
176
				then
185
				then
177
					mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
186
					mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
178
					mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
187
					mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
179
				else
188
				else
180
					mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
189
					mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
181
				fi
190
				fi
182
			done
191
			done
183
		done
192
		done
184
		rm -f $FILE_tmp $FILE_ip_tmp
193
		rm -f $FILE_tmp $FILE_ip_tmp
185
		echo
194
		echo
186
		;;
195
		;;
187
	# reload when categories are changed 
196
	# reload when categories are changed 
188
	-reload | --reload)
197
	-reload | --reload)
189
		# for DG
198
		# for DG
190
		chown -R dansguardian:apache $DIR_DG_BL/ossi
199
		chown -R dansguardian:apache $DIR_DG_BL/ossi
191
		chmod -R g+w $DIR_DG_BL/ossi
200
		chmod -R g+w $DIR_DG_BL/ossi
192
		cat_choice
201
		cat_choice
193
		#  for dnsmasq (noms de domaine réhabilités)
202
		#  for dnsmasq (rehabited domain names)
194
		if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
203
		if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
195
		then
204
		then
196
			for i in `cat $DIR_DG/exceptionsitelist`
205
			for i in `cat $DIR_DG/exceptionsitelist`
197
			do
206
			do
198
				$SED "/$i/d" $DIR_DNS_BL/*
207
				$SED "/$i/d" $DIR_DNS_BL/*
199
			done
208
			done
200
		fi
209
		fi
201
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
210
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
202
		$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
211
		$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
-
 
212
		cp -f $DIR_DG_BL/ossi/domains_wl $DIR_DNS_WL/ossi.conf
203
		DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
213
		DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
204
		DNS_FILTERING=${DNS_FILTERING:=off}
214
		DNS_FILTERING=${DNS_FILTERING:=off}
205
		if [ $DNS_FILTERING = on ]; then
215
		if [ $DNS_FILTERING = on ]; then
206
			bl_enable
216
			bl_enable
207
		else
217
		else
208
			bl_disable
218
			bl_disable
209
		fi
219
		fi
210
		;;
220
		;;
211
	*)
221
	*)
212
		echo "Argument inconnu :$1";
222
		echo "Argument inconnu :$1";
213
		echo "$usage"
223
		echo "$usage"
214
		exit 1
224
		exit 1
215
		;;
225
		;;
216
esac
226
esac
217
 
227
 
218
 
228