Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 2441 2017-11-21 14:41:17Z franck $
|
3 |
# $Id: alcasar-bl.sh 2454 2017-12-09 18:59:31Z tom.houdayer $
|
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 25... |
Line 25... |
25 |
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled" # ' ' BL enabled categories
|
25 |
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled" # ' ' BL enabled categories
|
26 |
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled" # ' ' WL enabled categories
|
26 |
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled" # ' ' WL enabled categories
|
27 |
DIR_SHARE="/usr/local/share"
|
27 |
DIR_SHARE="/usr/local/share"
|
28 |
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl" # all the BL in the DNSMASQ format
|
28 |
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl" # all the BL in the DNSMASQ format
|
29 |
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl" # all the WL ' ' '
|
29 |
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl" # all the WL ' ' '
|
30 |
DIR_IP_BL="$DIR_SHARE/iptables-bl" # all the IP addresses of the BL
|
30 |
DIR_IP_BL="$DIR_SHARE/iptables-bl" # all the IP addresses of the BL
|
31 |
DIR_IP_WL="$DIR_SHARE/iptables-wl" # IP ossi disabled WL
|
31 |
DIR_IP_WL="$DIR_SHARE/iptables-wl" # IP ossi disabled WL
|
32 |
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the domains BL (only enabled categories)
|
32 |
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the domains BL (only enabled categories)
|
33 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' '
|
33 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' '
|
34 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
34 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
35 |
DIR_IP_WL_ENABLED="$DIR_SHARE/iptables-wl-enabled" # ' ' ip WL (ossi and ossi-* imported from ACC)
|
35 |
DIR_IP_WL_ENABLED="$DIR_SHARE/iptables-wl-enabled" # ' ' ip WL (ossi and ossi-* imported from ACC)
|
36 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
36 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
Line 59... |
Line 59... |
59 |
chmod 660 $DIR_CONF/update_cat.conf
|
59 |
chmod 660 $DIR_CONF/update_cat.conf
|
60 |
fi
|
60 |
fi
|
61 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
61 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
62 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
62 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
63 |
|
63 |
|
64 |
# process the file $BL_CATEGORIES with the choice of categories
|
64 |
# process the file $BL_CATEGORIES with the choice of categories
|
65 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
65 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
66 |
do
|
66 |
do
|
67 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
67 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
68 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
68 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
69 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
69 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
70 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
70 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
71 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
71 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
72 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
72 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
Line 76... |
Line 76... |
76 |
sort +0.0 -0.2 $BL_CATEGORIES_ENABLED -o $FILE_tmp
|
76 |
sort +0.0 -0.2 $BL_CATEGORIES_ENABLED -o $FILE_tmp
|
77 |
mv $FILE_tmp $BL_CATEGORIES_ENABLED
|
77 |
mv $FILE_tmp $BL_CATEGORIES_ENABLED
|
78 |
chown root:apache $BL_CATEGORIES $BL_CATEGORIES_ENABLED
|
78 |
chown root:apache $BL_CATEGORIES $BL_CATEGORIES_ENABLED
|
79 |
chmod 660 $BL_CATEGORIES $BL_CATEGORIES_ENABLED
|
79 |
chmod 660 $BL_CATEGORIES $BL_CATEGORIES_ENABLED
|
80 |
|
80 |
|
81 |
# process the file $WL_CATEGORIES with the choice of categories
|
81 |
# process the file $WL_CATEGORIES with the choice of categories
|
82 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
82 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
83 |
do
|
83 |
do
|
84 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
84 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
85 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
85 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
86 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
86 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
87 |
done
|
87 |
done
|
88 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
88 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
89 |
mv $FILE_tmp $WL_CATEGORIES
|
89 |
mv $FILE_tmp $WL_CATEGORIES
|
Line 113... |
Line 113... |
113 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
113 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
114 |
nb_args=$#
|
114 |
nb_args=$#
|
115 |
args=$1
|
115 |
args=$1
|
116 |
if [ $nb_args -eq 0 ]
|
116 |
if [ $nb_args -eq 0 ]
|
117 |
then
|
117 |
then
|
118 |
args="-h"
|
118 |
args="-h"
|
119 |
fi
|
119 |
fi
|
120 |
case $args in
|
120 |
case $args in
|
121 |
-\? | -h* | --h*)
|
121 |
-\? | -h* | --h*)
|
122 |
echo "$usage"
|
122 |
echo "$usage"
|
123 |
exit 0
|
123 |
exit 0
|
Line 127... |
Line 127... |
127 |
rm -rf /tmp/con_ok.html
|
127 |
rm -rf /tmp/con_ok.html
|
128 |
`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
|
128 |
`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
|
129 |
if [ ! -e /tmp/con_ok.html ]
|
129 |
if [ ! -e /tmp/con_ok.html ]
|
130 |
then
|
130 |
then
|
131 |
echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
|
131 |
echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
|
132 |
else
|
132 |
else
|
133 |
rm -rf /tmp/con_ok.html $DIR_tmp
|
133 |
rm -rf /tmp/con_ok.html $DIR_tmp
|
134 |
mkdir $DIR_tmp
|
134 |
mkdir $DIR_tmp
|
135 |
wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
|
135 |
wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
|
136 |
md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
|
136 |
md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
|
137 |
chown -R apache:apache $DIR_tmp
|
137 |
chown -R apache:apache $DIR_tmp
|
Line 144... |
Line 144... |
144 |
# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
|
144 |
# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
|
145 |
-adapt | --adapt)
|
145 |
-adapt | --adapt)
|
146 |
echo -n "Adaptation process of Toulouse University blackList. Please wait : "
|
146 |
echo -n "Adaptation process of Toulouse University blackList. Please wait : "
|
147 |
if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
|
147 |
if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
|
148 |
then
|
148 |
then
|
149 |
# keep custom files (ossi)
|
149 |
# keep custom files (ossi)
|
150 |
for x in $(ls -1 $DIR_DG_BL | grep "^ossi-*")
|
150 |
for x in $(ls -1 $DIR_DG_BL | grep "^ossi-*")
|
151 |
do
|
151 |
do
|
152 |
mv $DIR_DG_BL/$x $DIR_tmp
|
152 |
mv $DIR_DG_BL/$x $DIR_tmp
|
153 |
done
|
153 |
done
|
154 |
rm -rf $DIR_DG_BL $DIR_IP_BL
|
154 |
rm -rf $DIR_DG_BL $DIR_IP_BL
|
Line 156... |
Line 156... |
156 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
156 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
157 |
chown -R dansguardian:apache $DIR_DG
|
157 |
chown -R dansguardian:apache $DIR_DG
|
158 |
chmod -R 770 $DIR_DG
|
158 |
chmod -R 770 $DIR_DG
|
159 |
# Add the two local categories (ossi-bl & ossi-wl) to the usage file
|
159 |
# Add the two local categories (ossi-bl & ossi-wl) to the usage file
|
160 |
# Add the custom categories (ossi-tor_nodes) to the usage file
|
160 |
# Add the custom categories (ossi-tor_nodes) to the usage file
|
161 |
cat << EOF >> $DIR_DG_BL/global_usage
|
161 |
cat << EOF >> $DIR_DG_BL/global_usage
|
162 |
|
162 |
|
163 |
NAME: ossi-bl
|
163 |
NAME: ossi-bl
|
164 |
DEFAULT_TYPE: black
|
164 |
DEFAULT_TYPE: black
|
165 |
SOURCE: ALCASAR Team
|
165 |
SOURCE: ALCASAR Team
|
166 |
DESC FR: sites blacklistés ajoutés localement
|
166 |
DESC FR: sites blacklistés ajoutés localement
|
Line 202... |
Line 202... |
202 |
do
|
202 |
do
|
203 |
categorie=`echo $dir_categorie|cut -d "/" -f6`
|
203 |
categorie=`echo $dir_categorie|cut -d "/" -f6`
|
204 |
categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie$ $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
|
204 |
categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie$ $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
|
205 |
if [ "$categorie_type" == "white" ]
|
205 |
if [ "$categorie_type" == "white" ]
|
206 |
then
|
206 |
then
|
207 |
echo "$dir_categorie" >> $WL_CATEGORIES
|
207 |
echo "$dir_categorie" >> $WL_CATEGORIES
|
208 |
else
|
208 |
else
|
209 |
echo "$dir_categorie" >> $BL_CATEGORIES
|
209 |
echo "$dir_categorie" >> $BL_CATEGORIES
|
210 |
fi
|
210 |
fi
|
211 |
done
|
211 |
done
|
212 |
rm -f $FILE_tmp
|
212 |
rm -f $FILE_tmp
|
213 |
# Verify that the enabled categories are effectively in the BL (need after an update of the BL)
|
213 |
# Verify that the enabled categories are effectively in the BL (need after an update of the BL)
|
214 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
214 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
215 |
do
|
215 |
do
|
216 |
ok=`grep /$ENABLE_CATEGORIE$ $BL_CATEGORIES|wc -l`
|
216 |
ok=`grep /$ENABLE_CATEGORIE$ $BL_CATEGORIES|wc -l`
|
217 |
if [ $ok != "1" ]
|
217 |
if [ $ok != "1" ]
|
218 |
then
|
218 |
then
|
219 |
$SED "/^$ENABLE_CATEGORIE$/d" $BL_CATEGORIES_ENABLED
|
219 |
$SED "/^$ENABLE_CATEGORIE$/d" $BL_CATEGORIES_ENABLED
|
220 |
fi
|
220 |
fi
|
221 |
done
|
221 |
done
|
222 |
# Verify that the enabled categories are effectively in the WL (need after an update of the WL)
|
222 |
# Verify that the enabled categories are effectively in the WL (need after an update of the WL)
|
223 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
223 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
224 |
do
|
224 |
do
|
225 |
ok=`grep /$ENABLE_CATEGORIE$ $WL_CATEGORIES|wc -l`
|
225 |
ok=`grep /$ENABLE_CATEGORIE$ $WL_CATEGORIES|wc -l`
|
226 |
if [ $ok != "1" ]
|
226 |
if [ $ok != "1" ]
|
227 |
then
|
227 |
then
|
228 |
$SED "/^$ENABLE_CATEGORIE$/d" $WL_CATEGORIES_ENABLED
|
228 |
$SED "/^$ENABLE_CATEGORIE$/d" $WL_CATEGORIES_ENABLED
|
229 |
fi
|
229 |
fi
|
230 |
done
|
230 |
done
|
231 |
# Creation of DNSMASQ and Iptables BL and WL
|
231 |
# Creation of DNSMASQ and Iptables BL and WL
|
Line 233... |
Line 233... |
233 |
do
|
233 |
do
|
234 |
for PATH_FILE in `cat $LIST` # for each category
|
234 |
for PATH_FILE in `cat $LIST` # for each category
|
235 |
do
|
235 |
do
|
236 |
DOMAIN=`basename $PATH_FILE`
|
236 |
DOMAIN=`basename $PATH_FILE`
|
237 |
echo -n "$DOMAIN, "
|
237 |
echo -n "$DOMAIN, "
|
238 |
if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
|
238 |
if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
|
239 |
then
|
239 |
then
|
240 |
touch $PATH_FILE/urls
|
240 |
touch $PATH_FILE/urls
|
241 |
chown dansguardian:apache $PATH_FILE/urls
|
241 |
chown dansguardian:apache $PATH_FILE/urls
|
242 |
fi
|
242 |
fi
|
243 |
cp $PATH_FILE/domains $FILE_tmp
|
243 |
cp $PATH_FILE/domains $FILE_tmp
|
244 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
244 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
245 |
if [ "$LIST" == "$BL_CATEGORIES" ]
|
245 |
if [ "$LIST" == "$BL_CATEGORIES" ]
|
246 |
then
|
246 |
then
|
247 |
# adapt to the dnsmasq syntax for the blacklist
|
247 |
# adapt to the dnsmasq syntax for the blacklist
|
248 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
248 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
249 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAIN.conf
|
249 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAIN.conf
|
250 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAIN
|
250 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAIN
|
251 |
else
|
251 |
else
|
252 |
# adapt to the dnsmasq syntax for the whitelist
|
252 |
# adapt to the dnsmasq syntax for the whitelist
|
253 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
253 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
254 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAIN.conf
|
254 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAIN.conf
|
255 |
fi
|
255 |
fi
|
256 |
done
|
256 |
done
|
257 |
done
|
257 |
done
|
258 |
echo
|
258 |
echo
|
259 |
chown -R root:apache $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
259 |
chown -R root:apache $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
260 |
chmod 770 $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
260 |
chmod 770 $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
261 |
chmod -f 660 $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL/* $DIR_DNS_WL/* $DIR_IP_BL/* $DIR_IP_WL/*
|
261 |
chmod -f 660 $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL/* $DIR_DNS_WL/* $DIR_IP_BL/* $DIR_IP_WL/*
|
262 |
rm -f $FILE_tmp $FILE_ip_tmp
|
262 |
rm -f $FILE_tmp $FILE_ip_tmp
|
263 |
rm -rf $DIR_tmp
|
263 |
rm -rf $DIR_tmp
|
264 |
;;
|
264 |
;;
|
265 |
# Rsync the categories which are listed in "/usr/local/etc/update_cat.conf". Cron run this function every 12h
|
265 |
# Rsync the categories which are listed in "/usr/local/etc/update_cat.conf". Cron run this function every 12h
|
Line 279... |
Line 279... |
279 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
279 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
280 |
black=`grep black $PATH_FILE/usage |wc -l`
|
280 |
black=`grep black $PATH_FILE/usage |wc -l`
|
281 |
if [ $black == "1" ]
|
281 |
if [ $black == "1" ]
|
282 |
then
|
282 |
then
|
283 |
# adapt to the dnsmasq syntax for the blacklist
|
283 |
# adapt to the dnsmasq syntax for the blacklist
|
284 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
284 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
285 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAIN.conf
|
285 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAIN.conf
|
286 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAIN
|
286 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAIN
|
287 |
else
|
287 |
else
|
288 |
# adapt to the dnsmasq syntax for the whitelist
|
288 |
# adapt to the dnsmasq syntax for the whitelist
|
289 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
289 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
290 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAIN.conf
|
290 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAIN.conf
|
291 |
mv $FILE_ip_tmp $DIR_IP_WL/$DOMAIN
|
291 |
mv $FILE_ip_tmp $DIR_IP_WL/$DOMAIN
|
292 |
fi
|
292 |
fi
|
293 |
rm -f $FILE_tmp $FILE_ip_tmp
|
293 |
rm -f $FILE_tmp $FILE_ip_tmp
|
294 |
done
|
294 |
done
|
295 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
295 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
296 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
296 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
297 |
/usr/bin/systemctl restart dansguardian
|
297 |
/usr/bin/systemctl restart dansguardian
|
298 |
/usr/local/bin/alcasar-iptables.sh
|
298 |
/usr/local/bin/alcasar-iptables.sh
|
299 |
else
|
299 |
else
|
300 |
echo -n "/usr/local/etc/update_cat.conf is empty ..."
|
300 |
echo -n "/usr/local/etc/update_cat.conf is empty ..."
|
301 |
fi
|
301 |
fi
|
302 |
echo
|
302 |
echo
|
303 |
;;
|
303 |
;;
|
304 |
# reload when selected categories are changed or when ossi change his custom files
|
304 |
# reload when selected categories are changed or when ossi change his custom files
|
305 |
-reload | --reload)
|
305 |
-reload | --reload)
|
306 |
# for DG
|
306 |
# for DG
|
307 |
cat_choice
|
307 |
cat_choice
|
Line 341... |
Line 341... |
341 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
341 |
clean_split # clean ossi custom files & split them for dnsmasq and for iptables
|
342 |
if [ $categorie_type == "white" ]
|
342 |
if [ $categorie_type == "white" ]
|
343 |
then
|
343 |
then
|
344 |
# adapt the file to the dnsmasq syntax and enable it if needed
|
344 |
# adapt the file to the dnsmasq syntax and enable it if needed
|
345 |
# for the WL
|
345 |
# for the WL
|
346 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
346 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
347 |
mv $FILE_tmp $DIR_DNS_WL/$ossi_categorie.conf
|
347 |
mv $FILE_tmp $DIR_DNS_WL/$ossi_categorie.conf
|
348 |
mv $FILE_ip_tmp $DIR_IP_WL/$ossi_categorie
|
348 |
mv $FILE_ip_tmp $DIR_IP_WL/$ossi_categorie
|
349 |
enabled=`grep ^$ossi_categorie$ $WL_CATEGORIES_ENABLED | wc -l`
|
349 |
enabled=`grep ^$ossi_categorie$ $WL_CATEGORIES_ENABLED | wc -l`
|
350 |
if [ $enabled == "1" ]
|
350 |
if [ $enabled == "1" ]
|
351 |
then
|
351 |
then
|
352 |
$SED "/\/$ossi_categorie$/d" $WL_CATEGORIES
|
352 |
$SED "/\/$ossi_categorie$/d" $WL_CATEGORIES
|
353 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ossi_categorie" $WL_CATEGORIES
|
353 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ossi_categorie" $WL_CATEGORIES
|
354 |
ln -sf $DIR_DNS_WL/$ossi_categorie.conf $DIR_DNS_WL_ENABLED/$ossi_categorie
|
354 |
ln -sf $DIR_DNS_WL/$ossi_categorie.conf $DIR_DNS_WL_ENABLED/$ossi_categorie
|
355 |
ln -sf $DIR_IP_WL/$ossi_categorie $DIR_IP_WL_ENABLED/$ossi_categorie
|
355 |
ln -sf $DIR_IP_WL/$ossi_categorie $DIR_IP_WL_ENABLED/$ossi_categorie
|
356 |
fi
|
356 |
fi
|
357 |
else
|
357 |
else
|
358 |
# for the BL
|
358 |
# for the BL
|
359 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
359 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
360 |
mv $FILE_tmp $DIR_DNS_BL/$ossi_categorie.conf
|
360 |
mv $FILE_tmp $DIR_DNS_BL/$ossi_categorie.conf
|
361 |
mv $FILE_ip_tmp $DIR_IP_BL/$ossi_categorie
|
361 |
mv $FILE_ip_tmp $DIR_IP_BL/$ossi_categorie
|
362 |
enabled=`grep ^$ossi_categorie$ $BL_CATEGORIES_ENABLED | wc -l`
|
362 |
enabled=`grep ^$ossi_categorie$ $BL_CATEGORIES_ENABLED | wc -l`
|
363 |
if [ $enabled == "1" ]
|
363 |
if [ $enabled == "1" ]
|
364 |
then
|
364 |
then
|
365 |
$SED "/\/$ossi_categorie$/d" $BL_CATEGORIES
|
365 |
$SED "/\/$ossi_categorie$/d" $BL_CATEGORIES
|
366 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ossi_categorie" $BL_CATEGORIES
|
366 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ossi_categorie" $BL_CATEGORIES
|
367 |
ln -sf $DIR_DNS_BL/$ossi_categorie.conf $DIR_DNS_BL_ENABLED/$ossi_categorie
|
367 |
ln -sf $DIR_DNS_BL/$ossi_categorie.conf $DIR_DNS_BL_ENABLED/$ossi_categorie
|
368 |
ln -sf $DIR_IP_BL/$ossi_categorie $DIR_IP_BL_ENABLED/$ossi_categorie
|
368 |
ln -sf $DIR_IP_BL/$ossi_categorie $DIR_IP_BL_ENABLED/$ossi_categorie
|
369 |
fi
|
369 |
fi
|
370 |
fi
|
370 |
fi
|