Subversion Repositories ALCASAR

Rev

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

Rev 1912 Rev 1913
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1912 2016-05-29 13:18:17Z richard $
3
# $Id: alcasar-bl.sh 1913 2016-05-29 14:44:38Z 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 43... Line 43...
43
BL_SERVER="dsi.ut-capitole.fr"
43
BL_SERVER="dsi.ut-capitole.fr"
44
SED="/bin/sed -i"
44
SED="/bin/sed -i"
45
 
45
 
46
# enable/disable the BL & WL categories
46
# enable/disable the BL & WL categories
47
function cat_choice (){
47
function cat_choice (){
48
	# saving ossi category
-
 
49
	mkdir $DIR_tmp
48
	mkdir $DIR_tmp
50
	cp $DIR_IP_BL/ossi $DIR_tmp
-
 
51
	#ip BL ENABLE
49
	#ip BL ENABLE
52
	if [ -d $DIR_IP_BL_ENABLED ]
50
	if [ -d $DIR_IP_BL_ENABLED ]
53
	then
51
	then
54
		for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
52
		for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
55
		do
53
		do
56
			rm -f $DIR_IP_BL_ENABLED/$file
54
			rm -f $DIR_IP_BL_ENABLED/$file
57
		done
55
		done
58
	else
56
	else
59
		mkdir $DIR_IP_BL_ENABLED
57
		mkdir $DIR_IP_BL_ENABLED
60
		chown dansguardian:apache $DIR_IP_BL_ENABLED
58
		chown root:apache $DIR_IP_BL_ENABLED
61
		chmod g+w $DIR_IP_BL_ENABLED
59
		chmod 770 $DIR_IP_BL_ENABLED
62
	fi
60
	fi
63
	
-
 
64
	
61
 
65
	#dns BL ENABLED
62
	#dns BL ENABLED
66
	if [ -d $DIR_DNS_BL_ENABLED ]
63
	if [ -d $DIR_DNS_BL_ENABLED ]
67
	then
64
	then
68
		for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
65
		for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
69
		do
66
		do
70
			rm -f $DIR_DNS_BL_ENABLED/$file
67
			rm -f $DIR_DNS_BL_ENABLED/$file
71
		done
68
		done
72
	else
69
	else
73
		mkdir $DIR_DNS_BL_ENABLED
70
		mkdir $DIR_DNS_BL_ENABLED
74
		chown dansguardian:apache $DIR_DNS_BL_ENABLED
71
		chown root:apache $DIR_DNS_BL_ENABLED
75
		chmod g+w $DIR_DNS_BL_ENABLED
72
		chmod 770 $DIR_DNS_BL_ENABLED
76
	fi
73
	fi
77
	
-
 
78
	#ip WL ENABLE
74
	#dns BL ossi.conf 
79
	if [ -d $DIR_IP_WL ]
75
	if [ ! -e $DIR_DNS_BL/ossi.conf ]
80
	then
76
	then
-
 
77
		touch $DIR_DNS_BL/ossi.conf
81
		for file in `ls -1 $DIR_IP_WL | grep -v "^ossi*"`
78
		chown root:apache $DIR_DNS_BL/ossi.conf
82
		do
-
 
83
			rm -f $DIR_IP_WL/$file
79
		chmod g+w $DIR_DNS_BL/ossi.conf
84
		done
80
		if [ ! -e $DIR_DNS_BL_ENABLED/ossi ]
85
	else
81
		then
86
		mkdir $DIR_IP_WL
-
 
87
		chown dansguardian:apache $DIR_IP_WL
82
			ln -s $DIR_DNS_BL/ossi.conf $DIR_DNS_BL_ENABLED/ossi
88
		chmod g+w $DIR_IP_WL
83
		fi
89
	fi
84
	fi
90
	
85
 
91
	#ip WL ENABLE
86
	#ip WL ENABLE
92
	if [ -d $DIR_IP_WL_ENABLED ]
87
	if [ -d $DIR_IP_WL_ENABLED ]
93
	then
88
	then
94
		for file in `ls -1 $DIR_IP_WL_ENABLED | grep -v "^ossi*"`
89
		for file in `ls -1 $DIR_IP_WL_ENABLED | grep -v "^ossi*"`
95
		do
90
		do
96
			rm -f $DIR_IP_WL_ENABLED/$file
91
			rm -f $DIR_IP_WL_ENABLED/$file
97
		done
92
		done
98
	else
93
	else
99
		mkdir $DIR_IP_WL_ENABLED
94
		mkdir $DIR_IP_WL_ENABLED
100
		chown dansguardian:apache $DIR_IP_WL_ENABLED
-
 
101
		chmod g+w $DIR_IP_WL_ENABLED
-
 
102
		touch $DIR_IP_WL_ENABLED/ossi
95
		touch $DIR_IP_WL_ENABLED/ossi
103
		chown dansguardian:apache $DIR_IP_WL_ENABLED/ossi
96
		chown -R root:apache $DIR_IP_WL_ENABLED
-
 
97
		chmod 770 $DIR_IP_WL_ENABLED
104
		chmod g+w $DIR_IP_WL_ENABLED/ossi
98
		chmod g+w $DIR_IP_WL_ENABLED/ossi
105
	fi
99
	fi
106
 
100
 
107
	#dns WL ENABLED
101
	#dns WL ENABLED
108
	if [ -d $DIR_DNS_WL_ENABLED ]
102
	if [ -d $DIR_DNS_WL_ENABLED ]
Line 111... Line 105...
111
		do
105
		do
112
			rm -f $DIR_DNS_WL_ENABLED/$file
106
			rm -f $DIR_DNS_WL_ENABLED/$file
113
		done
107
		done
114
	else
108
	else
115
		mkdir $DIR_DNS_WL_ENABLED
109
		mkdir $DIR_DNS_WL_ENABLED
116
		chown dansguardian:apache $DIR_DNS_WL_ENABLED
110
		chown root:apache $DIR_DNS_WL_ENABLED
117
		chmod g+w $DIR_DNS_WL_ENABLED
111
		chmod 770 $DIR_DNS_WL_ENABLED
118
	fi
112
	fi
119
	
-
 
120
	#dns WL ossi.conf 
113
	#dns WL ossi.conf 
121
	if [ ! -e $DIR_DNS_WL/ossi.conf ]
114
	if [ ! -e $DIR_DNS_WL/ossi.conf ]
122
	then
115
	then
123
		touch $DIR_DNS_WL/ossi.conf
116
		touch $DIR_DNS_WL/ossi.conf
124
		chown dansguardian:apache $DIR_DNS_WL/ossi.conf
117
		chown root:apache $DIR_DNS_WL/ossi.conf
125
		chmod g+w $DIR_DNS_WL/ossi.conf
118
		chmod g+w $DIR_DNS_WL/ossi.conf
126
		if [ ! -e $DIR_DNS_WL_ENABLED/ossi ]
119
		if [ ! -e $DIR_DNS_WL_ENABLED/ossi ]
127
		then
120
		then
128
		ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
121
			ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
129
		fi
122
		fi
130
	fi
123
	fi
131
 
124
 
132
	# update categories with rsync
125
	# update categories with rsync
133
	if [ ! -e $DIR_CONF/update_cat.conf ]
126
	if [ ! -e $DIR_CONF/update_cat.conf ]
Line 200... Line 193...
200
		cat_choice
193
		cat_choice
201
		;;
194
		;;
202
	# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
195
	# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
203
	-adapt | --adapt)
196
	-adapt | --adapt)
204
		echo -n "Adaptation process of Toulouse University blackList. Please wait : "
197
		echo -n "Adaptation process of Toulouse University blackList. Please wait : "
205
		# keep custom files (ossi)
198
		# keep custom files (ossi) only when updating he BL
-
 
199
		if [ -d $DIR_IP_BL -a -d $DIR_IP_WL -a -d $DIR_DNS_BL -a -d $DIR_DNS_WL ]
-
 
200
		then
206
		for x in $(ls -1 $DIR_IP_BL | grep "^ossi*")
201
			for x in $(ls -1 $DIR_IP_BL | grep "^ossi*")
207
		do
202
			do
208
			mv $DIR_IP_BL/$x $tmp_DIR_IP_BL
203
				mv $DIR_IP_BL/$x $tmp_DIR_IP_BL
209
		done
204
			done
210
		for x in $(ls -1 $DIR_IP_WL | grep "^ossi*")
205
			for x in $(ls -1 $DIR_IP_WL | grep "^ossi*")
211
		do
206
			do
212
			mv $DIR_IP_WL/$x $tmp_DIR_IP_WL
207
				mv $DIR_IP_WL/$x $tmp_DIR_IP_WL
213
		done
208
			done
214
		for x in $(ls -1 $DIR_DNS_BL | grep "^ossi*")
209
			for x in $(ls -1 $DIR_DNS_BL | grep "^ossi*")
215
		do
210
			do
216
			mv $DIR_DNS_BL/$x $tmp_DIR_DNS_BL
211
				mv $DIR_DNS_BL/$x $tmp_DIR_DNS_BL
217
		done
212
			done
218
		for x in $(ls -1 $DIR_DNS_WL | grep "^ossi*")
213
			for x in $(ls -1 $DIR_DNS_WL | grep "^ossi*")
219
		do
214
			do
220
			mv $DIR_DNS_WL/$x $tmp_DIR_DNS_WL
215
				mv $DIR_DNS_WL/$x $tmp_DIR_DNS_WL
221
		done
216
			done
-
 
217
		fi
222
		if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
218
		if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
223
		then
219
		then
224
			rm -rf $DIR_DG_BL $DIR_IP_BL
220
			rm -rf $DIR_DG_BL $DIR_IP_BL
225
			mkdir $DIR_DG_BL $DIR_IP_BL
221
			mkdir $DIR_DG_BL $DIR_IP_BL
226
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
222
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/