Subversion Repositories ALCASAR

Rev

Rev 1390 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1390 Rev 1393
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1390 2014-06-17 12:37:37Z richard $
3
# $Id: alcasar-bl.sh 1393 2014-06-19 08:44:51Z 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
 
Line 36... Line 36...
36
BL_SERVER="dsi.ut-capitole.fr"
36
BL_SERVER="dsi.ut-capitole.fr"
37
SED="/bin/sed -i"
37
SED="/bin/sed -i"
38
 
38
 
39
# enable/disable the BL & WL categories
39
# enable/disable the BL & WL categories
40
function cat_choice (){
40
function cat_choice (){
41
	# saving ip files and ossi category
41
	# saving ossi category
42
	mkdir $DIR_tmp
42
	mkdir $DIR_tmp
-
 
43
	cp $DIR_IP_BL/ossi $DIR_tmp
43
	if [ $(find $DIR_IP_BL_ENABLED -name "ossi-*" | wc -l) -ne 0 ]
44
	if [ -d $DIR_IP_BL_ENABLED ]
44
	then
45
	then
-
 
46
		for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
-
 
47
		do
45
		cp $DIR_IP_BL_ENABLED/ossi-* $DIR_tmp
48
			rm -f $DIR_IP_BL_ENABLED/$file
-
 
49
		done
-
 
50
	else
-
 
51
		mkdir $DIR_IP_BL_ENABLED
-
 
52
		chown apache $DIR_IP_BL_ENABLED
46
	fi
53
	fi
47
	cp $DIR_IP_BL/ossi $DIR_tmp
-
 
48
	rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED # cleaning for dnsmasq and iptables
54
	rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED # cleaning for dnsmasq and iptables
49
	$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
55
	$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
50
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
56
	$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
51
	mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED
57
	mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED
52
	chown apache $DIR_IP_BL_ENABLED
-
 
53
	# process the file $BL_CATEGORIES with the choice of categories 
58
	# process the file $BL_CATEGORIES with the choice of categories 
54
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` 
59
	for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` 
55
	do
60
	do
56
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES 
61
		$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES 
57
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
62
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
Line 72... Line 77...
72
	sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
77
	sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
73
	mv $FILE_tmp $WL_CATEGORIES
78
	mv $FILE_tmp $WL_CATEGORIES
74
	# restoring ip files and ossi category
79
	# restoring ip files and ossi category
75
	mv $DIR_tmp/ossi $DIR_IP_BL
80
	mv $DIR_tmp/ossi $DIR_IP_BL
76
	chown apache $DIR_IP_BL/ossi
81
	chown apache $DIR_IP_BL/ossi
77
	if [ $(find $DIR_tmp -name "ossi-*" | wc -l) -ne 0 ]
-
 
78
	then
-
 
79
		mv $DIR_tmp/ossi-* $DIR_IP_BL_ENABLED
-
 
80
	fi
-
 
81
	rm -rf $DIR_tmp
82
	rm -rf $DIR_tmp
82
}
83
}
83
function bl_enable (){
84
function bl_enable (){
84
	$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
85
	$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
85
	if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
86
	if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage