Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 1930 2016-06-08 22:00:48Z richard $
|
3 |
# $Id: alcasar-bl.sh 1931 2016-06-09 21:09:15Z richard $
|
4 |
|
4 |
|
5 |
# alcasar-bl.sh
|
5 |
# alcasar-bl.sh
|
6 |
# by Franck BOUIJOUX and Richard REY
|
6 |
# by Franck BOUIJOUX and Richard REY
|
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
8 |
|
8 |
|
Line 28... |
Line 28... |
28 |
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl" # all the BL in the DNSMASQ format
|
28 |
DIR_DNS_BL="$DIR_SHARE/dnsmasq-bl" # all the BL in the DNSMASQ format
|
29 |
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl" # all the WL ' ' '
|
29 |
DIR_DNS_WL="$DIR_SHARE/dnsmasq-wl" # all the WL ' ' '
|
30 |
DIR_IP_BL="$DIR_SHARE/iptables-bl" # all the IP addresses of the BL
|
30 |
DIR_IP_BL="$DIR_SHARE/iptables-bl" # all the IP addresses of the BL
|
31 |
DIR_IP_WL="$DIR_SHARE/iptables-wl" # IP ossi disabled WL
|
31 |
DIR_IP_WL="$DIR_SHARE/iptables-wl" # IP ossi disabled WL
|
32 |
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the domains BL (only enabled categories)
|
32 |
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the domains BL (only enabled categories)
|
33 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' ' '
|
33 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' '
|
34 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
34 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
35 |
DIR_IP_WL_ENABLED="$DIR_SHARE/iptables-wl-enabled" # ' ' ip WL (ossi and ossi-* imported from ACC)
|
35 |
DIR_IP_WL_ENABLED="$DIR_SHARE/iptables-wl-enabled" # ' ' ip WL (ossi and ossi-* imported from ACC)
|
36 |
tmp_DIR_IP_BL="/tmp/ossi-iptables-bl" #IP BL tmp directory to keep ossi files during an update
|
- |
|
37 |
tmp_DIR_IP_WL="/tmp/ossi-iptables-wl" #IP WL tmp directory to keep ossi files during an update
|
- |
|
38 |
tmp_DIR_DNS_BL="/tmp/ossi-dnsmasq-bl" #DNS BL tmp directory to keep ossi files during an update
|
- |
|
39 |
tmp_DIR_DNS_WL="/tmp/ossi-dnsmasq-wl" #DNS WL tmp directory to keep ossi files during an update
|
- |
|
40 |
#BL tmp directory to keep ossi files
|
- |
|
41 |
DNSMASQ_BL_CONF="/etc/dnsmasq-blacklist.conf" # conf file of dnsmasq-blacklist
|
- |
|
42 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
36 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
43 |
BL_SERVER="dsi.ut-capitole.fr"
|
37 |
BL_SERVER="dsi.ut-capitole.fr"
|
44 |
SED="/bin/sed -i"
|
38 |
SED="/bin/sed -i"
|
45 |
|
39 |
|
46 |
# enable/disable the BL & WL categories
|
40 |
# enable/disable the BL & WL categories
|
47 |
function cat_choice (){
|
41 |
function cat_choice (){
|
48 |
mkdir $DIR_tmp
|
42 |
mkdir -p $DIR_tmp
|
49 |
for dir_bl in $DIR_IP_BL_ENABLED $DIR_DNS_BL_ENABLED $DIR_IP_WL_ENABLED $DIR_DNS_WL_ENABLED
|
43 |
for LIST in $DIR_IP_BL_ENABLED $DIR_DNS_BL_ENABLED $DIR_IP_WL_ENABLED $DIR_DNS_WL_ENABLED
|
50 |
do
|
44 |
do
|
51 |
rm -f $dir_bl/*
|
45 |
rm -rf $LIST/*
|
52 |
done
|
46 |
done
|
53 |
# update categories with rsync
|
47 |
# update categories with rsync
|
54 |
if [ ! -e $DIR_CONF/update_cat.conf ]
|
48 |
if [ ! -e $DIR_CONF/update_cat.conf ]
|
55 |
then
|
49 |
then
|
56 |
touch $DIR_CONF/update_cat.conf
|
50 |
touch $DIR_CONF/update_cat.conf
|
Line 68... |
Line 62... |
68 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
62 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
69 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
63 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
70 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
64 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
71 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
65 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
72 |
done
|
66 |
done
|
- |
|
67 |
# add ossi categories
|
- |
|
68 |
for OSSI_CATEGORIE in `ls $DIR_DNS_BL | grep ossi`
|
- |
|
69 |
do
|
- |
|
70 |
ln -sf $DIR_DNS_BL/$OSSI_CATEGORIE $DIR_DNS_BL_ENABLED/$OSSI_CATEGORIE
|
- |
|
71 |
done
|
- |
|
72 |
for OSSI_CATEGORIE in `ls $DIR_IP_BL | grep ossi`
|
- |
|
73 |
do
|
- |
|
74 |
ln -sf $DIR_IP_BL/$OSSI_CATEGORIE $DIR_IP_BL_ENABLED/$OSSI_CATEGORIE
|
- |
|
75 |
done
|
- |
|
76 |
|
73 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
77 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
74 |
mv $FILE_tmp $BL_CATEGORIES
|
78 |
mv $FILE_tmp $BL_CATEGORIES
|
75 |
|
79 |
|
76 |
# process the file $WL_CATEGORIES with the choice of categories
|
80 |
# process the file $WL_CATEGORIES with the choice of categories
|
77 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
81 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
78 |
do
|
82 |
do
|
79 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
83 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
80 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
84 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
81 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
85 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
82 |
done
|
86 |
done
|
- |
|
87 |
# add ossi categories
|
- |
|
88 |
for OSSI_CATEGORIE in `ls $DIR_DNS_WL | grep ossi`
|
- |
|
89 |
do
|
- |
|
90 |
ln -sf $DIR_DNS_WL/$OSSI_CATEGORIE $DIR_DNS_WL_ENABLED/$OSSI_CATEGORIE
|
- |
|
91 |
done
|
- |
|
92 |
for OSSI_CATEGORIE in `ls $DIR_IP_WL | grep ossi`
|
- |
|
93 |
do
|
- |
|
94 |
ln -sf $DIR_IP_WL/$OSSI_CATEGORIE $DIR_IP_WL_ENABLED/$OSSI_CATEGORIE
|
- |
|
95 |
done
|
83 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
96 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
84 |
mv $FILE_tmp $WL_CATEGORIES
|
97 |
mv $FILE_tmp $WL_CATEGORIES
|
85 |
}
|
98 |
}
|
86 |
|
99 |
|
87 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
100 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|