Subversion Repositories ALCASAR

Rev

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

Rev 1873 Rev 1874
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
 
2
 
3
# $Id: alcasar-bl.sh 1873 2016-05-05 10:31:32Z richard $
3
# $Id: alcasar-bl.sh 1874 2016-05-06 14:43:52Z 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 256... Line 256...
256
		echo
256
		echo
257
		;;
257
		;;
258
		#mise a jour d'une categorie avec rsync
258
		#mise a jour d'une categorie avec rsync
259
		-update_cat | --update_cat)
259
		-update_cat | --update_cat)
260
		
260
		
-
 
261
		if [ $(cat /usr/local/etc/update_cat.conf | wc -l) -ne 0 ]
-
 
262
		then
261
		echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
263
		echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
262
 
264
 
263
		
-
 
264
		for LIGNE_RSYNC in $(cat /usr/local/etc/update_cat.conf)
265
		cat /usr/local/etc/update_cat.conf | while read LIGNE_RSYNC
265
		do
266
		do
266
 
-
 
267
		$CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f0)
267
		CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
268
		$URL=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
268
		URL=$(echo $LIGNE_RSYNC | cut -d' ' -f2)
269
	
269
			
270
		PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
270
		PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
271
		echo "rsync -rv $URL $(dirname $PATH_FILE )" #rsync inside of the blacklist directory
271
		rsync -rv $URL $(dirname $PATH_FILE ) #rsync inside of the blacklist directory
272
		echo $PATH_FILE
-
 
273
		
272
		
274
		# Creation of DNSMASQ and Iptables BL and WL
273
		# Creation of DNSMASQ and Iptables BL and WL
275
		DOMAINE=$(basename $PATH_FILE)
274
		DOMAINE=$(basename $PATH_FILE)
276
		
275
 
-
 
276
		#correct some synthaxes
277
		$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
277
		$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls
278
		# extract ip addresses for iptables
278
		# extract ip addresses for iptables
279
		awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
279
		awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
280
		# for dnsmask, remove IP addesses, accented characters and commented lines.
280
		# for dnsmask, remove IP addesses, accented characters and commented lines.
281
		egrep  -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
281
		egrep  -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
282
		$SED "/[äâëêïîöôüû]/d" $FILE_tmp
282
		$SED "/[äâëêïîöôüû]/d" $FILE_tmp
Line 300... Line 300...
300
		
300
		
301
		/usr/bin/systemctl restart dnsmasq-whitelist
301
		/usr/bin/systemctl restart dnsmasq-whitelist
302
		/usr/bin/systemctl restart dnsmasq-blacklist
302
		/usr/bin/systemctl restart dnsmasq-blacklist
303
		/usr/bin/systemctl restart dansguardian
303
		/usr/bin/systemctl restart dansguardian
304
		/usr/local/bin/alcasar-iptables.sh
304
		/usr/local/bin/alcasar-iptables.sh
-
 
305
		else
-
 
306
		echo -n "/usr/local/etc/update_cat.conf is empty ..."
-
 
307
		fi
305
		
308
		
306
		echo "MAJ RSYNC réussie"
-
 
307
	
309
	
-
 
310
		echo 
308
		;;
311
		;;
309
	# reload when categories are changed 
312
	# reload when categories are changed 
310
	-reload | --reload)
313
	-reload | --reload)
311
		# for DG
314
		# for DG
312
		chown -R dansguardian:apache $DIR_DG_BL/ossi
315
		chown -R dansguardian:apache $DIR_DG_BL/ossi
Line 335... Line 338...
335
		;;
338
		;;
336
esac
339
esac
337
 
340
 
338
 
341
 
339
 
342
 
-
 
343