Subversion Repositories ALCASAR

Rev

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

Rev 1852 Rev 1855
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1852 2016-05-01 18:46:46Z raphael.pion $
3
# $Id: alcasar-bl.sh 1855 2016-05-02 09:44:08Z raphael.pion $
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 22... Line 22...
22
DIR_DG_BL="$DIR_DG/blacklists"
22
DIR_DG_BL="$DIR_DG/blacklists"
23
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
24
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#'	'		WL	'
24
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories"				#'	'		WL	'
25
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
26
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
27
OSSI_DOMAINS_WL="$DIR_DG/blacklists/ossi/domains_wl"			# Domain names for the ossi category
-
 
28
DIR_SHARE="/usr/local/share"
27
DIR_SHARE="/usr/local/share"
29
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl"					# all the BL in the DNSMASQ format
28
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl"					# all the BL in the DNSMASQ format
30
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl"					# all the WL	'	'	'
29
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl"					# all the WL	'	'	'
31
DIR_IP_BL="$DIR_SHARE/iptables-bl"					# all the IP addresses of the BL 
30
DIR_IP_BL="$DIR_SHARE/iptables-bl"					# all the IP addresses of the BL 
32
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled"			# symbolic link to the domains BL (only enabled categories)
31
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled"			# symbolic link to the domains BL (only enabled categories)
Line 42... Line 41...
42
# enable/disable the BL & WL categories
41
# enable/disable the BL & WL categories
43
function cat_choice (){
42
function cat_choice (){
44
	# saving ossi category
43
	# saving ossi category
45
	mkdir $DIR_tmp
44
	mkdir $DIR_tmp
46
	cp $DIR_IP_BL/ossi $DIR_tmp
45
	cp $DIR_IP_BL/ossi $DIR_tmp
47
	
46
 
-
 
47
	if [ ! -e $DIR_DNS_WL/ossi.conf ]
-
 
48
	then
-
 
49
		touch $DIR_DNS_WL/ossi.conf
-
 
50
		chown apache $DIR_DNS_WL/ossi.conf
-
 
51
		ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
-
 
52
	fi
-
 
53
 
48
	if [ -d $DIR_IP_BL_ENABLED ]
54
	if [ -d $DIR_IP_BL_ENABLED ]
49
	then
55
	then
50
		for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
56
		for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
51
		do
57
		do
52
			rm -f $DIR_IP_BL_ENABLED/$file
58
			rm -f $DIR_IP_BL_ENABLED/$file
Line 247... Line 253...
247
				$SED "/$i/d" $DIR_DNS_BL/*
253
				$SED "/$i/d" $DIR_DNS_BL/*
248
			done
254
			done
249
		fi
255
		fi
250
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
256
		cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
251
		$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
257
		$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
252
		cp -f $OSSI_DOMAINS_WL $DIR_DNS_WL/ossi.conf
-
 
253
		$SED "s?.*?server=/&/$DNS1?g" $DIR_DNS_WL/ossi.conf
258
		$SED "s?.*?server=/&/$DNS1?g" $DIR_DNS_WL/ossi.conf
254
		ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
-
 
255
		
259
		
256
		/usr/bin/systemctl restart dnsmasq-blacklist
260
		/usr/bin/systemctl restart dnsmasq-blacklist
257
		/usr/bin/systemctl restart dnsmasq-whitelist
261
		/usr/bin/systemctl restart dnsmasq-whitelist
258
		/usr/local/bin/alcasar-iptables.sh
262
		/usr/local/bin/alcasar-iptables.sh
259
		;;
263
		;;