1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 1912 2016-05-29 13:18:17Z richard $
|
3 |
# $Id: alcasar-bl.sh 1913 2016-05-29 14:44:38Z 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 |
|
9 |
# Gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via Dansguardian)
|
9 |
# Gestion de la BL pour le filtrage de domaine (via dnsmasq) et d'URL (via Dansguardian)
|
10 |
# Manage the BL for DnsBlackHole (dnsmasq) and URL filtering (Dansguardian)
|
10 |
# Manage the BL for DnsBlackHole (dnsmasq) and URL filtering (Dansguardian)
|
11 |
|
11 |
|
12 |
DIR_CONF="/usr/local/etc"
|
12 |
DIR_CONF="/usr/local/etc"
|
13 |
CONF_FILE="$DIR_CONF/alcasar.conf"
|
13 |
CONF_FILE="$DIR_CONF/alcasar.conf"
|
14 |
private_ip_mask=`grep PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
|
14 |
private_ip_mask=`grep PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
|
15 |
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
|
15 |
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
|
16 |
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1` # ALCASAR LAN IP address
|
16 |
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1` # ALCASAR LAN IP address
|
17 |
DIR_tmp="/tmp/blacklists"
|
17 |
DIR_tmp="/tmp/blacklists"
|
18 |
DIR_WL_tmp="/tmp/whitelists"
|
18 |
DIR_WL_tmp="/tmp/whitelists"
|
19 |
FILE_tmp="/tmp/filesfilter.txt"
|
19 |
FILE_tmp="/tmp/filesfilter.txt"
|
20 |
FILE_ip_tmp="/tmp/filesipfilter.txt"
|
20 |
FILE_ip_tmp="/tmp/filesipfilter.txt"
|
21 |
DIR_DG="/etc/dansguardian/lists"
|
21 |
DIR_DG="/etc/dansguardian/lists"
|
22 |
DIR_DG_BL="$DIR_DG/blacklists"
|
22 |
DIR_DG_BL="$DIR_DG/blacklists"
|
23 |
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories" # list of names of the BL categories
|
23 |
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories" # list of names of the BL categories
|
24 |
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories" #' ' WL '
|
24 |
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories" #' ' WL '
|
25 |
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled" # ' ' BL enabled categories
|
25 |
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled" # ' ' BL enabled categories
|
26 |
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled" # ' ' WL enabled categories
|
26 |
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled" # ' ' WL enabled categories
|
27 |
DIR_SHARE="/usr/local/share"
|
27 |
DIR_SHARE="/usr/local/share"
|
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
|
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
|
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
|
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
|
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
|
40 |
#BL tmp directory to keep ossi files
|
41 |
DNSMASQ_BL_CONF="/etc/dnsmasq-blacklist.conf" # conf file of dnsmasq-blacklist
|
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)
|
42 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
43 |
BL_SERVER="dsi.ut-capitole.fr"
|
43 |
BL_SERVER="dsi.ut-capitole.fr"
|
44 |
SED="/bin/sed -i"
|
44 |
SED="/bin/sed -i"
|
45 |
|
45 |
|
46 |
# enable/disable the BL & WL categories
|
46 |
# enable/disable the BL & WL categories
|
47 |
function cat_choice (){
|
47 |
function cat_choice (){
|
48 |
# saving ossi category
|
- |
|
49 |
mkdir $DIR_tmp
|
48 |
mkdir $DIR_tmp
|
50 |
cp $DIR_IP_BL/ossi $DIR_tmp
|
- |
|
51 |
#ip BL ENABLE
|
49 |
#ip BL ENABLE
|
52 |
if [ -d $DIR_IP_BL_ENABLED ]
|
50 |
if [ -d $DIR_IP_BL_ENABLED ]
|
53 |
then
|
51 |
then
|
54 |
for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
|
52 |
for file in `ls -1 $DIR_IP_BL_ENABLED | grep -v "^ossi-*"`
|
55 |
do
|
53 |
do
|
56 |
rm -f $DIR_IP_BL_ENABLED/$file
|
54 |
rm -f $DIR_IP_BL_ENABLED/$file
|
57 |
done
|
55 |
done
|
58 |
else
|
56 |
else
|
59 |
mkdir $DIR_IP_BL_ENABLED
|
57 |
mkdir $DIR_IP_BL_ENABLED
|
60 |
chown dansguardian:apache $DIR_IP_BL_ENABLED
|
58 |
chown root:apache $DIR_IP_BL_ENABLED
|
61 |
chmod g+w $DIR_IP_BL_ENABLED
|
59 |
chmod 770 $DIR_IP_BL_ENABLED
|
62 |
fi
|
60 |
fi
|
63 |
|
- |
|
64 |
|
61 |
|
65 |
#dns BL ENABLED
|
62 |
#dns BL ENABLED
|
66 |
if [ -d $DIR_DNS_BL_ENABLED ]
|
63 |
if [ -d $DIR_DNS_BL_ENABLED ]
|
67 |
then
|
64 |
then
|
68 |
for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
|
65 |
for file in `ls -1 $DIR_DNS_BL_ENABLED | grep -v "^ossi-*"`
|
69 |
do
|
66 |
do
|
70 |
rm -f $DIR_DNS_BL_ENABLED/$file
|
67 |
rm -f $DIR_DNS_BL_ENABLED/$file
|
71 |
done
|
68 |
done
|
72 |
else
|
69 |
else
|
73 |
mkdir $DIR_DNS_BL_ENABLED
|
70 |
mkdir $DIR_DNS_BL_ENABLED
|
74 |
chown dansguardian:apache $DIR_DNS_BL_ENABLED
|
71 |
chown root:apache $DIR_DNS_BL_ENABLED
|
75 |
chmod g+w $DIR_DNS_BL_ENABLED
|
72 |
chmod 770 $DIR_DNS_BL_ENABLED
|
76 |
fi
|
73 |
fi
|
77 |
|
- |
|
78 |
#ip WL ENABLE
|
74 |
#dns BL ossi.conf
|
79 |
if [ -d $DIR_IP_WL ]
|
75 |
if [ ! -e $DIR_DNS_BL/ossi.conf ]
|
80 |
then
|
76 |
then
|
- |
|
77 |
touch $DIR_DNS_BL/ossi.conf
|
81 |
for file in `ls -1 $DIR_IP_WL | grep -v "^ossi*"`
|
78 |
chown root:apache $DIR_DNS_BL/ossi.conf
|
82 |
do
|
- |
|
83 |
rm -f $DIR_IP_WL/$file
|
79 |
chmod g+w $DIR_DNS_BL/ossi.conf
|
84 |
done
|
80 |
if [ ! -e $DIR_DNS_BL_ENABLED/ossi ]
|
85 |
else
|
81 |
then
|
86 |
mkdir $DIR_IP_WL
|
- |
|
87 |
chown dansguardian:apache $DIR_IP_WL
|
82 |
ln -s $DIR_DNS_BL/ossi.conf $DIR_DNS_BL_ENABLED/ossi
|
88 |
chmod g+w $DIR_IP_WL
|
83 |
fi
|
89 |
fi
|
84 |
fi
|
90 |
|
85 |
|
91 |
#ip WL ENABLE
|
86 |
#ip WL ENABLE
|
92 |
if [ -d $DIR_IP_WL_ENABLED ]
|
87 |
if [ -d $DIR_IP_WL_ENABLED ]
|
93 |
then
|
88 |
then
|
94 |
for file in `ls -1 $DIR_IP_WL_ENABLED | grep -v "^ossi*"`
|
89 |
for file in `ls -1 $DIR_IP_WL_ENABLED | grep -v "^ossi*"`
|
95 |
do
|
90 |
do
|
96 |
rm -f $DIR_IP_WL_ENABLED/$file
|
91 |
rm -f $DIR_IP_WL_ENABLED/$file
|
97 |
done
|
92 |
done
|
98 |
else
|
93 |
else
|
99 |
mkdir $DIR_IP_WL_ENABLED
|
94 |
mkdir $DIR_IP_WL_ENABLED
|
100 |
chown dansguardian:apache $DIR_IP_WL_ENABLED
|
- |
|
101 |
chmod g+w $DIR_IP_WL_ENABLED
|
- |
|
102 |
touch $DIR_IP_WL_ENABLED/ossi
|
95 |
touch $DIR_IP_WL_ENABLED/ossi
|
103 |
chown dansguardian:apache $DIR_IP_WL_ENABLED/ossi
|
96 |
chown -R root:apache $DIR_IP_WL_ENABLED
|
- |
|
97 |
chmod 770 $DIR_IP_WL_ENABLED
|
104 |
chmod g+w $DIR_IP_WL_ENABLED/ossi
|
98 |
chmod g+w $DIR_IP_WL_ENABLED/ossi
|
105 |
fi
|
99 |
fi
|
106 |
|
100 |
|
107 |
#dns WL ENABLED
|
101 |
#dns WL ENABLED
|
108 |
if [ -d $DIR_DNS_WL_ENABLED ]
|
102 |
if [ -d $DIR_DNS_WL_ENABLED ]
|
109 |
then
|
103 |
then
|
110 |
for file in `ls -1 $DIR_DNS_WL_ENABLED | grep -v "^ossi-*"`
|
104 |
for file in `ls -1 $DIR_DNS_WL_ENABLED | grep -v "^ossi-*"`
|
111 |
do
|
105 |
do
|
112 |
rm -f $DIR_DNS_WL_ENABLED/$file
|
106 |
rm -f $DIR_DNS_WL_ENABLED/$file
|
113 |
done
|
107 |
done
|
114 |
else
|
108 |
else
|
115 |
mkdir $DIR_DNS_WL_ENABLED
|
109 |
mkdir $DIR_DNS_WL_ENABLED
|
116 |
chown dansguardian:apache $DIR_DNS_WL_ENABLED
|
110 |
chown root:apache $DIR_DNS_WL_ENABLED
|
117 |
chmod g+w $DIR_DNS_WL_ENABLED
|
111 |
chmod 770 $DIR_DNS_WL_ENABLED
|
118 |
fi
|
112 |
fi
|
119 |
|
- |
|
120 |
#dns WL ossi.conf
|
113 |
#dns WL ossi.conf
|
121 |
if [ ! -e $DIR_DNS_WL/ossi.conf ]
|
114 |
if [ ! -e $DIR_DNS_WL/ossi.conf ]
|
122 |
then
|
115 |
then
|
123 |
touch $DIR_DNS_WL/ossi.conf
|
116 |
touch $DIR_DNS_WL/ossi.conf
|
124 |
chown dansguardian:apache $DIR_DNS_WL/ossi.conf
|
117 |
chown root:apache $DIR_DNS_WL/ossi.conf
|
125 |
chmod g+w $DIR_DNS_WL/ossi.conf
|
118 |
chmod g+w $DIR_DNS_WL/ossi.conf
|
126 |
if [ ! -e $DIR_DNS_WL_ENABLED/ossi ]
|
119 |
if [ ! -e $DIR_DNS_WL_ENABLED/ossi ]
|
127 |
then
|
120 |
then
|
128 |
ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
|
121 |
ln -s $DIR_DNS_WL/ossi.conf $DIR_DNS_WL_ENABLED/ossi
|
129 |
fi
|
122 |
fi
|
130 |
fi
|
123 |
fi
|
131 |
|
124 |
|
132 |
# update categories with rsync
|
125 |
# update categories with rsync
|
133 |
if [ ! -e $DIR_CONF/update_cat.conf ]
|
126 |
if [ ! -e $DIR_CONF/update_cat.conf ]
|
134 |
then
|
127 |
then
|
135 |
touch $DIR_CONF/update_cat.conf
|
128 |
touch $DIR_CONF/update_cat.conf
|
136 |
chown root:apache $DIR_CONF/update_cat.conf
|
129 |
chown root:apache $DIR_CONF/update_cat.conf
|
137 |
chmod 660 $DIR_CONF/update_cat.conf
|
130 |
chmod 660 $DIR_CONF/update_cat.conf
|
138 |
fi
|
131 |
fi
|
139 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
132 |
$SED "/\.Include/d" $DIR_DG/bannedsitelist $DIR_DG/bannedurllist # cleaning for DG
|
140 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
133 |
$SED "s?^[^#]?#&?g" $BL_CATEGORIES $WL_CATEGORIES # cleaning BL & WL categories file (comment all lines)
|
141 |
|
134 |
|
142 |
# process the file $BL_CATEGORIES with the choice of categories
|
135 |
# process the file $BL_CATEGORIES with the choice of categories
|
143 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
136 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
144 |
do
|
137 |
do
|
145 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
138 |
$SED "/\/$ENABLE_CATEGORIE$/d" $BL_CATEGORIES
|
146 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
139 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $BL_CATEGORIES
|
147 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
140 |
ln -sf $DIR_DNS_BL/$ENABLE_CATEGORIE.conf $DIR_DNS_BL_ENABLED/$ENABLE_CATEGORIE
|
148 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
141 |
ln -sf $DIR_IP_BL/$ENABLE_CATEGORIE $DIR_IP_BL_ENABLED/$ENABLE_CATEGORIE
|
149 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
142 |
# echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/domains>" >> $DIR_DG/bannedsitelist # Blacklisted domains are managed by dnsmasq
|
150 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
143 |
echo ".Include<$DIR_DG_BL/$ENABLE_CATEGORIE/urls>" >> $DIR_DG/bannedurllist
|
151 |
done
|
144 |
done
|
152 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
145 |
sort +0.0 -0.2 $BL_CATEGORIES -o $FILE_tmp
|
153 |
mv $FILE_tmp $BL_CATEGORIES
|
146 |
mv $FILE_tmp $BL_CATEGORIES
|
154 |
|
147 |
|
155 |
# process the file $WL_CATEGORIES with the choice of categories
|
148 |
# process the file $WL_CATEGORIES with the choice of categories
|
156 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
149 |
for ENABLE_CATEGORIE in `cat $WL_CATEGORIES_ENABLED`
|
157 |
do
|
150 |
do
|
158 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
151 |
$SED "/\/$ENABLE_CATEGORIE$/d" $WL_CATEGORIES
|
159 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
152 |
$SED "1i\/etc\/dansguardian\/lists\/blacklists\/$ENABLE_CATEGORIE" $WL_CATEGORIES
|
160 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
153 |
ln -sf $DIR_DNS_WL/$ENABLE_CATEGORIE.conf $DIR_DNS_WL_ENABLED/$ENABLE_CATEGORIE
|
161 |
done
|
154 |
done
|
162 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
155 |
sort +0.0 -0.2 $WL_CATEGORIES -o $FILE_tmp
|
163 |
mv $FILE_tmp $WL_CATEGORIES
|
156 |
mv $FILE_tmp $WL_CATEGORIES
|
164 |
|
157 |
|
165 |
# restoring ip files and ossi category BL/WL
|
158 |
# restoring ip files and ossi category BL/WL
|
166 |
mv $DIR_tmp/ossi $DIR_IP_BL
|
159 |
mv $DIR_tmp/ossi $DIR_IP_BL
|
167 |
chown apache $DIR_IP_BL/ossi
|
160 |
chown apache $DIR_IP_BL/ossi
|
168 |
rm -rf $DIR_tmp
|
161 |
rm -rf $DIR_tmp
|
169 |
}
|
162 |
}
|
170 |
|
163 |
|
171 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
164 |
usage="Usage: alcasar-bl.sh { -cat_choice or --cat_choice } | { -download or --download } | { -adapt or --adapt } | { -reload or --reload } | { -update_cat or --update_cat }"
|
172 |
nb_args=$#
|
165 |
nb_args=$#
|
173 |
args=$1
|
166 |
args=$1
|
174 |
if [ $nb_args -eq 0 ]
|
167 |
if [ $nb_args -eq 0 ]
|
175 |
then
|
168 |
then
|
176 |
args="-h"
|
169 |
args="-h"
|
177 |
fi
|
170 |
fi
|
178 |
case $args in
|
171 |
case $args in
|
179 |
-\? | -h* | --h*)
|
172 |
-\? | -h* | --h*)
|
180 |
echo "$usage"
|
173 |
echo "$usage"
|
181 |
exit 0
|
174 |
exit 0
|
182 |
;;
|
175 |
;;
|
183 |
# Retrieve Toulouse University BL
|
176 |
# Retrieve Toulouse University BL
|
184 |
-download | --download)
|
177 |
-download | --download)
|
185 |
rm -rf /tmp/con_ok.html
|
178 |
rm -rf /tmp/con_ok.html
|
186 |
`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
|
179 |
`/usr/bin/curl $BL_SERVER -# -o /tmp/con_ok.html`
|
187 |
if [ ! -e /tmp/con_ok.html ]
|
180 |
if [ ! -e /tmp/con_ok.html ]
|
188 |
then
|
181 |
then
|
189 |
echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
|
182 |
echo "Erreur : le serveur de blacklist ($BL_SERVER) n'est pas joignable"
|
190 |
else
|
183 |
else
|
191 |
rm -rf /tmp/con_ok.html $DIR_tmp
|
184 |
rm -rf /tmp/con_ok.html $DIR_tmp
|
192 |
mkdir $DIR_tmp
|
185 |
mkdir $DIR_tmp
|
193 |
wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
|
186 |
wget -P $DIR_tmp http://$BL_SERVER/blacklists/download/blacklists.tar.gz
|
194 |
md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
|
187 |
md5sum $DIR_tmp/blacklists.tar.gz | cut -d" " -f1 > $DIR_tmp/md5sum
|
195 |
chown -R apache:apache $DIR_tmp
|
188 |
chown -R apache:apache $DIR_tmp
|
196 |
fi
|
189 |
fi
|
197 |
;;
|
190 |
;;
|
198 |
# enable/disable categories (used only during the alcasar install process)
|
191 |
# enable/disable categories (used only during the alcasar install process)
|
199 |
-cat_choice | --cat_choice)
|
192 |
-cat_choice | --cat_choice)
|
200 |
cat_choice
|
193 |
cat_choice
|
201 |
;;
|
194 |
;;
|
202 |
# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
|
195 |
# Adapt Toulouse University BL to ALCASAR architecture (dnsmasq + DG + iptables)
|
203 |
-adapt | --adapt)
|
196 |
-adapt | --adapt)
|
204 |
echo -n "Adaptation process of Toulouse University blackList. Please wait : "
|
197 |
echo -n "Adaptation process of Toulouse University blackList. Please wait : "
|
205 |
# keep custom files (ossi)
|
198 |
# keep custom files (ossi) only when updating he BL
|
- |
|
199 |
if [ -d $DIR_IP_BL -a -d $DIR_IP_WL -a -d $DIR_DNS_BL -a -d $DIR_DNS_WL ]
|
- |
|
200 |
then
|
206 |
for x in $(ls -1 $DIR_IP_BL | grep "^ossi*")
|
201 |
for x in $(ls -1 $DIR_IP_BL | grep "^ossi*")
|
207 |
do
|
202 |
do
|
208 |
mv $DIR_IP_BL/$x $tmp_DIR_IP_BL
|
203 |
mv $DIR_IP_BL/$x $tmp_DIR_IP_BL
|
209 |
done
|
204 |
done
|
210 |
for x in $(ls -1 $DIR_IP_WL | grep "^ossi*")
|
205 |
for x in $(ls -1 $DIR_IP_WL | grep "^ossi*")
|
211 |
do
|
206 |
do
|
212 |
mv $DIR_IP_WL/$x $tmp_DIR_IP_WL
|
207 |
mv $DIR_IP_WL/$x $tmp_DIR_IP_WL
|
213 |
done
|
208 |
done
|
214 |
for x in $(ls -1 $DIR_DNS_BL | grep "^ossi*")
|
209 |
for x in $(ls -1 $DIR_DNS_BL | grep "^ossi*")
|
215 |
do
|
210 |
do
|
216 |
mv $DIR_DNS_BL/$x $tmp_DIR_DNS_BL
|
211 |
mv $DIR_DNS_BL/$x $tmp_DIR_DNS_BL
|
217 |
done
|
212 |
done
|
218 |
for x in $(ls -1 $DIR_DNS_WL | grep "^ossi*")
|
213 |
for x in $(ls -1 $DIR_DNS_WL | grep "^ossi*")
|
219 |
do
|
214 |
do
|
220 |
mv $DIR_DNS_WL/$x $tmp_DIR_DNS_WL
|
215 |
mv $DIR_DNS_WL/$x $tmp_DIR_DNS_WL
|
221 |
done
|
216 |
done
|
- |
|
217 |
fi
|
222 |
if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
|
218 |
if [ -f $DIR_tmp/blacklists.tar.gz ] # when downloading the last version of the BL
|
223 |
then
|
219 |
then
|
224 |
rm -rf $DIR_DG_BL $DIR_IP_BL
|
220 |
rm -rf $DIR_DG_BL $DIR_IP_BL
|
225 |
mkdir $DIR_DG_BL $DIR_IP_BL
|
221 |
mkdir $DIR_DG_BL $DIR_IP_BL
|
226 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
222 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
227 |
fi
|
223 |
fi
|
228 |
rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
|
224 |
rm -f $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
|
229 |
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
225 |
rm -rf $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
230 |
touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
|
226 |
touch $BL_CATEGORIES $WL_CATEGORIES $WL_CATEGORIES_ENABLED
|
231 |
mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
227 |
mkdir $DIR_DNS_BL $DIR_DNS_WL $DIR_IP_BL $DIR_IP_WL
|
232 |
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
|
228 |
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
|
233 |
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
|
229 |
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
|
234 |
find $DIR_DG_BL/ -type f -name domains > $FILE_tmp # retrieve directory name where a domain file exist
|
230 |
find $DIR_DG_BL/ -type f -name domains > $FILE_tmp # retrieve directory name where a domain file exist
|
235 |
$SED "s?\/domains??g" $FILE_tmp # remove "/domains" suffix
|
231 |
$SED "s?\/domains??g" $FILE_tmp # remove "/domains" suffix
|
236 |
for dir_categorie in `cat $FILE_tmp` # create the blacklist and the whitelist files
|
232 |
for dir_categorie in `cat $FILE_tmp` # create the blacklist and the whitelist files
|
237 |
do
|
233 |
do
|
238 |
categorie=`echo $dir_categorie|cut -d "/" -f6`
|
234 |
categorie=`echo $dir_categorie|cut -d "/" -f6`
|
239 |
categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
|
235 |
categorie_type=`grep -A1 ^NAME:[$' '$'\t']*$categorie $DIR_DG_BL/global_usage | grep ^DEFAULT_TYPE | cut -d":" -f2 | tr -d " \t"`
|
240 |
if [ "$categorie_type" == "white" ]
|
236 |
if [ "$categorie_type" == "white" ]
|
241 |
then
|
237 |
then
|
242 |
echo "$dir_categorie" >> $WL_CATEGORIES
|
238 |
echo "$dir_categorie" >> $WL_CATEGORIES
|
243 |
echo `basename $dir_categorie` >> $WL_CATEGORIES_ENABLED # by default all WL are enabled
|
239 |
echo `basename $dir_categorie` >> $WL_CATEGORIES_ENABLED # by default all WL are enabled
|
244 |
fi
|
240 |
fi
|
245 |
echo "$dir_categorie" >> $BL_CATEGORIES # By default all categories are in BL
|
241 |
echo "$dir_categorie" >> $BL_CATEGORIES # By default all categories are in BL
|
246 |
done
|
242 |
done
|
247 |
rm -f $FILE_tmp
|
243 |
rm -f $FILE_tmp
|
248 |
# Verify that the enabled categories are effectively in the BL (need after an update of the BL)
|
244 |
# Verify that the enabled categories are effectively in the BL (need after an update of the BL)
|
249 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
245 |
for ENABLE_CATEGORIE in `cat $BL_CATEGORIES_ENABLED`
|
250 |
do
|
246 |
do
|
251 |
ok=`grep /$ENABLE_CATEGORIE$ $BL_CATEGORIES|wc -l`
|
247 |
ok=`grep /$ENABLE_CATEGORIE$ $BL_CATEGORIES|wc -l`
|
252 |
if [ $ok != "1" ]
|
248 |
if [ $ok != "1" ]
|
253 |
then
|
249 |
then
|
254 |
$SED "/^$ENABLE_CATEGORIE$/d" $BL_CATEGORIES_ENABLED
|
250 |
$SED "/^$ENABLE_CATEGORIE$/d" $BL_CATEGORIES_ENABLED
|
255 |
fi
|
251 |
fi
|
256 |
done
|
252 |
done
|
257 |
# Creation of DNSMASQ and Iptables BL and WL
|
253 |
# Creation of DNSMASQ and Iptables BL and WL
|
258 |
for LIST in $BL_CATEGORIES $WL_CATEGORIES # for each list (bl and wl)
|
254 |
for LIST in $BL_CATEGORIES $WL_CATEGORIES # for each list (bl and wl)
|
259 |
do
|
255 |
do
|
260 |
for PATH_FILE in `cat $LIST` # for each category
|
256 |
for PATH_FILE in `cat $LIST` # for each category
|
261 |
do
|
257 |
do
|
262 |
DOMAINE=`basename $PATH_FILE`
|
258 |
DOMAINE=`basename $PATH_FILE`
|
263 |
echo -n "$DOMAINE, "
|
259 |
echo -n "$DOMAINE, "
|
264 |
if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
|
260 |
if [ ! -f $PATH_FILE/urls ] # create 'urls' file if it doesn't exist
|
265 |
then
|
261 |
then
|
266 |
touch $PATH_FILE/urls
|
262 |
touch $PATH_FILE/urls
|
267 |
chown dansguardian:apache $PATH_FILE/urls
|
263 |
chown dansguardian:apache $PATH_FILE/urls
|
268 |
fi
|
264 |
fi
|
269 |
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
|
265 |
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
|
270 |
# extract ip addresses for iptables
|
266 |
# extract ip addresses for iptables
|
271 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
|
267 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
|
272 |
# for dnsmask, remove IP addesses, accented characters and commented lines.
|
268 |
# for dnsmask, remove IP addesses, accented characters and commented lines.
|
273 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
|
269 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
|
274 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
270 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
275 |
$SED "/^#.*/d" $FILE_tmp
|
271 |
$SED "/^#.*/d" $FILE_tmp
|
276 |
if [ "$LIST" == "$BL_CATEGORIES" ]
|
272 |
if [ "$LIST" == "$BL_CATEGORIES" ]
|
277 |
then
|
273 |
then
|
278 |
# adapt to the dnsmasq syntax for the blacklist
|
274 |
# adapt to the dnsmasq syntax for the blacklist
|
279 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
275 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
280 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
|
276 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
|
281 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
|
277 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
|
282 |
else
|
278 |
else
|
283 |
# adapt to the dnsmasq syntax for the whitelist
|
279 |
# adapt to the dnsmasq syntax for the whitelist
|
284 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
280 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
285 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
281 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
286 |
fi
|
282 |
fi
|
287 |
done
|
283 |
done
|
288 |
done
|
284 |
done
|
289 |
rm -f $FILE_tmp $FILE_ip_tmp
|
285 |
rm -f $FILE_tmp $FILE_ip_tmp
|
290 |
# Restoring custom files (ossi)
|
286 |
# Restoring custom files (ossi)
|
291 |
rm -rf $DIR_tmp
|
287 |
rm -rf $DIR_tmp
|
292 |
if [ -d $tmp_DIR_IP_BL -a -d $tmp_DIR_IP_WL -a -d $tmp_DIR_DNS_BL -a -d $tmp_DIR_DNS_WL ]
|
288 |
if [ -d $tmp_DIR_IP_BL -a -d $tmp_DIR_IP_WL -a -d $tmp_DIR_DNS_BL -a -d $tmp_DIR_DNS_WL ]
|
293 |
then
|
289 |
then
|
294 |
for x in $(ls -1 $tmp_DIR_IP_BL | grep "^ossi*")
|
290 |
for x in $(ls -1 $tmp_DIR_IP_BL | grep "^ossi*")
|
295 |
do
|
291 |
do
|
296 |
mv $tmp_DIR_IP_BL/$x $DIR_IP_BL
|
292 |
mv $tmp_DIR_IP_BL/$x $DIR_IP_BL
|
297 |
done
|
293 |
done
|
298 |
for x in $(ls -1 $tmp_DIR_IP_WL | grep "^ossi*")
|
294 |
for x in $(ls -1 $tmp_DIR_IP_WL | grep "^ossi*")
|
299 |
do
|
295 |
do
|
300 |
mv $tmp_DIR_IP_WL/$x $DIR_IP_WL
|
296 |
mv $tmp_DIR_IP_WL/$x $DIR_IP_WL
|
301 |
done
|
297 |
done
|
302 |
for x in $(ls -1 $tmp_DIR_DNS_BL | grep "^ossi*")
|
298 |
for x in $(ls -1 $tmp_DIR_DNS_BL | grep "^ossi*")
|
303 |
do
|
299 |
do
|
304 |
mv $tmp_DIR_DNS_BL/$x $DIR_DNS_BL
|
300 |
mv $tmp_DIR_DNS_BL/$x $DIR_DNS_BL
|
305 |
done
|
301 |
done
|
306 |
for x in $(ls -1 $tmp_DIR_DNS_WL | grep "^ossi*")
|
302 |
for x in $(ls -1 $tmp_DIR_DNS_WL | grep "^ossi*")
|
307 |
do
|
303 |
do
|
308 |
mv $tmp_DIR_DNS_WL/$x $DIR_DNS_WL
|
304 |
mv $tmp_DIR_DNS_WL/$x $DIR_DNS_WL
|
309 |
done
|
305 |
done
|
310 |
rm -rf $tmp_DIR_IP_BL $tmp_DIR_IP_WL $tmp_DIR_DNS_BL $tmp_DIR_DNS_WL
|
306 |
rm -rf $tmp_DIR_IP_BL $tmp_DIR_IP_WL $tmp_DIR_DNS_BL $tmp_DIR_DNS_WL
|
311 |
fi
|
307 |
fi
|
312 |
echo
|
308 |
echo
|
313 |
;;
|
309 |
;;
|
314 |
# update the categories which are written in "/usr/local/etc/update_cat.conf" with rsync
|
310 |
# update the categories which are written in "/usr/local/etc/update_cat.conf" with rsync
|
315 |
-update_cat | --update_cat)
|
311 |
-update_cat | --update_cat)
|
316 |
if [ $(cat /usr/local/etc/update_cat.conf | wc -l) -ne 0 ]
|
312 |
if [ $(cat /usr/local/etc/update_cat.conf | wc -l) -ne 0 ]
|
317 |
then
|
313 |
then
|
318 |
echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
|
314 |
echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
|
319 |
cat /usr/local/etc/update_cat.conf | while read LIGNE_RSYNC
|
315 |
cat /usr/local/etc/update_cat.conf | while read LIGNE_RSYNC
|
320 |
do
|
316 |
do
|
321 |
CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
|
317 |
CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
|
322 |
URL=$(echo $LIGNE_RSYNC | cut -d' ' -f2)
|
318 |
URL=$(echo $LIGNE_RSYNC | cut -d' ' -f2)
|
323 |
PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
|
319 |
PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
|
324 |
rsync -rv $URL $(dirname $PATH_FILE ) #rsync inside of the blacklist directory
|
320 |
rsync -rv $URL $(dirname $PATH_FILE ) #rsync inside of the blacklist directory
|
325 |
# Creation of DNSMASQ and Iptables BL and WL
|
321 |
# Creation of DNSMASQ and Iptables BL and WL
|
326 |
DOMAINE=$(basename $PATH_FILE)
|
322 |
DOMAINE=$(basename $PATH_FILE)
|
327 |
# correct some synthaxes
|
323 |
# correct some synthaxes
|
328 |
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls
|
324 |
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls
|
329 |
# extract ip addresses for iptables
|
325 |
# extract ip addresses for iptables
|
330 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
|
326 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
|
331 |
# for dnsmask, remove IP addresses, accentuated characters and commented lines.
|
327 |
# for dnsmask, remove IP addresses, accentuated characters and commented lines.
|
332 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
|
328 |
egrep -v "^([0-9]{1,3}\.){3}[0-9]{1,3}$" $PATH_FILE/domains > $FILE_tmp
|
333 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
329 |
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
|
334 |
$SED "/^#.*/d" $FILE_tmp
|
330 |
$SED "/^#.*/d" $FILE_tmp
|
335 |
black=`grep black $PATH_FILE/usage |wc -l`
|
331 |
black=`grep black $PATH_FILE/usage |wc -l`
|
336 |
if [ $black == "1" ]
|
332 |
if [ $black == "1" ]
|
337 |
then
|
333 |
then
|
338 |
# adapt to the dnsmasq syntax for the blacklist
|
334 |
# adapt to the dnsmasq syntax for the blacklist
|
339 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
335 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp
|
340 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
|
336 |
mv $FILE_tmp $DIR_DNS_BL/$DOMAINE.conf
|
341 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
|
337 |
mv $FILE_ip_tmp $DIR_IP_BL/$DOMAINE
|
342 |
else
|
338 |
else
|
343 |
# adapt to the dnsmasq syntax for the whitelist
|
339 |
# adapt to the dnsmasq syntax for the whitelist
|
344 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
340 |
$SED "s?.*?server=/&/$DNS1?g" $FILE_tmp
|
345 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
341 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
346 |
fi
|
342 |
fi
|
347 |
rm -f $FILE_tmp $FILE_ip_tmp
|
343 |
rm -f $FILE_tmp $FILE_ip_tmp
|
348 |
done
|
344 |
done
|
349 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
345 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
350 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
346 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
351 |
/usr/bin/systemctl restart dansguardian
|
347 |
/usr/bin/systemctl restart dansguardian
|
352 |
/usr/local/bin/alcasar-iptables.sh
|
348 |
/usr/local/bin/alcasar-iptables.sh
|
353 |
else
|
349 |
else
|
354 |
echo -n "/usr/local/etc/update_cat.conf is empty ..."
|
350 |
echo -n "/usr/local/etc/update_cat.conf is empty ..."
|
355 |
fi
|
351 |
fi
|
356 |
echo
|
352 |
echo
|
357 |
;;
|
353 |
;;
|
358 |
# reload when categories are changed
|
354 |
# reload when categories are changed
|
359 |
-reload | --reload)
|
355 |
-reload | --reload)
|
360 |
# for DG
|
356 |
# for DG
|
361 |
chown -R dansguardian:apache $DIR_DG_BL/ossi
|
357 |
chown -R dansguardian:apache $DIR_DG_BL/ossi
|
362 |
chmod -R g+w $DIR_DG_BL/ossi
|
358 |
chmod -R g+w $DIR_DG_BL/ossi
|
363 |
cat_choice
|
359 |
cat_choice
|
364 |
# for dnsmasq (rehabited domain names)
|
360 |
# for dnsmasq (rehabited domain names)
|
365 |
if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
|
361 |
if [ `wc -w $DIR_DG/exceptionsitelist|cut -d " " -f1` != "0" ]
|
366 |
then
|
362 |
then
|
367 |
for i in `cat $DIR_DG/exceptionsitelist`
|
363 |
for i in `cat $DIR_DG/exceptionsitelist`
|
368 |
do
|
364 |
do
|
369 |
$SED "/$i/d" $DIR_DNS_BL/*
|
365 |
$SED "/$i/d" $DIR_DNS_BL/*
|
370 |
done
|
366 |
done
|
371 |
fi
|
367 |
fi
|
372 |
cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
|
368 |
cp -f $DIR_DG_BL/ossi/domains $DIR_DNS_BL/ossi.conf
|
373 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
|
369 |
$SED "s?.*?address=/&/$PRIVATE_IP?g" $DIR_DNS_BL/ossi.conf
|
374 |
$SED "s?.*?server=/&/$DNS1?g" $DIR_DNS_WL/ossi.conf
|
370 |
$SED "s?.*?server=/&/$DNS1?g" $DIR_DNS_WL/ossi.conf
|
375 |
|
371 |
|
376 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
372 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
377 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
373 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
378 |
/usr/local/bin/alcasar-iptables.sh
|
374 |
/usr/local/bin/alcasar-iptables.sh
|
379 |
;;
|
375 |
;;
|
380 |
*)
|
376 |
*)
|
381 |
echo "Argument inconnu :$1";
|
377 |
echo "Argument inconnu :$1";
|
382 |
echo "$usage"
|
378 |
echo "$usage"
|
383 |
exit 1
|
379 |
exit 1
|
384 |
;;
|
380 |
;;
|
385 |
esac
|
381 |
esac
|
386 |
|
382 |
|
387 |
|
383 |
|
388 |
|
384 |
|
389 |
|
385 |
|
390 |
|
386 |
|