Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
# $Id: alcasar-conf.sh 1961 2016-06-23 21:23:34Z richard $
|
2 |
# $Id: alcasar-conf.sh 1969 2016-06-28 22:12:54Z richard $
|
3 |
|
3 |
|
4 |
# alcasar-conf.sh
|
4 |
# alcasar-conf.sh
|
5 |
# by REXY
|
5 |
# by REXY
|
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
7 |
|
7 |
|
Line 16... |
Line 16... |
16 |
|
16 |
|
17 |
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
|
17 |
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
|
18 |
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
|
18 |
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
|
19 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
19 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
20 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
20 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
21 |
DIR_BIN="/usr/local/bin" # répertoire des scripts d'admin
|
21 |
DIR_BIN="/usr/local/bin" # scripts directory
|
22 |
DIR_ETC="/usr/local/etc" # répertoire des fichiers de conf
|
22 |
DIR_ETC="/usr/local/etc" # conf directory
|
- |
|
23 |
DIR_SHARE="/usr/local/share" # data directory
|
23 |
DIR_BLACKLIST="/etc/dansguardian/lists/blacklists" # répertoire de la BL de Toulouse
|
24 |
DIR_BLACKLIST="/etc/dansguardian/lists/blacklists" # Toulouse BL directory
|
24 |
CONF_FILE="$DIR_ETC/alcasar.conf" # main alcasar conf file
|
25 |
CONF_FILE="$DIR_ETC/alcasar.conf" # main alcasar conf file
|
25 |
VERSION="/var/www/html/VERSION" # contient la version en cours
|
26 |
VERSION="/var/www/html/VERSION" # contient la version en cours
|
26 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
27 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
27 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
28 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
28 |
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
29 |
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
Line 36... |
Line 37... |
36 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
37 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
37 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
38 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
38 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
39 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
39 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
40 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
40 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2` 2>/dev/null
|
41 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2` 2>/dev/null
|
- |
|
42 |
DNS1=`grep "DNS1" $CONF_FILE | cut -d '=' -f 2` # server DNS1 (for WL domain names)
|
41 |
DOMAIN=${DOMAIN:=localdomain}
|
43 |
DOMAIN=${DOMAIN:=localdomain}
|
42 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
44 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
43 |
private_network_calc ()
|
45 |
private_network_calc ()
|
44 |
{
|
46 |
{
|
45 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
47 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
Line 304... |
Line 306... |
304 |
# Alcasar Control Center
|
306 |
# Alcasar Control Center
|
305 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
307 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
306 |
FIC_MOD_SSL=`find /etc/httpd/conf/ -type f -name ssl.conf`
|
308 |
FIC_MOD_SSL=`find /etc/httpd/conf/ -type f -name ssl.conf`
|
307 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
309 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
308 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
310 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
309 |
# Dialup_Admin
|
311 |
# ACC
|
310 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
312 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
311 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
313 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
312 |
# coova
|
314 |
# coova
|
313 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
315 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
314 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
316 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
Line 322... |
Line 324... |
322 |
do
|
324 |
do
|
323 |
$SED "/^server=/d" $i
|
325 |
$SED "/^server=/d" $i
|
324 |
echo "server=$DNS1" >> $i
|
326 |
echo "server=$DNS1" >> $i
|
325 |
echo "server=$DNS2" >> $i
|
327 |
echo "server=$DNS2" >> $i
|
326 |
done
|
328 |
done
|
327 |
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
|
329 |
$SED "s?^address=.*?address=/#/$PRIVATE_IP?g" /etc/dnsmasq-blackhole.conf
|
- |
|
330 |
for i in `ls $DIR_SHARE/dnsmasq-wl`
|
- |
|
331 |
do
|
- |
|
332 |
cat $DIR_SHARE/dnsmasq-wl/$i|cut -d"/" -f1,2 > /tmp/tmp_file
|
- |
|
333 |
$SED "s/$/\/$DNS1/" /tmp/tmp_file
|
- |
|
334 |
mv -f /tmp/tmp_file $DIR_SHARE/dnsmasq-wl/$i
|
- |
|
335 |
done
|
- |
|
336 |
chown root:apache $DIR_SHARE/dnsmasq-wl/*
|
- |
|
337 |
chmod 660 $DIR_SHARE/dnsmasq-wl/*
|
328 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
338 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
- |
|
339 |
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
|
329 |
# tinyproxy
|
340 |
# tinyproxy
|
330 |
$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
|
341 |
$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
|
331 |
# DG + BL
|
342 |
# DG + BL
|
332 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
343 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
333 |
# Watchdog
|
344 |
# Watchdog
|