Subversion Repositories ALCASAR

Rev

Rev 2688 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2223 tom.houday 1
#!/bin/bash
1843 raphael.pi 2
 
2223 tom.houday 3
# Id: $Id: alcasar-url_filter_wl.sh 3263 2025-03-25 23:14:18Z rexy $
4
 
1843 raphael.pi 5
# alcasar-url_filter.sh
6
# by REXY
7
# This script is distributed under the Gnu General Public License (GPL)
8
 
9
# Active / désactive : safesearch des moteurs de recherche
10
# Enable / disable : search engines safesearch
11
 
2688 lucas.echa 12
CONF_FILE="/usr/local/etc/alcasar.conf"
1852 raphael.pi 13
IP_WL="/usr/local/share/iptables-wl-enabled/ossi-ip-safesearch"
1843 raphael.pi 14
SED="/bin/sed -i"
15
safesearch="Off"
16
usage="Usage: alcasar-url_filter_wl.sh { -safesearch_on or -safesearch_off }"
2648 lucas.echa 17
 
2688 lucas.echa 18
nb_args=$#
1843 raphael.pi 19
if [ $nb_args -le 0 ]
20
then
21
	echo "$usage"
2688 lucas.echa 22
	exit 1
23
fi
24
 
25
while [ $nb_args -ge 1 ]
26
do
27
	arg=${!nb_args}
28
	case $arg in
29
	-\? | -h* | --h*)
30
		echo "$usage"
31
		exit 0
32
		;;
33
	# Safe search activation
34
	-safesearch_on | --safesearch_on)
35
		safesearch="On"
36
		;;
37
	# Safe search desactivation
38
	-safesearch_off | --safesearch_off)
39
		safesearch="Off"
40
		;;
41
	*)
42
		echo "Argument inconnu : $arg";
43
		echo "$usage"
44
		exit 1
45
		;;
46
	esac
47
nb_args=$(expr $nb_args - 1)
48
done
49
 
50
if [ $safesearch == "On" ]
51
then
52
	[ -e $IP_WL ] && rm -f $IP_WL
3263 rexy 53
	# Before we wrote a special Unbound file with redirection. Ex. for google safesearching
54
	# google_safe_server=`host -ta forcesafesearch.google.com | grep "address" | cut -d" " -f4`	# retrieve google forcesafesearch ip
55
	# echo "server:" > $UNBOUND_BL_DOMAIN_FILTER_CONF
56
	# for domain in "google.com. google.ad. google.ae. google.com.af. google.com.ag. google.com etc."
57
	# do
58
	#	echo -e "\tlocal-zone: \"$domain\" redirect" >> $UNBOUND_BL_DOMAIN_FILTER_CONF
59
	#	echo -e "\tlocal-data: \"$domain A $google_safe_server\"" >> $UNBOUND_BL_DOMAIN_FILTER_CONF
60
	# done
61
	#
62
	# If enable again, add/remove "safe-searching" file in /etc/unbound/conf.d/whitelist (in this file, CNAME is used instead of REDIRECT)
2688 lucas.echa 63
	$SED 's/^WL_SAFESEARCH=.*/WL_SAFESEARCH=on/g' $CONF_FILE
64
else
65
	[ -e $IP_WL ] && rm -f $IP_WL
66
	$SED 's/^WL_SAFESEARCH=.*/WL_SAFESEARCH=off/g' $CONF_FILE
1843 raphael.pi 67
fi
2688 lucas.echa 68
systemctl restart unbound-whitelist