Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2569 → Rev 2570

/scripts/alcasar-conf.sh
5,14 → 5,14
# by REXY
# This script is distributed under the Gnu General Public License (GPL)
 
# Ce script permet la mise à jour ALCASAR
# Ce script permet de mettre à jour d'ALCASAR
# - création de l'archive des fichiers de configuration "/var/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
# - chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load). Le cas échéant, c'est ici qu'on met à jour les fichiers entre versions
# - application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" lors d'un changement de conf réseau à chaud (alcasar-conf -apply)
# This script allows ALCASAR update
# - chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load). Le cas échéant, c'est ici qu'on met à jour les fichiers entre versions
# - application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" à chaud (alcasar-conf -apply)
# This script allows ALCASAR update
# - create the configuration files backup "/var/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
# - load the backup of configuration files during the update process (alcasar-conf -load). If needed, it's here we update files between versions
# - apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification is needed (alcasar-conf -apply)
# - apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification are needed (alcasar-conf -apply)
 
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
85,8 → 85,8
mkdir $DIR_UPDATE/custom_bl
for i in exceptioniplist urlregexplist exceptionsitelist bannedsitelist exceptionurllist bannedurllist
do
if [ -d /etc/dansguardian ]; then # before V3.3
cp /etc/dansguardian/lists/$i $DIR_UPDATE/custom_bl/
if [ -d /etc/dansguardian ]; then
cp /etc/dansguardian/lists/$i $DIR_UPDATE/custom_bl/ # before V3.3
else
cp /etc/e2guardian/lists/$i $DIR_UPDATE/custom_bl/ # since V3.3
fi
99,7 → 99,7
# backup of the security certificates (server & CA)
cp -f /etc/pki/tls/certs/alcasar.crt* $DIR_UPDATE
cp -f /etc/pki/tls/private/alcasar.key* $DIR_UPDATE
cp -f /etc/pki/tls/private/alcasar.pem $DIR_UPDATE
[ -e /etc/pki/tls/private/alcasar.pem ] && cp -f /etc/pki/tls/private/alcasar.pem $DIR_UPDATE # since V3.3
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
117,11 → 117,46
--load|-load)
cd /var/tmp
tar -xf alcasar-conf*.tar.gz
# Extract the previous version
######################### modifications between versions #######################
# Retrieve the previous version
PREVIOUS_VERSION=`grep ^VERSION= $DIR_UPDATE/etc/alcasar.conf|cut -d"=" -f2`
MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
## From 3.2.0 & 3.2.1 ##
if [ $MAJ_PREVIOUS_VERSION == "3" ] && [ $MIN_PREVIOUS_VERSION == "2" ]
then
## rewrite the file managing domain name resolution (local & remote). Hostnames resolutions are now in /etc/hosts
cat << EOF > $DIR_UPDATE/etc/alcasar-dns-name
# Vous pouvez définir ici votre nom de domain local ('localdomain' par défaut)
# Here you can define your local domain name ('localdomain' by default)
local=/$DOMAIN/
domain=$DOMAIN
 
## Ajouter une ligne pour chaque nom de domaine géré par un autre seveur DNS
## Add one line for each domain name managed by an other DNS server
## server=/<your_domain>/<@IP_domain_server>
## Exemple for an A.D. domain : server=/Your.Domain.AD/110.120.100.100
## Exemple for an other domain : server=/an_other_domain/10.20.30.40
 
## INFO : local hostnames are resolved in /etc/hosts file
EOF
## rewrite /etc/hosts file managing hostname resolution
PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
cat << EOF > $DIR_UPDATE/etc/hosts
127.0.0.1 localhost
$PRIVATE_IP $HOSTNAME
EOF
## apache & dansguardian are replaced with lighttpd & E²guardian
rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
/usr/sbin/urpme --auto -a $rm_rpm
/usr/sbin/urpme --auto --auto-orphans
rm -rf /etc/httpd/ /var/log/httpd/ /var/dansguardian/ /etc/dansguardian/
## lighttpd need a .pem certificate (aggregation with private key & server crt)
(cat $DIR_UPDATE/alcasar-ca.key; echo; cat $DIR_UPDATE/alcasar.crt) > $DIR_UPDATE/alcasar.pem
fi
###################### End of modifications between versions #######################
# Retrieve the logo
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
138,7 → 173,7
gzip -dc < `ls $DIR_UPDATE/alcasar-users-database*` | mysql -u$DB_USER -p$DB_PASS
# Retrieve local parameters
cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
mv -f $DIR_ETC/hosts /etc/hosts
mv -f $DIR_UPDATE/etc/hosts /etc/hosts
# Retrieve BL/WL custom files
cp -f $DIR_UPDATE/custom_bl/exceptioniplist /etc/e2guardian/lists/
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist /etc/e2guardian/lists/
166,40 → 201,6
fi
# Remove the update folder
rm -rf $DIR_UPDATE
######################### modifications between versions #######################
## From 3.2.0 & 3.2.1 ##
if [ $MAJ_PREVIOUS_VERSION == "3" ] && [ $MIN_PREVIOUS_VERSION == "2" ]
then
## rewrite the file managing domain name resolution (local & remote). Hostnames resolutions are now in /etc/hosts
cat << EOF > $DIR_ETC/alcasar-dns-name
# Vous pouvez définir ici votre nom de domain local ('localdomain' par défaut)
# Here you can define your local domain name ('localdomain' by default)
local=/$DOMAIN/
domain=$DOMAIN
 
## Ajouter une ligne pour chaque nom de domaine géré par un autre seveur DNS
## Add one line for each domain name managed by an other DNS server
## server=/<your_domain>/<@IP_domain_server>
## Exemple for an A.D. domain : server=/Your.Domain.AD/110.120.100.100
## Exemple for an other domain : server=/an_other_domain/10.20.30.40
 
## INFO : local hostnames are resolved in /etc/hosts file
EOF
## rewrite /etc/hosts file managing hostname resolution
PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
cat << EOF > /etc/hosts
127.0.0.1 localhost
$PRIVATE_IP $HOSTNAME
EOF
# apache & dansguardian are replaced with lighttpd & E²guardian
rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
/usr/sbin/urpme --auto -a $rm_rpm
/usr/sbin/urpme --auto --auto-orphans
rm -rf /etc/httpd/ /var/log/httpd/ /var/dansguardian/ /etc/dansguardian/
# lighttpd need a .pem certificate (aggregation with server crt & private key)
(cat /etc/pki/tls/private/alcasar.key; echo; cat /etc/pki/tls/certs/alcasar.crt) > /etc/pki/tls/private/alcasar.pem
fi
;;
 
--apply|-apply)