Subversion Repositories ALCASAR

Rev

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

Rev 3190 Rev 3193
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 3190 2024-04-07 22:35:03Z rexy $
3
# $Id: alcasar-bl.sh 3193 2024-04-21 22:33:19Z rexy $
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
 
Line 16... Line 16...
16
DIR_tmp="/tmp/blacklists"
16
DIR_tmp="/tmp/blacklists"
17
FILE_tmp="/tmp/filesfilter.txt"
17
FILE_tmp="/tmp/filesfilter.txt"
18
FILE_ip_tmp="/tmp/filesipfilter.txt"
18
FILE_ip_tmp="/tmp/filesipfilter.txt"
19
DIR_DG="/etc/e2guardian/lists"
19
DIR_DG="/etc/e2guardian/lists"
20
DIR_DG_BL="$DIR_DG/blacklists"
20
DIR_DG_BL="$DIR_DG/blacklists"
-
 
21
DIR_DG_GROUP1="$DIR_DG/group1"
21
GLOBAL_USAGE="$DIR_CONF/alcasar-global-usage"				# file containing the description of the lists
22
GLOBAL_USAGE="$DIR_CONF/alcasar-global-usage"				# file containing the description of the lists
22
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories"				# list of names of the 	BL categories
23
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories"				# list of names of the 	BL categories
23
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#	'	'	WL categories
24
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#	'	'	WL categories
24
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled"		#	'	'	BL enabled categories
25
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
26
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled"		#	'	'	WL enabled categories
Line 55... Line 56...
55
	then
56
	then
56
		touch $DIR_CONF/update_cat.conf
57
		touch $DIR_CONF/update_cat.conf
57
		chown root:apache $DIR_CONF/update_cat.conf
58
		chown root:apache $DIR_CONF/update_cat.conf
58
		chmod 660 $DIR_CONF/update_cat.conf
59
		chmod 660 $DIR_CONF/update_cat.conf
59
	fi
60
	fi
60
	$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
61
	$SED "/\.Include/d" $DIR_DG_GROUP1/bannedsitelist $DIR_DG_GROUP1/bannedurllist # cleaning for DG
61
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
62
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
62
 
63
 
63
	# process the file $BL_CATEGORIES with the choice of categories
64
	# process the file $BL_CATEGORIES with the choice of categories
64
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
65
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
65
	do
66
	do
66
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
67
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
67
		$SED "1i\/etc\/e2guardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
68
		$SED "1i\/etc\/e2guardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
68
		ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
69
		ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
69
		ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
70
		ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
70
		# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist  # Blacklisted domains are managed by unbound
71
		# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG_GROUP1/bannedsitelist  # Blacklisted domains are managed by unbound
71
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
72
		echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG_GROUP1/bannedurllist
72
	done
73
	done
73
	sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
74
	sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
74
	mv $FILE_tmp $BL_CATEGORIES
75
	mv $FILE_tmp $BL_CATEGORIES
75
	sort +0.0 -0.2 $BL_CATEGORIES_ENABLED -o $FILE_tmp
76
	sort +0.0 -0.2 $BL_CATEGORIES_ENABLED -o $FILE_tmp
76
	mv $FILE_tmp $BL_CATEGORIES_ENABLED
77
	mv $FILE_tmp $BL_CATEGORIES_ENABLED
Line 287... Line 288...
287
	-reload | --reload)
288
	-reload | --reload)
288
		# for E2Gardian
289
		# for E2Gardian
289
		cat_choice
290
		cat_choice
290
		#  for unbound (rehabilitated domain names)
291
		#  for unbound (rehabilitated domain names)
291
		rm -f $REHABILITATED_DNS_FILE
292
		rm -f $REHABILITATED_DNS_FILE
292
		if [ "$(wc -w $DIR_DG/exceptionsitelist | cut -d " " -f1)" != "0" ]
293
		if [ "$(wc -w $DIR_DG_GROUP1/exceptionsitelist | cut -d " " -f1)" != "0" ]
293
		then
294
		then
294
			touch $REHABILITATED_DNS_FILE
295
			touch $REHABILITATED_DNS_FILE
295
			while read -r domain; do
296
			while read -r domain; do
296
				[ -z "$domain" ] && continue
297
				[ -z "$domain" ] && continue
297
				echo "local-zone: $domain typetransparent" >> $REHABILITATED_DNS_FILE
298
				echo "local-zone: $domain typetransparent" >> $REHABILITATED_DNS_FILE
298
				echo "local-zone-tag: $domain \"\"" >> $REHABILITATED_DNS_FILE
299
				echo "local-zone-tag: $domain \"\"" >> $REHABILITATED_DNS_FILE
299
			done < $DIR_DG/exceptionsitelist
300
			done < $DIR_DG_GROUP1/exceptionsitelist
300
		fi
301
		fi
301
		# adapt OSSI BL & WL custom files
302
		# adapt OSSI BL & WL custom files
302
		for dir in $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED $DIR_IP_WL_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
303
		for dir in $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED $DIR_IP_WL_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
303
		do
304
		do
304
			rm -f $dir/ossi*
305
			rm -f $dir/ossi*