Subversion Repositories ALCASAR

Rev

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

Rev 2688 Rev 3195
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
 
2
 
3
# Id: $Id: alcasar-url_filter_bl.sh 2688 2019-01-18 23:15:49Z lucas.echard $
3
# Id: $Id: alcasar-url_filter_bl.sh 3195 2024-04-23 22:39:48Z rexy $
4
 
4
 
5
# alcasar-url_filter.sh
5
# alcasar-url_filter.sh
6
# by REXY
6
# by REXY
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 10... Line 10...
10
# Enable / disable : search engines safesearch
10
# Enable / disable : search engines safesearch
11
# Active / désactive : le filtrage des url contenant une adresse ip à la place d'un nom de domaine
11
# Active / désactive : le filtrage des url contenant une adresse ip à la place d'un nom de domaine
12
# Enable / disable : filter of urls containing ip address instead of domain name
12
# Enable / disable : filter of urls containing ip address instead of domain name
13
 
13
 
14
CONF_FILE="/usr/local/etc/alcasar.conf"
14
CONF_FILE="/usr/local/etc/alcasar.conf"
15
DIR_DG="/etc/e2guardian/lists"
15
DIR_DG_GROUP1="/etc/e2guardian/lists/group1"
16
UNBOUND_BL_DOMAIN_FILTER_CONF="/etc/unbound/conf.d/blacklist/domainfilter.conf"
16
UNBOUND_BL_DOMAIN_FILTER_CONF="/etc/unbound/conf.d/blacklist/domainfilter.conf"
17
SED="/bin/sed -i"
17
SED="/bin/sed -i"
18
safesearch="Off"
18
safesearch="Off"
19
pureip="Off"
19
pureip="Off"
20
usage="Usage: alcasar-url_filter_bl.sh { -safesearch_on or -safesearch_off } & { -pureip_on or -pureip_off }"
20
usage="Usage: alcasar-url_filter_bl.sh { -safesearch_on or -safesearch_off } & { -pureip_on or -pureip_off }"
Line 67... Line 67...
67
nb_args=$(expr $nb_args - 1)
67
nb_args=$(expr $nb_args - 1)
68
done
68
done
69
 
69
 
70
if [ "$safesearch" == "On" ]
70
if [ "$safesearch" == "On" ]
71
then
71
then
72
	$SED "s?^#\"?\"?g" $DIR_DG/urlregexplist # on décommente les lignes de regles
72
	$SED "s?^#\"?\"?g" $DIR_DG_GROUP1/urlregexplist # on décommente les lignes de regles
73
	# add 'SafeSearch' redirection for google searching
73
	# add 'SafeSearch' redirection for google searching
74
	google_safe_server=`host -ta forcesafesearch.google.com | grep "address" | cut -d" " -f4`	# retrieve google forcesafesearch ip
74
	google_safe_server=`host -ta forcesafesearch.google.com | grep "address" | cut -d" " -f4`	# retrieve google forcesafesearch ip
75
 
75
 
76
	# config file header
76
	# config file header
77
	echo "server:" > $UNBOUND_BL_DOMAIN_FILTER_CONF
77
	echo "server:" > $UNBOUND_BL_DOMAIN_FILTER_CONF
Line 101... Line 101...
101
	echo -e "\tlocal-data: \"api.qwant.com A $qwant_safe_server\"" >> $UNBOUND_BL_DOMAIN_FILTER_CONF
101
	echo -e "\tlocal-data: \"api.qwant.com A $qwant_safe_server\"" >> $UNBOUND_BL_DOMAIN_FILTER_CONF
102
 
102
 
103
	$SED 's/^BL_SAFESEARCH=.*/BL_SAFESEARCH=on/g' $CONF_FILE
103
	$SED 's/^BL_SAFESEARCH=.*/BL_SAFESEARCH=on/g' $CONF_FILE
104
elif [ "$safesearch" == "Off" ]
104
elif [ "$safesearch" == "Off" ]
105
then
105
then
106
	$SED "s?^[^#]?#&?g" $DIR_DG/urlregexplist
106
	$SED "s?^[^#]?#&?g" $DIR_DG_GROUP1/urlregexplist
107
	[ -e $UNBOUND_BL_DOMAIN_FILTER_CONF ] && rm -f $UNBOUND_BL_DOMAIN_FILTER_CONF
107
	[ -e $UNBOUND_BL_DOMAIN_FILTER_CONF ] && rm -f $UNBOUND_BL_DOMAIN_FILTER_CONF
108
 
108
 
109
	$SED 's/^BL_SAFESEARCH=.*/BL_SAFESEARCH=off/g' $CONF_FILE
109
	$SED 's/^BL_SAFESEARCH=.*/BL_SAFESEARCH=off/g' $CONF_FILE
110
fi
110
fi
111
 
111
 
112
if [ "$pureip" == "On" ]
112
if [ "$pureip" == "On" ]
113
then
113
then
114
	$SED "s/^\#\*ip$/*ip/g" $DIR_DG/bannedsitelist
114
	$SED "s/^\#\*ip$/*ip/g" $DIR_DG_GROUP1/bannedsitelist
115
	$SED "s/^\#\*ips$/*ips/g" $DIR_DG/bannedsitelist
115
	$SED "s/^\#\*ips$/*ips/g" $DIR_DG_GROUP1/bannedsitelist
116
 
116
 
117
	$SED 's/^BL_PUREIP=.*/BL_PUREIP=on/g' $CONF_FILE
117
	$SED 's/^BL_PUREIP=.*/BL_PUREIP=on/g' $CONF_FILE
118
elif [ "$pureip" == "Off" ]
118
elif [ "$pureip" == "Off" ]
119
then
119
then
120
	$SED "s/^\*ip$/#*ip/g" $DIR_DG/bannedsitelist
120
	$SED "s/^\*ip$/#*ip/g" $DIR_DG_GROUP1/bannedsitelist
121
	$SED "s/^\*ips$/#*ips/g" $DIR_DG/bannedsitelist
121
	$SED "s/^\*ips$/#*ips/g" $DIR_DG_GROUP1/bannedsitelist
122
 
122
 
123
	$SED 's/^BL_PUREIP=.*/BL_PUREIP=off/g' $CONF_FILE
123
	$SED 's/^BL_PUREIP=.*/BL_PUREIP=off/g' $CONF_FILE
124
fi
124
fi
125
systemctl restart e2guardian
125
systemctl restart e2guardian
126
systemctl restart unbound-blacklist
126
systemctl restart unbound-blacklist