Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1364 → Rev 1365

/scripts/sbin/alcasar-bl.sh
17,6 → 17,7
DIR_tmp="/tmp/blacklists"
FILE_tmp="/tmp/filesfilter.txt"
FILE_ip_tmp="/tmp/filesipfilter.txt"
FILE_IP_WL="/usr/local/share/ossi_wl"
DIR_DG="/etc/dansguardian/lists"
DIR_DG_BL="$DIR_DG/blacklists"
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories" # list of names of the BL categories
30,7 → 31,8
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the dnsmasq BL (only enabled categories)
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' ' '
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
DNSMASQ_BL_CONF="/etc/dnsmasq-blackhole.conf" # conf file of dnsmasq-blackhole
DNSMASQ_BL_CONF="/etc/dnsmasq-blacklist.conf" # conf file of dnsmasq-blacklist
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
BL_SERVER="dsi.ut-capitole.fr"
SED="/bin/sed -i"
 
99,15 → 101,9
args=$1
if [ $nb_args -eq 0 ]
then
DNS_FILTERING=`grep DNS_FILTERING $CONF_FILE|cut -d"=" -f2` # DNS and URLs filter (on/off)
DNS_FILTERING=${DNS_FILTERING:=off}
echo "Set BlackList Filtering to $DNS_FILTERING"
if [ $DNS_FILTERING = on ]; then
cat_choice
bl_enable
else
bl_disable
fi
echo "Set BlackList Filtering to ON"
cat_choice
bl_enable
exit 0
fi
case $args in
143,9 → 139,17
;;
# Adapt Toulouse BL to ALCASAR architecture (dnsmasq + DG + iptables)
-adapt | --adapt)
echo -n "Migration process of Toulouse BlackList. Please wait : "
# Saving IP ossi category if exist else create it (ie : during the installaton process)
[ -e $DIR_IP_BL/ossi ] && mv -f $DIR_IP_BL/ossi $DIR_tmp/ossi-ip
echo -n "Toulouse BlackList migration process. Please wait : "
# Saving whitelist ip
if [ -e $FILE_IP_WL ]
then
cp $FILE_IP_WL $DIR_tmp
else
touch $FILE_IP_WL
chown apache $FILE_IP_WL
fi
# Saving ossi category
cp $DIR_IP_BL/ossi $DIR_tmp/ossi-ip
if [ -f $DIR_tmp/blacklists.tar.gz ]
then
[ -d $DIR_DG_BL/ossi ] && mv -f $DIR_DG_BL/ossi $DIR_tmp
201,25 → 205,31
# retrieve the ip addresses for iptables
# 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.
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
$SED "/^#.*/d" $FILE_tmp
# adapt to the dnsmasq syntax
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
if [ "$LIST" == "$BL_CATEGORIES" ]
then
# adapt to the dnsmasq syntax for the blacklist
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
else
# adapt to the dnsmasq syntax for the whitelist
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
fi
done
done
rm -f $FILE_tmp $FILE_ip_tmp
# Restoring ossi-IP category
[ -e $DIR_tmp/ossi-ip ] && mv $DIR_tmp/ossi-ip $DIR_IP_BL/ossi
# Restoring ossi category
mv $DIR_tmp/ossi-ip $DIR_IP_BL/ossi
# Restoring whitelist ip
if [ -e $DIR_tmp/ossi_wl ]
then
mv $DIR_tmpi/ossi_wl /usr/local/share/
fi
rm -rf $DIR_tmp
echo
;;
240,13 → 250,7
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
bl_enable
else
bl_disable
fi
bl_enable
;;
*)
echo "Argument inconnu :$1";