36,10 → 36,15 |
|
# enable/disable the BL & WL categories |
function cat_choice (){ |
# saving ip files and ossi category |
mkdir $DIR_tmp |
cp $DIR_IP_BL_ENABLED/ossi-* $DIR_tmp |
cp $DIR_IP_BL/ossi $DIR_tmp |
rm -rf $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED # cleaning for dnsmasq and iptables |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines) |
mkdir $DIR_DNS_BL_ENABLED $DIR_DNS_WL_ENABLED $DIR_IP_BL_ENABLED |
chown apache $DIR_IP_BL_ENABLED |
# process the file $BL_CATEGORIES with the choice of categories |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` |
do |
61,6 → 66,11 |
done |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp |
mv $FILE_tmp $WL_CATEGORIES |
# restoring ip files and ossi category |
mv $DIR_tmp/ossi $DIR_IP_BL |
chown apache $DIR_IP_BL/ossi |
mv $DIR_tmp/ossi-* $DIR_IP_BL_ENABLED |
rm -rf $DIR_tmp |
} |
function bl_enable (){ |
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf |
134,6 → 144,8 |
# Adapt Toulouse BL to ALCASAR architecture (dnsmasq + DG + iptables) |
-adapt | --adapt) |
echo -n "Toulouse BlackList migration process. Please wait : " |
# Saving ossi category |
cp $DIR_IP_BL/ossi $DIR_tmp |
if [ -f $DIR_tmp/blacklists.tar.gz ] |
then |
[ -d $DIR_DG_BL/ossi ] && mv -f $DIR_DG_BL/ossi $DIR_tmp |
141,7 → 153,6 |
mkdir $DIR_DG_BL |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/ |
[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DG_BL/ |
rm -rf $DIR_tmp |
fi |
rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED |
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL |
188,7 → 199,7 |
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors |
|
# retrieve the ip addresses for iptables |
# create an ipset save for the selected category |
# create an set save for the selected category |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add blacklist_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp |
|
# for dnsmask, remove IP addesses, accented characters and commented lines. |
207,6 → 218,9 |
done |
done |
rm -f $FILE_tmp $FILE_ip_tmp |
# Restoring ossi category |
mv $DIR_tmp/ossi $DIR_IP_BL |
rm -rf $DIR_tmp |
echo |
;; |
# reload when categories are changed |