Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 1395 2014-06-19 16:13:27Z richard $
|
3 |
# $Id: alcasar-bl.sh 1416 2014-07-22 17:12:07Z 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 49... |
Line 49... |
49 |
done
|
49 |
done
|
50 |
else
|
50 |
else
|
51 |
mkdir $DIR_IP_BL_ENABLED
|
51 |
mkdir $DIR_IP_BL_ENABLED
|
52 |
chown apache $DIR_IP_BL_ENABLED
|
52 |
chown apache $DIR_IP_BL_ENABLED
|
53 |
fi
|
53 |
fi
|
- |
|
54 |
if [ -d $DIR_DNS_BL_ENABLED ]
|
- |
|
55 |
then
|
- |
|
56 |
for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
|
- |
|
57 |
do
|
- |
|
58 |
rm -f $DIR_DNS_BL_ENABLED/$file
|
- |
|
59 |
done
|
- |
|
60 |
else
|
- |
|
61 |
mkdir $DIR_DNS_BL_ENABLED
|
- |
|
62 |
chown apache $DIR_DNS_BL_ENABLED
|
- |
|
63 |
fi
|
54 |
rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED # cleaning for dnsmasq and iptables
|
64 |
rm -rf $DIR_DNS_WL_ENABLED # cleaning for dnsmasq and iptables
|
55 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
65 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
56 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
66 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
57 |
mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED
|
67 |
mkdir $DIR_DNS_WL_ENABLED
|
58 |
# process the file $BL_CATEGORIES with the choice of categories
|
68 |
# process the file $BL_CATEGORIES with the choice of categories
|
59 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
69 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
60 |
do
|
70 |
do
|
61 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
71 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
62 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
72 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
Line 83... |
Line 93... |
83 |
}
|
93 |
}
|
84 |
function bl_enable (){
|
94 |
function bl_enable (){
|
85 |
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
|
95 |
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
|
86 |
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
|
96 |
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
|
87 |
then
|
97 |
then
|
88 |
service dansguardian restart
|
98 |
/bin/systemctl restart dansguardian
|
89 |
service dnsmasq restart
|
99 |
/bin/systemctl restart dnsmasq
|
90 |
service dnsmasq-blacklist restart
|
100 |
/bin/systemctl restart dnsmasq-blacklist
|
91 |
service dnsmasq-whitelist restart
|
101 |
/bin/systemctl restart dnsmasq-whitelist
|
92 |
/usr/local/bin/alcasar-iptables.sh
|
102 |
/usr/local/bin/alcasar-iptables.sh
|
93 |
fi
|
103 |
fi
|
94 |
}
|
104 |
}
|
95 |
function bl_disable (){
|
105 |
function bl_disable (){
|
96 |
rm -rf $DIR_DNS_BL_ENABLED/*
|
106 |
rm -rf $DIR_DNS_BL_ENABLED/*
|
Line 98... |
Line 108... |
98 |
$SED "/google/d" $DNSMASQ_BL_CONF # remove nosslsearch server
|
108 |
$SED "/google/d" $DNSMASQ_BL_CONF # remove nosslsearch server
|
99 |
$SED "s?^[^#]?#&?g" $DIR_DG/urlregexplist # remove safe searching
|
109 |
$SED "s?^[^#]?#&?g" $DIR_DG/urlregexplist # remove safe searching
|
100 |
$SED "s/^\*ip$/#*ip/g" $DIR_DG/bannedsitelist # remove pureip browsing
|
110 |
$SED "s/^\*ip$/#*ip/g" $DIR_DG/bannedsitelist # remove pureip browsing
|
101 |
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
|
111 |
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
|
102 |
then
|
112 |
then
|
103 |
service dansguardian restart
|
113 |
/bin/systemctl restart dansguardian
|
104 |
service dnsmasq restart
|
114 |
/bin/systemctl restart dnsmasq
|
105 |
service dnsmasq-blacklist restart
|
115 |
/bin/systemctl restart dnsmasq-blacklist
|
106 |
service dnsmasq-whitelist restart
|
116 |
/bin/systemctl restart dnsmasq-whitelist
|
107 |
/usr/local/bin/alcasar-iptables.sh
|
117 |
/usr/local/bin/alcasar-iptables.sh
|
108 |
fi
|
118 |
fi
|
109 |
}
|
119 |
}
|
110 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload }"
|
120 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload }"
|
111 |
nb_args=$#
|
121 |
nb_args=$#
|