Subversion Repositories ALCASAR

Rev

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

Rev 359 Rev 386
Line 1... Line 1...
1
#/bin/sh
1
#/bin/sh
2
# $Id: alcasar-bl.sh 359 2010-12-02 22:55:28Z richard $
2
# $Id: alcasar-bl.sh 386 2010-12-29 22:04:40Z franck $
3
 
3
 
4
# Script de gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via dansguardian)
4
# Script de gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via dansguardian)
5
# By 3abtux & rexy
5
# By 3abtux & rexy
6
 
6
 
7
DIR_tmp="/tmp/blacklists"
7
DIR_tmp="/tmp/blacklists"
Line 75... Line 75...
75
		ln -s $DIR_DNS_FILTER_AVAILABLE/$i.conf $DIR_DNS_FILTER_ENABLED/$i
75
		ln -s $DIR_DNS_FILTER_AVAILABLE/$i.conf $DIR_DNS_FILTER_ENABLED/$i
76
		# echo ".Include<$DIR_DANSGUARDIAN/blacklists/$i/domains>" >> $DIR_DANSGUARDIAN/bannedsitelist
76
		# echo ".Include<$DIR_DANSGUARDIAN/blacklists/$i/domains>" >> $DIR_DANSGUARDIAN/bannedsitelist
77
		echo ".Include<$DIR_DG_BL/$i/urls>" >> $DIR_DG/bannedurllist
77
		echo ".Include<$DIR_DG_BL/$i/urls>" >> $DIR_DG/bannedurllist
78
		done
78
		done
79
}
79
}
80
usage="Usage: alcasar-bl.sh -on | -off | -download| -reload"
80
usage="Usage: alcasar-bl.sh {-on or --on} | { -off or --off } | { -download or --download } | { -reload - --reload }"
81
nb_args=$#
81
nb_args=$#
82
args=$1
82
args=$1
83
if [ $nb_args -eq 0 ]
83
if [ $nb_args -eq 0 ]
84
then
84
then
85
	nb_args=1
85
	nb_args=1
Line 89... Line 89...
89
	-\? | -h* | --h*)
89
	-\? | -h* | --h*)
90
		echo "$usage"
90
		echo "$usage"
91
		exit 0
91
		exit 0
92
		;;
92
		;;
93
	# activation du filtrage
93
	# activation du filtrage
94
	-on)	
94
	-on | --on)	
95
		cat_choice
95
		cat_choice
96
		$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
96
		$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
97
		if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # on ne relance pas les processus d'une install
97
		if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # on ne relance pas les processus d'une install
98
		then
98
		then
99
		service dansguardian restart
99
		service dansguardian restart
100
		service dnsmasq restart
100
		service dnsmasq restart
101
		fi
101
		fi
102
		;;
102
		;;
103
	# désactivation du filtrage
103
	# désactivation du filtrage
104
	-off)
104
	-off | -off)
105
		rm -rf $DIR_DNS_FILTER_ENABLED/*
105
		rm -rf $DIR_DNS_FILTER_ENABLED/*
106
		$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
106
		$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
107
		if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # on ne relance pas les processus lors d'une install
107
		if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # on ne relance pas les processus lors d'une install
108
		then
108
		then
109
		service dansguardian restart
109
		service dansguardian restart
110
		service dnsmasq restart
110
		service dnsmasq restart
111
		fi
111
		fi
112
		;;
112
		;;
113
	# Mise a jour de la blacklist 'Toulouse' et adaptation à dansguardian et dnsmasq
113
	# Mise a jour de la blacklist 'Toulouse' et adaptation à dansguardian et dnsmasq
114
	-download)
114
	-download | --download)
115
		rm -rf /tmp/con_ok.html
115
		rm -rf /tmp/con_ok.html
116
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
116
		`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
117
		if [ ! -e /tmp/con_ok.html ]
117
		if [ ! -e /tmp/con_ok.html ]
118
		then
118
		then
119
			echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
119
			echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
Line 127... Line 127...
127
			rm -rf /tmp/con_ok.html
127
			rm -rf /tmp/con_ok.html
128
		fi
128
		fi
129
		adapt
129
		adapt
130
		;;		
130
		;;		
131
	# regénération suite à modification (choix catégories ou BL secondaire)
131
	# regénération suite à modification (choix catégories ou BL secondaire)
132
	-reload)
132
	-reload | --reload)
133
		adapt
133
		adapt
134
		# pour Dansguardian
134
		# pour Dansguardian
135
		chown -R dansguardian:apache $DIR_DG_BL/ossi
135
		chown -R dansguardian:apache $DIR_DG_BL/ossi
136
		chmod -R g+w $DIR_DG_BL/ossi
136
		chmod -R g+w $DIR_DG_BL/ossi
137
		cat_choice
137
		cat_choice