Subversion Repositories ALCASAR

Rev

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

Rev 1914 Rev 1925
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1914 2016-05-29 15:36:09Z richard $
3
# $Id: alcasar-bl.sh 1925 2016-06-04 18:38: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 152... Line 152...
152
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
152
		$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
153
		ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
153
		ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
154
	done
154
	done
155
	sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
155
	sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
156
	mv $FILE_tmp $WL_CATEGORIES
156
	mv $FILE_tmp $WL_CATEGORIES
157
 
-
 
158
	# restoring ip files and ossi category BL/WL
-
 
159
	mv $DIR_tmp/ossi $DIR_IP_BL
-
 
160
	chown apache $DIR_IP_BL/ossi
-
 
161
	rm -rf $DIR_tmp
-
 
162
}
157
}
163
 
158
 
164
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
159
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
165
nb_args=$#
160
nb_args=$#
166
args=$1
161
args=$1
Line 193... Line 188...
193
		cat_choice
188
		cat_choice
194
		;;
189
		;;
195
	# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
190
	# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
196
	-adapt | --adapt)
191
	-adapt | --adapt)
197
		echo -n "Adaptation process of Toulouse University blackList. Please wait : "
192
		echo -n "Adaptation process of Toulouse University blackList. Please wait : "
198
		# keep custom files (ossi) only when updating he BL
193
		# keep custom files (ossi) 
199
		if [ -d $DIR_IP_BL -a -d $DIR_IP_WL -a -d $DIR_DNS_BL -a -d $DIR_DNS_WL ]
-
 
200
		then
-
 
201
			for x in $(ls -1 $DIR_IP_BL | grep "^ossi*")
194
		for x in $(ls -1 $DIR_DG_BL | grep "^ossi-*")
202
			do
195
		do
203
				mv $DIR_IP_BL/$x $tmp_DIR_IP_BL
196
			mv $DIR_DG_BL/$x $DIR_tmp
204
			done
-
 
205
			for x in $(ls -1 $DIR_IP_WL | grep "^ossi*")
-
 
206
			do
-
 
207
				mv $DIR_IP_WL/$x $tmp_DIR_IP_WL
-
 
208
			done
-
 
209
			for x in $(ls -1 $DIR_DNS_BL | grep "^ossi*")
-
 
210
			do
-
 
211
				mv $DIR_DNS_BL/$x $tmp_DIR_DNS_BL
-
 
212
			done
-
 
213
			for x in $(ls -1 $DIR_DNS_WL | grep "^ossi*")
-
 
214
			do
-
 
215
				mv $DIR_DNS_WL/$x $tmp_DIR_DNS_WL
-
 
216
			done
197
		done
217
		fi
-
 
218
		if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
198
		if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
219
		then
199
		then
220
			rm -rf $DIR_DG_BL $DIR_IP_BL
200
			rm -rf $DIR_DG_BL $DIR_IP_BL
221
			mkdir $DIR_DG_BL $DIR_IP_BL
201
			mkdir $DIR_DG_BL $DIR_IP_BL
222
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
202
			tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
223
		fi
203
		fi
-
 
204
		# Retrieve custom files (ossi)
-
 
205
		for x in $(ls -1 $DIR_tmp | grep "^ossi-*")
-
 
206
		do
-
 
207
			mv $DIR_tmp/$x $DIR_DG_BL
-
 
208
		done
-
 
209
 
224
		rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
210
		rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
225
		rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
211
		rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
226
		touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
212
		touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
227
		mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
213
		mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
228
		chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
214
		chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL