Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 1954 2016-06-18 19:46:53Z richard $
|
3 |
# $Id: alcasar-bl.sh 1955 2016-06-20 22:10:50Z 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 72... |
Line 72... |
72 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
72 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
73 |
done
|
73 |
done
|
74 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
74 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
75 |
mv $FILE_tmp $BL_CATEGORIES
|
75 |
mv $FILE_tmp $BL_CATEGORIES
|
76 |
chown root:apache $BL_CATEGORIES
|
76 |
chown root:apache $BL_CATEGORIES
|
- |
|
77 |
chmod 660 $BL_CATEGORIES
|
77 |
|
78 |
|
78 |
# process the file $WL_CATEGORIES with the choice of categories
|
79 |
# process the file $WL_CATEGORIES with the choice of categories
|
79 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
80 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
80 |
do
|
81 |
do
|
81 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
82 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
Line 83... |
Line 84... |
83 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
84 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
84 |
done
|
85 |
done
|
85 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
86 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
86 |
mv $FILE_tmp $WL_CATEGORIES
|
87 |
mv $FILE_tmp $WL_CATEGORIES
|
87 |
chown root:apache $WL_CATEGORIES
|
88 |
chown root:apache $WL_CATEGORIES
|
- |
|
89 |
chmod 660 $WL_CATEGORIES
|
88 |
}
|
90 |
}
|
89 |
|
91 |
|
90 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
92 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
91 |
nb_args=$#
|
93 |
nb_args=$#
|
92 |
args=$1
|
94 |
args=$1
|
Line 318... |
Line 320... |
318 |
else
|
320 |
else
|
319 |
categorie_type="white"
|
321 |
categorie_type="white"
|
320 |
fi
|
322 |
fi
|
321 |
$SED "s/\.\{2,10\}/\./g" $ossi_custom_dir/domains $ossi_custom_dir/urls # correction 'coma" instead of 'dot'
|
323 |
$SED "s/\.\{2,10\}/\./g" $ossi_custom_dir/domains $ossi_custom_dir/urls # correction 'coma" instead of 'dot'
|
322 |
$SED "/^$/d" $ossi_custom_dir/domains $ossi_custom_dir/urls # remove empty lines
|
324 |
$SED "/^$/d" $ossi_custom_dir/domains $ossi_custom_dir/urls # remove empty lines
|
- |
|
325 |
$SED "s/\r//" $ossi_custom_dir/domains $ossi_custom_dir/urls # remove Windows <CR>
|
323 |
# extract ip addresses for iptables
|
326 |
# extract ip addresses for iptables
|
324 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $ossi_custom_dir/domains > $FILE_ip_tmp
|
327 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $ossi_custom_dir/domains > $FILE_ip_tmp
|
325 |
# for dnsmask, remove IP addesses, accented characters and commented lines.
|
328 |
# for dnsmask, remove IP addesses, accented characters and commented lines.
|
326 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $ossi_custom_dir/domains > $FILE_tmp
|
329 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $ossi_custom_dir/domains > $FILE_tmp
|
327 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
330 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
Line 357... |
Line 360... |
357 |
fi
|
360 |
fi
|
358 |
done
|
361 |
done
|
359 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
362 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
360 |
mv $FILE_tmp $BL_CATEGORIES
|
363 |
mv $FILE_tmp $BL_CATEGORIES
|
361 |
chown root:apache $BL_CATEGORIES
|
364 |
chown root:apache $BL_CATEGORIES
|
- |
|
365 |
chmod 660 $BL_CATEGORIES
|
362 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
366 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
363 |
mv $FILE_tmp $WL_CATEGORIES
|
367 |
mv $FILE_tmp $WL_CATEGORIES
|
364 |
chown root:apache $WL_CATEGORIES
|
368 |
chown root:apache $WL_CATEGORIES
|
- |
|
369 |
chmod 660 $WL_CATEGORIES
|
365 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
370 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
366 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
371 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
367 |
/usr/local/bin/alcasar-iptables.sh
|
372 |
/usr/local/bin/alcasar-iptables.sh
|
368 |
;;
|
373 |
;;
|
369 |
*)
|
374 |
*)
|