Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
|
2 |
|
3 |
# $Id: alcasar-bl.sh 1365 2014-05-28 14:38:29Z richard $
|
3 |
# $Id: alcasar-bl.sh 1366 2014-05-29 09:21:47Z 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 15... |
Line 15... |
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 |
FILE_tmp="/tmp/filesfilter.txt"
|
18 |
FILE_tmp="/tmp/filesfilter.txt"
|
19 |
FILE_ip_tmp="/tmp/filesipfilter.txt"
|
19 |
FILE_ip_tmp="/tmp/filesipfilter.txt"
|
20 |
FILE_IP_WL="/usr/local/share/ossi_wl"
|
- |
|
21 |
DIR_DG="/etc/dansguardian/lists"
|
20 |
DIR_DG="/etc/dansguardian/lists"
|
22 |
DIR_DG_BL="$DIR_DG/blacklists"
|
21 |
DIR_DG_BL="$DIR_DG/blacklists"
|
23 |
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories" # list of names of the BL categories
|
22 |
BL_CATEGORIES="$DIR_CONF/alcasar-bl-categories" # list of names of the BL categories
|
24 |
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories" #' ' WL '
|
23 |
WL_CATEGORIES="$DIR_CONF/alcasar-wl-categories" #' ' WL '
|
25 |
BL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-bl-categories-enabled" # ' ' BL enabled categories
|
24 |
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
|
25 |
WL_CATEGORIES_ENABLED="$DIR_CONF/alcasar-wl-categories-enabled" # ' ' WL enabled categories
|
27 |
DIR_SHARE="/usr/local/share"
|
26 |
DIR_SHARE="/usr/local/share"
|
- |
|
27 |
FILE_IP_WL="$DIR_SHARE/ossi_wl"
|
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_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the dnsmasq BL (only enabled categories)
|
31 |
DIR_DNS_BL_ENABLED="$DIR_SHARE/dnsmasq-bl-enabled" # symbolic link to the domains BL (only enabled categories)
|
32 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' ' '
|
32 |
DIR_DNS_WL_ENABLED="$DIR_SHARE/dnsmasq-wl-enabled" # ' ' ' WL ' ' '
|
33 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
33 |
DIR_IP_BL_ENABLED="$DIR_SHARE/iptables-bl-enabled" # ' ' ip BL (only enabled categories)
|
34 |
DNSMASQ_BL_CONF="/etc/dnsmasq-blacklist.conf" # conf file of dnsmasq-blacklist
|
34 |
DNSMASQ_BL_CONF="/etc/dnsmasq-blacklist.conf" # conf file of dnsmasq-blacklist
|
35 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
35 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
36 |
BL_SERVER="dsi.ut-capitole.fr"
|
36 |
BL_SERVER="dsi.ut-capitole.fr"
|
Line 147... |
Line 147... |
147 |
else
|
147 |
else
|
148 |
touch $FILE_IP_WL
|
148 |
touch $FILE_IP_WL
|
149 |
chown apache $FILE_IP_WL
|
149 |
chown apache $FILE_IP_WL
|
150 |
fi
|
150 |
fi
|
151 |
# Saving ossi category
|
151 |
# Saving ossi category
|
152 |
cp $DIR_IP_BL/ossi $DIR_tmp/ossi-ip
|
- |
|
153 |
if [ -f $DIR_tmp/blacklists.tar.gz ]
|
152 |
if [ -f $DIR_tmp/blacklists.tar.gz ]
|
154 |
then
|
153 |
then
|
155 |
[ -d $DIR_DG_BL/ossi ] && mv -f $DIR_DG_BL/ossi $DIR_tmp
|
154 |
[ -d $DIR_DG_BL/ossi ] && mv $DIR_DG_BL/ossi $DIR_tmp
|
- |
|
155 |
[ -e $DIR_IP_BL/ossi ] && mv $DIR_IP_BL/ossi $DIR_tmp/ossi-ip
|
156 |
rm -rf $DIR_DG_BL
|
156 |
rm -rf $DIR_DG_BL
|
157 |
mkdir $DIR_DG_BL
|
157 |
mkdir $DIR_DG_BL
|
158 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
158 |
tar zxf $DIR_tmp/blacklists.tar.gz --directory=$DIR_DG/
|
159 |
[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DG_BL/
|
159 |
[ -d $DIR_tmp/ossi ] && mv -f $DIR_tmp/ossi $DIR_DG_BL/
|
160 |
fi
|
160 |
fi
|
Line 221... |
Line 221... |
221 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
221 |
mv $FILE_tmp $DIR_DNS_WL/$DOMAINE.conf
|
222 |
fi
|
222 |
fi
|
223 |
done
|
223 |
done
|
224 |
done
|
224 |
done
|
225 |
rm -f $FILE_tmp $FILE_ip_tmp
|
225 |
rm -f $FILE_tmp $FILE_ip_tmp
|
226 |
# Restoring ossi category
|
226 |
# Restoring ossi files
|
227 |
mv $DIR_tmp/ossi-ip $DIR_IP_BL/ossi
|
227 |
[ -e $DIR_tmp/ossi-ip ] && mv $DIR_tmp/ossi-ip $DIR_IP_BL/ossi
|
228 |
# Restoring whitelist ip
|
- |
|
229 |
if [ -e $DIR_tmp/ossi_wl ]
|
- |
|
230 |
then
|
- |
|
231 |
mv $DIR_tmpi/ossi_wl /usr/local/share/
|
228 |
[ -e $DIR_tmp/ossi_wl ] && mv $DIR_tmpi/ossi_wl $DIR_SHARE/ossi_wl
|
232 |
fi
|
229 |
fi
|
233 |
rm -rf $DIR_tmp
|
230 |
rm -rf $DIR_tmp
|
234 |
echo
|
231 |
echo
|
235 |
;;
|
232 |
;;
|
236 |
# reload when categories are changed
|
233 |
# reload when categories are changed
|