Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1929 → Rev 1930

/scripts/alcasar-bl.sh
46,82 → 46,10
# enable/disable the BL & WL categories
function cat_choice (){
mkdir $DIR_tmp
#ip BL ENABLE
if [ -d $DIR_IP_BL_ENABLED ]
then
for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
do
rm -f $DIR_IP_BL_ENABLED/$file
done
else
mkdir $DIR_IP_BL_ENABLED
chown root:apache $DIR_IP_BL_ENABLED
chmod 770 $DIR_IP_BL_ENABLED
fi
 
#dns BL ENABLED
if [ -d $DIR_DNS_BL_ENABLED ]
then
for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
do
rm -f $DIR_DNS_BL_ENABLED/$file
done
else
mkdir $DIR_DNS_BL_ENABLED
chown root:apache $DIR_DNS_BL_ENABLED
chmod 770 $DIR_DNS_BL_ENABLED
fi
#dns BL ossi.conf
if [ ! -e $DIR_DNS_BL/ossi.conf ]
then
touch $DIR_DNS_BL/ossi.conf
chown root:apache $DIR_DNS_BL/ossi.conf
chmod g+w $DIR_DNS_BL/ossi.conf
if [ ! -e $DIR_DNS_BL_ENABLED/ossi ]
then
ln -s $DIR_DNS_BL/ossi.conf $DIR_DNS_BL_ENABLED/ossi
fi
fi
 
#ip WL ENABLE
if [ -d $DIR_IP_WL_ENABLED ]
then
for file in `ls -1 $DIR_IP_WL_ENABLED | grep -v "^ossi*"`
do
rm -f $DIR_IP_WL_ENABLED/$file
done
else
mkdir $DIR_IP_WL_ENABLED
touch $DIR_IP_WL_ENABLED/ossi
chown -R root:apache $DIR_IP_WL_ENABLED
chmod 770 $DIR_IP_WL_ENABLED
chmod g+w $DIR_IP_WL_ENABLED/ossi
fi
 
#dns WL ENABLED
if [ -d $DIR_DNS_WL_ENABLED ]
then
for file in `ls -1 $DIR_DNS_WL_ENABLED | grep -v "^ossi-*"`
do
rm -f $DIR_DNS_WL_ENABLED/$file
done
else
mkdir $DIR_DNS_WL_ENABLED
chown root:apache $DIR_DNS_WL_ENABLED
chmod 770 $DIR_DNS_WL_ENABLED
fi
#dns WL ossi.conf
if [ ! -e $DIR_DNS_WL/ossi.conf ]
then
touch $DIR_DNS_WL/ossi.conf
chown root:apache $DIR_DNS_WL/ossi.conf
chmod g+w $DIR_DNS_WL/ossi.conf
if [ ! -e $DIR_DNS_WL_ENABLED/ossi ]
then
ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
fi
fi
 
for dir_bl in $DIR_IP_BL_ENABLED $DIR_DNS_BL_ENABLED $DIR_IP_WL_ENABLED $DIR_DNS_WL_ENABLED
do
rm -f $dir_bl/*
done
# update categories with rsync
if [ ! -e $DIR_CONF/update_cat.conf ]
then
190,32 → 118,18
# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
-adapt | --adapt)
echo -n "Adaptation process of Toulouse University blackList. Please wait : "
# keep custom files (ossi)
for x in $(ls -1 $DIR_DG_BL | grep "^ossi-*")
do
mv $DIR_DG_BL/$x $DIR_tmp
done
if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
then
# keep custom files (ossi)
for x in $(ls -1 $DIR_DG_BL | grep "^ossi-*")
do
mv $DIR_DG_BL/$x $DIR_tmp
done
rm -rf $DIR_DG_BL $DIR_IP_BL
mkdir $DIR_DG_BL $DIR_IP_BL
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
fi
# Retrieve custom files (ossi)
for x in $(ls -1 $DIR_tmp | grep "^ossi-*")
do
mv $DIR_tmp/$x $DIR_DG_BL
done
rm -f $BL_CATEGORIES $WL_CATEGORIES
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
touch $BL_CATEGORIES $WL_CATEGORIES
mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
chmod -R g+w $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
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
# Add the two local categories (ossi-bl & ossi-wl) to the usage file
cat << EOF >> $DIR_DG_BL/global_usage
# Add the two local categories (ossi-bl & ossi-wl) to the usage file
cat << EOF >> $DIR_DG_BL/global_usage
 
NAME: ossi-bl
DEFAULT_TYPE: black
241,6 → 155,20
NAME DE: ossi-wl
NAME ES: ossi-wl
EOF
# Retrieve custom files (ossi)
for x in $(ls -1 $DIR_tmp | grep "^ossi-*")
do
mv $DIR_tmp/$x $DIR_DG_BL
done
fi
rm -f $BL_CATEGORIES $WL_CATEGORIES
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
touch $BL_CATEGORIES $WL_CATEGORIES
mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
chown -R dansguardian:apache $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
chmod -R g+w $DIR_DG $BL_CATEGORIES $WL_CATEGORIES $BL_CATEGORIES_ENABLED $WL_CATEGORIES_ENABLED $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
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 blacklist and the whitelist files
do
categorie=`echo $dir_categorie|cut -d "/" -f6`
248,8 → 176,9
if [ "$categorie_type" == "white" ]
then
echo "$dir_categorie" >> $WL_CATEGORIES
else
echo "$dir_categorie" >> $BL_CATEGORIES
fi
echo "$dir_categorie" >> $BL_CATEGORIES
done
rm -f $FILE_tmp
# Verify that the enabled categories are effectively in the BL (need after an update of the BL)