33,11 → 33,11 |
BL_SERVER="dsi.ut-capitole.fr" |
SED="/bin/sed -i" |
|
# enable/disable the BL categories |
# enable/disable the BL & WL categories |
function cat_choice (){ |
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 # cleaning categories file (comment all lines) |
$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 |
# process the file $BL_CATEGORIES with the choice of categories |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED` |
51,6 → 51,15 |
done |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp |
mv $FILE_tmp $BL_CATEGORIES |
# process the file $WL_CATEGORIES with the choice of categories |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED` |
do |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES |
ln -s $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE |
done |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp |
mv $FILE_tmp $WL_CATEGORIES |
} |
function bl_enable (){ |
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf |
129,16 → 138,16 |
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 |
chown -R dansguardian:apache $DIR_DG |
chmod -R g+w $DIR_DG |
fi |
rm -f $BL_CATEGORIES $WL_CATEGORIES |
rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED |
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL |
touch $BL_CATEGORIES $WL_CATEGORIES |
touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED |
mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL |
chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED |
chmod -R g+w $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED |
find $DIR_DG_BL/ -type f -name domains > $FILE_tmp # retrieve directory name where a domain file exist |
$SED "s?\/domains??g" $FILE_tmp # remove "/domains" suffix |
for dir_categorie in `cat $FILE_tmp` # create the blackist and the whitelist files |
for dir_categorie in `cat $FILE_tmp` # create the blacklist and the whitelist files |
do |
categorie=`echo $dir_categorie|cut -d "/" -f6` |
categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"` |
145,7 → 154,7 |
if [ "$categorie_type" == "white" ] |
then |
echo "$dir_categorie" >> $WL_CATEGORIES |
echo "$dir_categorie" >> $WL_CATEGORIES_ENABLED # by default all WL are enabled |
echo `basename $dir_categorie` >> $WL_CATEGORIES_ENABLED # by default all WL are enabled |
else |
echo "$dir_categorie" >> $BL_CATEGORIES |
fi |
190,7 → 199,7 |
chown -R dansguardian:apache $DIR_DG_BL/ossi |
chmod -R g+w $DIR_DG_BL/ossi |
cat_choice |
# for dnsmasq (noms de domaine réhabilités) |
# for dnsmasq (rehabited domain names) |
if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ] |
then |
for i in `cat $DIR_DG/exceptionsitelist` |
200,6 → 209,7 |
fi |
cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf |
cp -f $DIR_DG_BL/ossi/domains_wl $DIR_DNS_WL/ossi.conf |
DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2` # DNS and URLs filter (on/off) |
DNS_FILTERING=${DNS_FILTERING:=off} |
if [ $DNS_FILTERING = on ]; then |