1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
# $Id: alcasar-conf.sh 923 2012-07-03 06:34:18Z franck $
|
2 |
# $Id: alcasar-conf.sh 933 2012-07-05 15:57:15Z franck $
|
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 |
|
8 |
# Ce script permet la mise à jour ALCASAR
|
8 |
# Ce script permet la mise à jour ALCASAR
|
9 |
# - création et chargement de l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
|
9 |
# - création et chargement de l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
|
10 |
# - application des directives du fichier de conf central (/usr/local/etc/alcasar.conf)
|
10 |
# - application des directives du fichier de conf central (/usr/local/etc/alcasar.conf)
|
11 |
# This script allows ALCASAR update
|
11 |
# This script allows ALCASAR update
|
12 |
# - create and load the configuration files backup (/tmp/alcasar-conf.tar.gz)
|
12 |
# - create and load the configuration files backup (/tmp/alcasar-conf.tar.gz)
|
13 |
# - apply ALCASAR central configuration file (/usr/local/etc/alcasar.conf)
|
13 |
# - apply ALCASAR central configuration file (/usr/local/etc/alcasar.conf)
|
14 |
|
14 |
|
15 |
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
|
15 |
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
|
16 |
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
|
16 |
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
|
17 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
17 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
18 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
18 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
19 |
DIR_BIN="/usr/local/bin" # répertoire des scripts d'admin
|
19 |
DIR_BIN="/usr/local/bin" # répertoire des scripts d'admin
|
20 |
DIR_SBIN="/usr/local/sbin" # répertoire des scripts d'admin
|
20 |
DIR_SBIN="/usr/local/sbin" # répertoire des scripts d'admin
|
21 |
DIR_ETC="/usr/local/etc" # répertoire des fichiers de conf
|
21 |
DIR_ETC="/usr/local/etc" # répertoire des fichiers de conf
|
22 |
DIR_SAVE="/var/Save/system_backup" # répertoire de sauvegarde
|
22 |
DIR_SAVE="/var/Save/system_backup" # répertoire de sauvegarde
|
23 |
CONF_FILE="$DIR_ETC/alcasar.conf" # main alcasar conf file
|
23 |
CONF_FILE="$DIR_ETC/alcasar.conf" # main alcasar conf file
|
24 |
VERSION="/var/www/html/VERSION" # contient la version en cours
|
24 |
VERSION="/var/www/html/VERSION" # contient la version en cours
|
25 |
EXTIF="eth0" # ETH0 est l'interface connectée à Internet (Box FAI)
|
25 |
EXTIF="eth0" # ETH0 est l'interface connectée à Internet (Box FAI)
|
26 |
INTIF="eth1" # ETH1 est l'interface connectée au réseau local de consultation
|
26 |
INTIF="eth1" # ETH1 est l'interface connectée au réseau local de consultation
|
27 |
HOSTNAME="alcasar"
|
27 |
HOSTNAME="alcasar"
|
28 |
DB_USER="radius"
|
28 |
DB_USER="radius"
|
29 |
radiuspwd=""
|
29 |
radiuspwd=""
|
30 |
SED="/bin/sed -i"
|
30 |
SED="/bin/sed -i"
|
31 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
31 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
32 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
32 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
33 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
33 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
34 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
34 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
35 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
35 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
36 |
DOMAIN=${DOMAIN:=localdomain}
|
36 |
DOMAIN=${DOMAIN:=localdomain}
|
37 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
37 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
38 |
private_network_calc ()
|
38 |
private_network_calc ()
|
39 |
{
|
39 |
{
|
40 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
40 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
41 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
|
41 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
|
42 |
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ + masque du réseau de consult (192.168.182.0/24)
|
42 |
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ + masque du réseau de consult (192.168.182.0/24)
|
43 |
classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2` # classes de réseau (ex.: 2=classe B, 3=classe C)
|
43 |
classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2` # classes de réseau (ex.: 2=classe B, 3=classe C)
|
44 |
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
|
44 |
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
|
45 |
}
|
45 |
}
|
46 |
|
46 |
|
47 |
usage="Usage: alcasar-conf.sh {--create ou -create} | {--load or -load} | {--apply or -apply}"
|
47 |
usage="Usage: alcasar-conf.sh {--create or -create} | {--load or -load} | {--apply or -apply}"
|
48 |
nb_args=$#
|
48 |
nb_args=$#
|
49 |
args=$1
|
49 |
args=$1
|
50 |
if [ $nb_args -eq 0 ]
|
50 |
if [ $nb_args -eq 0 ]
|
51 |
then
|
51 |
then
|
52 |
nb_args=1
|
52 |
nb_args=1
|
53 |
args="-h"
|
53 |
args="-h"
|
54 |
fi
|
54 |
fi
|
55 |
case $args in
|
55 |
case $args in
|
56 |
-\? | -h* | --h*)
|
56 |
-\? | -h* | --h*)
|
57 |
echo "$usage"
|
57 |
echo "$usage"
|
58 |
exit 0
|
58 |
exit 0
|
59 |
;;
|
59 |
;;
|
60 |
--create|-create)
|
60 |
--create|-create)
|
61 |
[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
|
61 |
[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
|
62 |
mkdir $DIR_UPDATE
|
62 |
mkdir $DIR_UPDATE
|
63 |
# Sauvegarde de la base des usagers
|
63 |
# Sauvegarde de la base des usagers
|
64 |
/usr/local/sbin/alcasar-mysql.sh -dump
|
64 |
/usr/local/sbin/alcasar-mysql.sh -dump
|
65 |
cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
|
65 |
cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
|
66 |
# Sauvegarde du logo
|
66 |
# Sauvegarde du logo
|
67 |
cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
|
67 |
cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
|
68 |
# Sauvegarde des fichiers exploités par dansguardian
|
68 |
# Sauvegarde des fichiers exploités par dansguardian
|
69 |
cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
|
69 |
cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
|
70 |
cp -f /etc/dansguardian/lists/urlregexplist $DIR_UPDATE
|
70 |
cp -f /etc/dansguardian/lists/urlregexplist $DIR_UPDATE
|
71 |
cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
|
71 |
cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
|
72 |
cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE
|
72 |
cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE
|
73 |
cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE
|
73 |
cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE
|
74 |
cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE
|
74 |
cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE
|
75 |
cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
|
75 |
cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
|
76 |
# sauvegarde des fichiers : de conf, de filtrage, d'exception, digest, etc.
|
76 |
# sauvegarde des fichiers : de conf, de filtrage, d'exception, digest, etc.
|
77 |
mkdir $DIR_UPDATE/etc/
|
77 |
mkdir $DIR_UPDATE/etc/
|
78 |
cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
|
78 |
cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
|
79 |
# particularité des versions
|
79 |
# particularité des versions
|
80 |
rm -f $DIR_UPDATE/etc/alcasar-macallowed # macallowed is replaced with macauth
|
80 |
rm -f $DIR_UPDATE/etc/alcasar-macallowed # macallowed is replaced with macauth
|
81 |
# si version <= 2.0
|
81 |
# si version <= 2.0
|
82 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -eq 0 ])
|
82 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -eq 0 ])
|
83 |
then
|
83 |
then
|
84 |
rm -f $DIR_UPDATE/etc/alcasar-dns-name # changement de format
|
84 |
rm -f $DIR_UPDATE/etc/alcasar-dns-name # changement de format
|
85 |
rm -rf $DIR_UPDATE/etc/digest # hostname=alcasar
|
85 |
rm -rf $DIR_UPDATE/etc/digest # hostname=alcasar
|
86 |
if [ -e $DIR_UPDATE/etc/alcasar-uamallowed ]; then
|
86 |
if [ -e $DIR_UPDATE/etc/alcasar-uamallowed ]; then
|
87 |
uamallowed=`cat $DIR_UPDATE/etc/alcasar-uamallowed`
|
87 |
uamallowed=`cat $DIR_UPDATE/etc/alcasar-uamallowed`
|
88 |
if [ $uamallowed == "uamallowed=\"\"" ]
|
88 |
if [ $uamallowed == "uamallowed=\"\"" ]
|
89 |
then rm -f $DIR_UPDATE/etc/alcasar-uamallowed # un uamallowed 'vide' perturbe coova
|
89 |
then rm -f $DIR_UPDATE/etc/alcasar-uamallowed # un uamallowed 'vide' perturbe coova
|
90 |
fi
|
90 |
fi
|
91 |
fi
|
91 |
fi
|
92 |
if [ -e $DIR_UPDATE/etc/alcasar-uamdomain ]; then
|
92 |
if [ -e $DIR_UPDATE/etc/alcasar-uamdomain ]; then
|
93 |
uamdomain=`cat $DIR_UPDATE/etc/alcasar-uamdomain`
|
93 |
uamdomain=`cat $DIR_UPDATE/etc/alcasar-uamdomain`
|
94 |
if [ $uamdomain == "uamdomain=\"\"" ]
|
94 |
if [ $uamdomain == "uamdomain=\"\"" ]
|
95 |
then rm -f $DIR_UPDATE/etc/alcasar-uamdomain # un uamdomain 'vide' perturbe coova
|
95 |
then rm -f $DIR_UPDATE/etc/alcasar-uamdomain # un uamdomain 'vide' perturbe coova
|
96 |
fi
|
96 |
fi
|
97 |
fi
|
97 |
fi
|
98 |
else
|
98 |
else
|
99 |
# si version >= 2.1 : sauvegarde des certificats (serveur et CA)
|
99 |
# si version >= 2.1 : sauvegarde des certificats (serveur et CA)
|
100 |
mkdir $DIR_UPDATE/pki/
|
100 |
mkdir $DIR_UPDATE/pki/
|
101 |
cert_date=`/usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d"=" -f2`
|
101 |
cert_date=`/usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d"=" -f2`
|
102 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE
|
102 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE
|
103 |
cp -f /etc/pki/tls/private/alcasar.key $DIR_UPDATE
|
103 |
cp -f /etc/pki/tls/private/alcasar.key $DIR_UPDATE
|
104 |
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
|
104 |
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
|
105 |
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
|
105 |
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
|
106 |
if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
|
106 |
if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
|
107 |
cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
|
107 |
cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
|
108 |
else
|
108 |
else
|
109 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
|
109 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
|
110 |
fi
|
110 |
fi
|
111 |
fi
|
111 |
fi
|
112 |
# si version < 2.2
|
112 |
# si version < 2.2
|
113 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ])
|
113 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ])
|
114 |
then
|
114 |
then
|
115 |
ORGANISM=`cat $DIR_WEB/intercept.php|grep '$organisme =' | cut -d"=" -f2|tr -d ";\" "` # Sauvegarde du nom d'organisme
|
115 |
ORGANISM=`cat $DIR_WEB/intercept.php|grep '$organisme =' | cut -d"=" -f2|tr -d ";\" "` # Sauvegarde du nom d'organisme
|
116 |
rm -f $DIR_UPDATE/etc/alcasar-ethers # This file doesn't contain comments
|
116 |
rm -f $DIR_UPDATE/etc/alcasar-ethers # This file doesn't contain comments
|
117 |
rm -f $DIR_UPDATE/exceptionurllist # This file was not empty (comments)
|
117 |
rm -f $DIR_UPDATE/exceptionurllist # This file was not empty (comments)
|
118 |
# Create the initial conf file (doesn't exist in earlier versions)
|
118 |
# Create the initial conf file (doesn't exist in earlier versions)
|
119 |
cat <<EOF > $CONF_FILE
|
119 |
cat <<EOF > $CONF_FILE
|
120 |
##########################################
|
120 |
##########################################
|
121 |
## ##
|
121 |
## ##
|
122 |
## ALCASAR Parameters ##
|
122 |
## ALCASAR Parameters ##
|
123 |
## ##
|
123 |
## ##
|
124 |
##########################################
|
124 |
##########################################
|
125 |
|
125 |
|
126 |
INSTALL_DATE=$DATE
|
126 |
INSTALL_DATE=$DATE
|
127 |
VERSION=$RUNNING_VERSION
|
127 |
VERSION=$RUNNING_VERSION
|
128 |
ORGANISM=$ORGANISM
|
128 |
ORGANISM=$ORGANISM
|
129 |
DOMAIN=$DOMAIN
|
129 |
DOMAIN=$DOMAIN
|
130 |
EOF
|
130 |
EOF
|
131 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
|
131 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
|
132 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
132 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
133 |
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
133 |
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
134 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
134 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
135 |
DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 1er DNS
|
135 |
DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 1er DNS
|
136 |
DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 2ème DNS
|
136 |
DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 2ème DNS
|
137 |
DNS1=${DNS1:=208.67.220.220}
|
137 |
DNS1=${DNS1:=208.67.220.220}
|
138 |
DNS2=${DNS2:=208.67.222.222}
|
138 |
DNS2=${DNS2:=208.67.222.222}
|
139 |
PRIVATE_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2` # @ip du portail (côté LAN)
|
139 |
PRIVATE_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2` # @ip du portail (côté LAN)
|
140 |
PRIVATE_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2`
|
140 |
PRIVATE_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2`
|
141 |
private_network_calc
|
141 |
private_network_calc
|
142 |
echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $CONF_FILE
|
142 |
echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $CONF_FILE
|
143 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
143 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
144 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
144 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
145 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
145 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
146 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
146 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
147 |
echo "DHCP=half" >> $CONF_FILE
|
147 |
echo "DHCP=half" >> $CONF_FILE
|
148 |
echo "EXT_DHCP_IP=none" >> $CONF_FILE
|
148 |
echo "EXT_DHCP_IP=none" >> $CONF_FILE
|
149 |
echo "RELAY_DHCP_IP=none" >> $CONF_FILE
|
149 |
echo "RELAY_DHCP_IP=none" >> $CONF_FILE
|
150 |
echo "RELAY_DHCP_PORT=none" >> $CONF_FILE
|
150 |
echo "RELAY_DHCP_PORT=none" >> $CONF_FILE
|
151 |
|
151 |
|
152 |
if [ -r /var/run/sshd.pid ]; then
|
152 |
if [ -r /var/run/sshd.pid ]; then
|
153 |
echo "SSH=on" >> $CONF_FILE
|
153 |
echo "SSH=on" >> $CONF_FILE
|
154 |
else
|
154 |
else
|
155 |
echo "SSH=off" >> $CONF_FILE
|
155 |
echo "SSH=off" >> $CONF_FILE
|
156 |
fi
|
156 |
fi
|
157 |
echo "QOS=off" >> $CONF_FILE
|
157 |
echo "QOS=off" >> $CONF_FILE
|
158 |
echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
|
158 |
echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
|
159 |
if [ `grep ^ldap /etc/raddb/sites-available/alcasar | wc -l` -eq "0" ]; then
|
159 |
if [ `grep ^ldap /etc/raddb/sites-available/alcasar | wc -l` -eq "0" ]; then
|
160 |
echo "LDAP=off" >> $CONF_FILE
|
160 |
echo "LDAP=off" >> $CONF_FILE
|
161 |
else
|
161 |
else
|
162 |
echo "LDAP=on" >> $CONF_FILE
|
162 |
echo "LDAP=on" >> $CONF_FILE
|
163 |
fi
|
163 |
fi
|
164 |
PROTOCOLS_FILTERING=`grep ^PROTO_FILTERING /usr/local/bin/alcasar-iptables.sh | cut -d"=" -f2`
|
164 |
PROTOCOLS_FILTERING=`grep ^PROTO_FILTERING /usr/local/bin/alcasar-iptables.sh | cut -d"=" -f2`
|
165 |
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:="no"}
|
165 |
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:="no"}
|
166 |
if [ $PROTOCOLS_FILTERING = "no" ]; then
|
166 |
if [ $PROTOCOLS_FILTERING = "no" ]; then
|
167 |
echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
|
167 |
echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
|
168 |
else
|
168 |
else
|
169 |
echo "PROTOCOLS_FILTERING=on" >> $CONF_FILE
|
169 |
echo "PROTOCOLS_FILTERING=on" >> $CONF_FILE
|
170 |
fi
|
170 |
fi
|
171 |
DNS_FILTERING=`grep ^reportinglevel /etc/dansguardian/dansguardian.conf | cut -d"=" -f2 | tr -d " "`
|
171 |
DNS_FILTERING=`grep ^reportinglevel /etc/dansguardian/dansguardian.conf | cut -d"=" -f2 | tr -d " "`
|
172 |
DNS_FILTERING=${DNS_FILTERING:="-1"}
|
172 |
DNS_FILTERING=${DNS_FILTERING:="-1"}
|
173 |
if [ $DNS_FILTERING -eq "-1" ]; then
|
173 |
if [ $DNS_FILTERING -eq "-1" ]; then
|
174 |
echo "DNS_FILTERING=off" >> $CONF_FILE
|
174 |
echo "DNS_FILTERING=off" >> $CONF_FILE
|
175 |
else
|
175 |
else
|
176 |
echo "DNS_FILTERING=on" >> $CONF_FILE
|
176 |
echo "DNS_FILTERING=on" >> $CONF_FILE
|
177 |
fi
|
177 |
fi
|
178 |
fi
|
178 |
fi
|
179 |
# DHCP mode can be "off/half/full" since V2.6
|
179 |
# DHCP mode can be "off/half/full" since V2.6
|
180 |
DHCP_mode=`cat $CONF_FILE|grep DHCP=|cut -d"=" -f2`
|
180 |
DHCP_mode=`cat $CONF_FILE|grep DHCP=|cut -d"=" -f2`
|
181 |
if [ $DHCP_mode = "on" ]; then
|
181 |
if [ $DHCP_mode = "on" ]; then
|
182 |
$SED "s?^DHCP=on.*?DHCP=half?" $CONF_FILE # DHCP option can be "off/half/full" since V2.6
|
182 |
$SED "s?^DHCP=on.*?DHCP=half?" $CONF_FILE # DHCP option can be "off/half/full" since V2.6
|
183 |
fi
|
183 |
fi
|
184 |
# le paramêtre 'EXT_LAN_FILTERING' n'existe plus depuis la V2.6
|
184 |
# le paramêtre 'EXT_LAN_FILTERING' n'existe plus depuis la V2.6
|
185 |
$SED "/^EXT_LAN/d" $CONF_FILE
|
185 |
$SED "/^EXT_LAN/d" $CONF_FILE
|
186 |
# la catégorie de sites filtrés "ip" n'existe plus depuis la V2.6
|
186 |
# la catégorie de sites filtrés "ip" n'existe plus depuis la V2.6
|
187 |
$SED "/\/ip\/urls/d" $DIR_UPDATE/bannedurllist; $SED "/\/ip\/domains/d" $DIR_UPDATE/bannedsitelist
|
187 |
$SED "/\/ip\/urls/d" $DIR_UPDATE/bannedurllist; $SED "/\/ip\/domains/d" $DIR_UPDATE/bannedsitelist
|
188 |
$SED "/blacklists\/ip/d" $DIR_UPDATE/etc/alcasar-bl-categories; $SED "/^ip/d" $DIR_UPDATE/etc/alcasar-bl-categories-enabled
|
188 |
$SED "/blacklists\/ip/d" $DIR_UPDATE/etc/alcasar-bl-categories; $SED "/^ip/d" $DIR_UPDATE/etc/alcasar-bl-categories-enabled
|
189 |
# bing et Youtube sont ajoutés au safesearching depuis la V2.6
|
189 |
# bing et Youtube sont ajoutés au safesearching depuis la V2.6
|
190 |
Bing=`grep bing $DIR_UPDATE/urlregexplist | wc -l`
|
190 |
Bing=`grep bing $DIR_UPDATE/urlregexplist | wc -l`
|
191 |
if [ $Bing -ne "1" ]; then
|
191 |
if [ $Bing -ne "1" ]; then
|
192 |
SafeSearch=`grep ^\"\(\^http\:\/\/ $DIR_UPDATE/urlregexplist | wc -l`
|
192 |
SafeSearch=`grep ^\"\(\^http\:\/\/ $DIR_UPDATE/urlregexplist | wc -l`
|
193 |
if [ $SafeSearch -eq "0" ]; then
|
193 |
if [ $SafeSearch -eq "0" ]; then
|
194 |
cat <<EOF >> $DIR_UPDATE/urlregexplist
|
194 |
cat <<EOF >> $DIR_UPDATE/urlregexplist
|
195 |
# Bing - add 'adlt=strict'
|
195 |
# Bing - add 'adlt=strict'
|
196 |
#"(^http://[0-9a-z]+\.bing\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&adlt=strict"
|
196 |
#"(^http://[0-9a-z]+\.bing\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&adlt=strict"
|
197 |
# Youtube - add 'edufilter=your_ID'
|
197 |
# Youtube - add 'edufilter=your_ID'
|
198 |
#"(^http://[0-9a-z]+\.youtube\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&edufilter=ABCD1234567890abcdef"
|
198 |
#"(^http://[0-9a-z]+\.youtube\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&edufilter=ABCD1234567890abcdef"
|
199 |
EOF
|
199 |
EOF
|
200 |
else
|
200 |
else
|
201 |
cat <<EOF >> $DIR_UPDATE/urlregexplist
|
201 |
cat <<EOF >> $DIR_UPDATE/urlregexplist
|
202 |
# Bing - add 'adlt=strict'
|
202 |
# Bing - add 'adlt=strict'
|
203 |
"(^http://[0-9a-z]+\.bing\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&adlt=strict"
|
203 |
"(^http://[0-9a-z]+\.bing\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&adlt=strict"
|
204 |
# Youtube - add 'edufilter=your_ID'
|
204 |
# Youtube - add 'edufilter=your_ID'
|
205 |
"(^http://[0-9a-z]+\.youtube\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&edufilter=ABCD1234567890abcdef"
|
205 |
"(^http://[0-9a-z]+\.youtube\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&edufilter=ABCD1234567890abcdef"
|
206 |
EOF
|
206 |
EOF
|
207 |
fi
|
207 |
fi
|
208 |
fi
|
208 |
fi
|
209 |
# la variable YOUTUBE_ID est déclarée dans le fichier de conf depuis la V2.6
|
209 |
# la variable YOUTUBE_ID est déclarée dans le fichier de conf depuis la V2.6
|
210 |
YOUTUBE_ID=`grep ^YOUTUBE_ID $CONF_FILE | cut -d"=" -f2`
|
210 |
YOUTUBE_ID=`grep ^YOUTUBE_ID $CONF_FILE | cut -d"=" -f2`
|
211 |
YOUTUBE_ID=${YOUTUBE_ID:="-1"}
|
211 |
YOUTUBE_ID=${YOUTUBE_ID:="-1"}
|
212 |
if [ $YOUTUBE_ID = "-1" ]; then
|
212 |
if [ $YOUTUBE_ID = "-1" ]; then
|
213 |
echo "YOUTUBE_ID=ABCD1234567890abcdef" >> $CONF_FILE
|
213 |
echo "YOUTUBE_ID=ABCD1234567890abcdef" >> $CONF_FILE
|
214 |
fi
|
214 |
fi
|
- |
|
215 |
cp /etc/sysconfig/dnsmasq $DIR_UPDATE
|
215 |
# copie du fichier de conf modifié
|
216 |
# copie du fichier de conf modifié
|
216 |
cp $CONF_FILE $DIR_UPDATE/etc/
|
217 |
cp $CONF_FILE $DIR_UPDATE/etc/
|
217 |
# le répertoire "ISO" est remplacé par "system_backup" suite à la suppression de "mondoarchive" (V2.5)
|
218 |
# le répertoire "ISO" est remplacé par "system_backup" suite à la suppression de "mondoarchive" (V2.5)
|
218 |
rm -rf /var/Save/ISO
|
219 |
rm -rf /var/Save/ISO
|
219 |
# création de l'archive et copie dans le répertoire WEB associé
|
220 |
# création de l'archive et copie dans le répertoire WEB associé
|
220 |
cd /tmp
|
221 |
cd /tmp
|
221 |
tar -cf alcasar-conf.tar conf/
|
222 |
tar -cf alcasar-conf.tar conf/
|
222 |
gzip -f alcasar-conf.tar
|
223 |
gzip -f alcasar-conf.tar
|
223 |
[ -d $DIR_SAVE ] && cp alcasar-conf.tar.gz $DIR_SAVE/$fichier
|
224 |
[ -d $DIR_SAVE ] && cp alcasar-conf.tar.gz $DIR_SAVE/$fichier
|
224 |
rm -rf $DIR_UPDATE
|
225 |
rm -rf $DIR_UPDATE
|
225 |
;;
|
226 |
;;
|
226 |
--load|-load)
|
227 |
--load|-load)
|
227 |
cd /tmp
|
228 |
cd /tmp
|
228 |
tar -xf /tmp/alcasar-conf.tar.gz
|
229 |
tar -xf /tmp/alcasar-conf.tar.gz
|
229 |
# Récupération du logo
|
230 |
# Récupération du logo
|
230 |
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
|
231 |
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
|
231 |
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
|
232 |
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
|
232 |
# Récupération des certificats (CA et serveur)
|
233 |
# Récupération des certificats (CA et serveur)
|
233 |
[ -e $DIR_UPDATE/alcasar-ca.crt ] && cp -f $DIR_UPDATE/alcasar-ca.crt /etc/pki/CA/
|
234 |
[ -e $DIR_UPDATE/alcasar-ca.crt ] && cp -f $DIR_UPDATE/alcasar-ca.crt /etc/pki/CA/
|
234 |
[ -e $DIR_UPDATE/alcasar-ca.key ] && cp -f $DIR_UPDATE/alcasar-ca.key /etc/pki/CA/private/
|
235 |
[ -e $DIR_UPDATE/alcasar-ca.key ] && cp -f $DIR_UPDATE/alcasar-ca.key /etc/pki/CA/private/
|
235 |
[ -e $DIR_UPDATE/alcasar.crt ] && cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
|
236 |
[ -e $DIR_UPDATE/alcasar.crt ] && cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
|
236 |
[ -e $DIR_UPDATE/alcasar.key ] && cp -f $DIR_UPDATE/alcasar.key /etc/pki/tls/private/
|
237 |
[ -e $DIR_UPDATE/alcasar.key ] && cp -f $DIR_UPDATE/alcasar.key /etc/pki/tls/private/
|
237 |
[ -e $DIR_UPDATE/server-chain.crt ] && cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
|
238 |
[ -e $DIR_UPDATE/server-chain.crt ] && cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
|
238 |
chown -R root:apache /etc/pki
|
239 |
chown -R root:apache /etc/pki
|
239 |
chmod -R 750 /etc/pki
|
240 |
chmod -R 750 /etc/pki
|
240 |
# Import de la dernière base usagers
|
241 |
# Import de la dernière base usagers
|
241 |
mysql -u$DB_USER -p$radiuspwd < `ls $DIR_UPDATE/radius*`
|
242 |
mysql -u$DB_USER -p$radiuspwd < `ls $DIR_UPDATE/radius*`
|
242 |
# Récupération des paramêtres locaux (fichier de conf, règles de filtrage, fichiers d'exception, comptes de gestion, etc.)
|
243 |
# Récupération des paramêtres locaux (fichier de conf, règles de filtrage, fichiers d'exception, comptes de gestion, etc.)
|
243 |
[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
|
244 |
[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
|
244 |
# Récupération des fichiers de Dansguardian
|
245 |
# Récupération des fichiers de Dansguardian
|
245 |
[ -e $DIR_UPDATE/exceptioniplist ] && cp -f $DIR_UPDATE/exceptioniplist /etc/dansguardian/lists/
|
246 |
[ -e $DIR_UPDATE/exceptioniplist ] && cp -f $DIR_UPDATE/exceptioniplist /etc/dansguardian/lists/
|
246 |
[ -e $DIR_UPDATE/exceptionsitelist ] && cp -f $DIR_UPDATE/exceptionsitelist /etc/dansguardian/lists/
|
247 |
[ -e $DIR_UPDATE/exceptionsitelist ] && cp -f $DIR_UPDATE/exceptionsitelist /etc/dansguardian/lists/
|
247 |
[ -e $DIR_UPDATE/urlregexplist ] && cp -f $DIR_UPDATE/urlregexplist /etc/dansguardian/lists/
|
248 |
[ -e $DIR_UPDATE/urlregexplist ] && cp -f $DIR_UPDATE/urlregexplist /etc/dansguardian/lists/
|
248 |
[ -e $DIR_UPDATE/bannedsitelist ] && cp -f $DIR_UPDATE/bannedsitelist /etc/dansguardian/lists/
|
249 |
[ -e $DIR_UPDATE/bannedsitelist ] && cp -f $DIR_UPDATE/bannedsitelist /etc/dansguardian/lists/
|
249 |
[ -e $DIR_UPDATE/exceptionurllist ] && cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
|
250 |
[ -e $DIR_UPDATE/exceptionurllist ] && cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
|
250 |
[ -e $DIR_UPDATE/bannedurllist ] && cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
|
251 |
[ -e $DIR_UPDATE/bannedurllist ] && cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
|
251 |
[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
|
252 |
[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
|
252 |
chown -R dansguardian:apache /etc/dansguardian/lists
|
253 |
chown -R dansguardian:apache /etc/dansguardian/lists
|
253 |
chmod -R g+rw /etc/dansguardian/lists
|
254 |
chmod -R g+rw /etc/dansguardian/lists
|
254 |
# Start / Stop DNS/URL filtering
|
255 |
# Start / Stop DNS/URL filtering
|
255 |
PARENT_SCRIPT=$0
|
256 |
PARENT_SCRIPT=$0
|
256 |
export PARENT_SCRIPT
|
257 |
export PARENT_SCRIPT
|
257 |
$DIR_SBIN/alcasar-bl.sh -reload
|
258 |
$DIR_SBIN/alcasar-bl.sh -reload
|
- |
|
259 |
[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq
|
258 |
# Prise en compte des comptes de gestion (admin + manager + backup)
|
260 |
# Prise en compte des comptes de gestion (admin + manager + backup)
|
259 |
$DIR_SBIN/alcasar-profil.sh --list
|
261 |
$DIR_SBIN/alcasar-profil.sh --list
|
260 |
# Start / Stop SSH Daemon
|
262 |
# Start / Stop SSH Daemon
|
261 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
263 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
262 |
if [ $ssh_active = "on" ]
|
264 |
if [ $ssh_active = "on" ]
|
263 |
then
|
265 |
then
|
264 |
/sbin/chkconfig --add sshd
|
266 |
/sbin/chkconfig --add sshd
|
265 |
else
|
267 |
else
|
266 |
/sbin/chkconfig --del sshd
|
268 |
/sbin/chkconfig --del sshd
|
267 |
fi
|
269 |
fi
|
268 |
# Effacement du répertoire d'update
|
270 |
# Effacement du répertoire d'update
|
269 |
rm -rf $DIR_UPDATE
|
271 |
rm -rf $DIR_UPDATE
|
270 |
;;
|
272 |
;;
|
271 |
--apply|-apply)
|
273 |
--apply|-apply)
|
272 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[012]?[0-9]\b"
|
274 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[012]?[0-9]\b"
|
273 |
PRIVATE_IP_MASK=`grep PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
|
275 |
PRIVATE_IP_MASK=`grep PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
|
274 |
check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
|
276 |
check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
|
275 |
if [[ "$?" -ne 0 ]]
|
277 |
if [[ "$?" -ne 0 ]]
|
276 |
then
|
278 |
then
|
277 |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
|
279 |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
|
278 |
exit 0
|
280 |
exit 0
|
279 |
fi
|
281 |
fi
|
280 |
PUBLIC_IP_MASK=`grep PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
|
282 |
PUBLIC_IP_MASK=`grep PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
|
281 |
check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
|
283 |
check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
|
282 |
if [[ "$?" -ne 0 ]]
|
284 |
if [[ "$?" -ne 0 ]]
|
283 |
then
|
285 |
then
|
284 |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
|
286 |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
|
285 |
exit 0
|
287 |
exit 0
|
286 |
fi
|
288 |
fi
|
287 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
|
289 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
|
288 |
PUBLIC_GATEWAY=`grep GW $CONF_FILE|cut -d"=" -f2`
|
290 |
PUBLIC_GATEWAY=`grep GW $CONF_FILE|cut -d"=" -f2`
|
289 |
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
|
291 |
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
|
290 |
if [[ "$?" -ne 0 ]]
|
292 |
if [[ "$?" -ne 0 ]]
|
291 |
then
|
293 |
then
|
292 |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
|
294 |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
|
293 |
exit 0
|
295 |
exit 0
|
294 |
fi
|
296 |
fi
|
295 |
DNS1=`grep DNS1 $CONF_FILE|cut -d"=" -f2`
|
297 |
DNS1=`grep DNS1 $CONF_FILE|cut -d"=" -f2`
|
296 |
check=$(echo $DNS1 | egrep $PTN)
|
298 |
check=$(echo $DNS1 | egrep $PTN)
|
297 |
if [[ "$?" -ne 0 ]]
|
299 |
if [[ "$?" -ne 0 ]]
|
298 |
then
|
300 |
then
|
299 |
echo "Syntax error for the IP address of the first DNS server ($DNS1)"
|
301 |
echo "Syntax error for the IP address of the first DNS server ($DNS1)"
|
300 |
exit 0
|
302 |
exit 0
|
301 |
fi
|
303 |
fi
|
302 |
DNS2=`grep DNS2 $CONF_FILE|cut -d"=" -f2`
|
304 |
DNS2=`grep DNS2 $CONF_FILE|cut -d"=" -f2`
|
303 |
check=$(echo $DNS2 | egrep $PTN)
|
305 |
check=$(echo $DNS2 | egrep $PTN)
|
304 |
if [[ "$?" -ne 0 ]]
|
306 |
if [[ "$?" -ne 0 ]]
|
305 |
then
|
307 |
then
|
306 |
echo "Syntax error for the IP address of the second DNS server ($DNS2)"
|
308 |
echo "Syntax error for the IP address of the second DNS server ($DNS2)"
|
307 |
exit 0
|
309 |
exit 0
|
308 |
fi
|
310 |
fi
|
309 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
311 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
310 |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
|
312 |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
|
311 |
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
|
313 |
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
|
312 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
314 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
313 |
private_network_calc
|
315 |
private_network_calc
|
314 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
316 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
315 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
317 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
316 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
318 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
317 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
319 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
318 |
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
|
320 |
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
|
- |
|
321 |
if [ $DHCP_mode = "off" ]
|
- |
|
322 |
then
|
- |
|
323 |
$DIR_SBIN/alcasar-dhcp.sh --off
|
- |
|
324 |
fi
|
319 |
# Logout everybody
|
325 |
# Logout everybody
|
320 |
$DIR_SBIN/alcasar-logout.sh all
|
326 |
$DIR_SBIN/alcasar-logout.sh all
|
321 |
# Services stop
|
327 |
# Services stop
|
322 |
for i in squid ntpd chilli httpd network
|
328 |
for i in squid ntpd chilli httpd network
|
323 |
do
|
329 |
do
|
324 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
|
330 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
|
325 |
done
|
331 |
done
|
326 |
|
332 |
|
327 |
# /etc/hosts
|
333 |
# /etc/hosts
|
328 |
cat <<EOF > /etc/hosts
|
334 |
cat <<EOF > /etc/hosts
|
329 |
127.0.0.1 localhost
|
335 |
127.0.0.1 localhost
|
330 |
$PRIVATE_IP $HOSTNAME $HOSTNAME.$DOMAIN
|
336 |
$PRIVATE_IP $HOSTNAME $HOSTNAME.$DOMAIN
|
331 |
EOF
|
337 |
EOF
|
332 |
|
338 |
|
333 |
# Ext Network Card config
|
339 |
# Ext Network Card config
|
334 |
$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
340 |
$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
335 |
$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
341 |
$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
336 |
$SED "s?^GATEWAY=.*?GATEWAY=$PUBLIC_GATEWAY?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
342 |
$SED "s?^GATEWAY=.*?GATEWAY=$PUBLIC_GATEWAY?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
337 |
# NTP server
|
343 |
# NTP server
|
338 |
$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
|
344 |
$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
|
339 |
# host.allow
|
345 |
# host.allow
|
340 |
cat <<EOF > /etc/hosts.allow
|
346 |
cat <<EOF > /etc/hosts.allow
|
341 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
347 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
342 |
sshd: ALL
|
348 |
sshd: ALL
|
343 |
ntpd: $PRIVATE_NETWORK_SHORT
|
349 |
ntpd: $PRIVATE_NETWORK_SHORT
|
344 |
EOF
|
350 |
EOF
|
345 |
# Alcasar Control Center
|
351 |
# Alcasar Control Center
|
346 |
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
|
352 |
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
|
347 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
353 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
348 |
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
|
354 |
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
|
349 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
355 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
350 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
356 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
351 |
# Dialup_Admin
|
357 |
# Dialup_Admin
|
352 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
358 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
353 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
359 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
354 |
# coova
|
360 |
# coova
|
355 |
$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
|
361 |
$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
|
356 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
362 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
357 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
363 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
358 |
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
364 |
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
359 |
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
|
365 |
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
|
360 |
$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
|
366 |
$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
|
361 |
# dhcp (coova + dnsmasq)
|
367 |
# dhcp (coova + dnsmasq)
|
362 |
$DIR_SBIN/alcasar-dhcp.sh -$DHCP_mode
|
368 |
$DIR_SBIN/alcasar-dhcp.sh -$DHCP_mode
|
363 |
# awstat
|
369 |
# awstat
|
364 |
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
|
370 |
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
|
365 |
# dnsmasq
|
371 |
# dnsmasq
|
366 |
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
372 |
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
367 |
for i in /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
373 |
for i in /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
368 |
do
|
374 |
do
|
369 |
$SED "/^server=/d" $i
|
375 |
$SED "/^server=/d" $i
|
370 |
echo "server=$DNS1" >> $i
|
376 |
echo "server=$DNS1" >> $i
|
371 |
echo "server=$DNS2" >> $i
|
377 |
echo "server=$DNS2" >> $i
|
372 |
done
|
378 |
done
|
373 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
379 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
374 |
# DG + BL
|
380 |
# DG + BL
|
375 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
381 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
376 |
# Watchdog
|
382 |
# Watchdog
|
377 |
$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
|
383 |
$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
|
378 |
# SSHD
|
384 |
# SSHD
|
379 |
$SED "s?^#ListenAddress 0\.0\.0\.0?ListenAddress $PRIVATE_IP?g" /etc/ssh/sshd_config
|
385 |
$SED "s?^#ListenAddress 0\.0\.0\.0?ListenAddress $PRIVATE_IP?g" /etc/ssh/sshd_config
|
380 |
$SED "/^ListenAddress $PRIVATE_IP/a\ListenAddress $PUBLIC_IP" /etc/ssh/sshd_config
|
386 |
$SED "/^ListenAddress $PRIVATE_IP/a\ListenAddress $PUBLIC_IP" /etc/ssh/sshd_config
|
381 |
# Prompts
|
387 |
# Prompts
|
382 |
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
|
388 |
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
|
383 |
# sudoers
|
389 |
# sudoers
|
384 |
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
|
390 |
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
|
385 |
# Services start
|
391 |
# Services start
|
386 |
for i in network squid ntpd chilli httpd
|
392 |
for i in network squid ntpd chilli httpd
|
387 |
do
|
393 |
do
|
388 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i start 2>/dev/null
|
394 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i start 2>/dev/null
|
389 |
done
|
395 |
done
|
390 |
# Start / Stop SSH Daemon
|
396 |
# Start / Stop SSH Daemon
|
391 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
397 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
392 |
if [ $ssh_active = "on" ]
|
398 |
if [ $ssh_active = "on" ]
|
393 |
then
|
399 |
then
|
394 |
/sbin/chkconfig --add sshd
|
400 |
/sbin/chkconfig --add sshd
|
395 |
/etc/init.d/sshd start
|
401 |
/etc/init.d/sshd start
|
396 |
else
|
402 |
else
|
397 |
/sbin/chkconfig --del sshd
|
403 |
/sbin/chkconfig --del sshd
|
398 |
echo "Au redémarrage du serveur, le service SSH sera désactivé !!! ; au besoin l'activer dans l'interface de gestion."
|
404 |
echo "Au redémarrage du serveur, le service SSH sera désactivé !!! ; au besoin l'activer dans l'interface de gestion."
|
399 |
sleep 2
|
405 |
sleep 2
|
400 |
fi
|
406 |
fi
|
401 |
# Reload BL (restart DG, dnsmasq & iptables)
|
407 |
# Reload BL (restart DG, dnsmasq & iptables)
|
402 |
$DIR_SBIN/alcasar-bl.sh -reload
|
408 |
$DIR_SBIN/alcasar-bl.sh -reload
|
403 |
;;
|
409 |
;;
|
404 |
*)
|
410 |
*)
|
405 |
echo "Argument inconnu :$1";
|
411 |
echo "Argument inconnu :$1";
|
406 |
echo "$usage"
|
412 |
echo "$usage"
|
407 |
exit 1
|
413 |
exit 1
|
408 |
;;
|
414 |
;;
|
409 |
esac
|
415 |
esac
|
410 |
|
416 |
|
411 |
|
417 |
|