Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1867 → Rev 1870

/scripts/alcasar-bl.sh
104,8 → 104,14
ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
fi
 
# update categories with rsync
if [ ! -e $DIR_CONF/update_cat.conf ]
then
touch $DIR_CONF/update_cat.conf
chown root:apache $DIR_CONF/update_cat.conf
chmod 660 $DIR_CONF/update_cat.conf
fi
$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)
# process the file $BL_CATEGORIES with the choice of categories
137,7 → 143,7
}
 
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat } & categorie & url_rsync"
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
252,13 → 258,19
#mise a jour d'une categorie avec rsync
-update_cat | --update_cat)
if [ $# -ge 3 ]
then
echo -n "Updating $2 category ..."
echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
 
PATH_FILE=$(find $DIR_DG_BL/ -type d -name $2) # retrieve directory name of the category
rsync -rv $3 $(dirname $PATH_FILE ) #rsync inside of the blacklist directory
for LIGNE_RSYNC in $(cat /usr/local/etc/update_cat.conf)
do
 
$CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f0)
$URL=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
echo "rsync -rv $URL $(dirname $PATH_FILE )" #rsync inside of the blacklist directory
echo $PATH_FILE
# Creation of DNSMASQ and Iptables BL and WL
DOMAINE=$(basename $PATH_FILE)
277,23 → 289,22
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
/usr/bin/systemctl restart dnsmasq-blacklist
else
# adapt to the dnsmasq syntax for the whitelist
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
/usr/bin/systemctl restart dnsmasq-whitelist
fi
rm -f $FILE_tmp $FILE_ip_tmp
 
rm -f $FILE_tmp $FILE_ip_tmp
done
/usr/bin/systemctl restart dnsmasq-whitelist
/usr/bin/systemctl restart dnsmasq-blacklist
/usr/bin/systemctl restart dansguardian
/usr/local/bin/alcasar-iptables.sh
echo "MAJ RSYNC réussie"
else
echo "$usage"
fi
;;
# reload when categories are changed
-reload | --reload)