Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1059 → Rev 1060

/scripts/alcasar-urpmi.sh
8,6 → 8,7
# script de mise en place des dépots RPM
# configure the RPM repository
 
Lang=`echo $LANG|cut -c 1-2`
VERSION="2"
ARCH="i586"
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
28,10 → 29,14
rpm_error ()
{
echo
echo "Relancez l'installation ultérieurement."
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
echo "Try an other install later."
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
if [ $Lang == "fr" ]
then
echo "Relancez l'installation ultérieurement."
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
else
echo "Try an other install later."
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
fi
}
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
fic=`cat /etc/product.id`
59,16 → 64,28
done
IFS="$old"
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
then
if [ $Lang == "fr" ]
then
echo "La migration automatique d'ALCASAR ne peut pas être réalisée."
echo "Le système d'exploitation doit être remplacer"
else
echo "The automatic update of ALCASAR can't be performed."
echo "The OS must be replaced"
fi
if [ -e /tmp/alcasar-conf.tar.gz ]
then
echo "le système Linux installé n'est pas conforme. Installez Mageia2 (cf documentation d'installation)"
echo "the installed Linux operating system isn't conform. Install Mageia2 (see installation documentation)"
if [ -e /tmp/alcasar-conf.tar.gz ]
then
echo
echo "La migration automatique du système ne peut pas être réalisée."
echo "Récupérez le fichier /tmp/alcasar-conf.tar.gz et faites une mise à jour manuelle (cf. readme.txt)."
echo "The automatic system update can't perform."
echo "Retrieve the file /tmp/alcasar-conf.tar.gz and do a manual update (see readme.txt)."
if [ $Lang == "fr" ]
then
echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancez l'installation d'ALCASAR"
else
echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
echo "2 - Install Linux-Mageia2 (cf. installation doc)"
echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
fi
fi
exit 1
fi
89,15 → 106,23
nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
if [ "$nb_repository" != "2" ]
then
echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
echo "An error occurs when synchronising the repositories N°$try_nb"
if [ $Lang == "fr" ]
then
echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
else
echo "An error occurs when synchronising the repositories N°$try_nb"
fi
if [ $(expr $try_nb) -eq $MIRROR_NBR ]
then
rpm_error
exit 1
fi
echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
echo "Do you wan't to try a synchronisation with an other repository?"
if [ $Lang == "fr" ]
then
echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
else
echo "Do you wan't to try a synchronisation with an other repository?"
fi
response=0
PTN='^[oOnNyY]$'
until [[ $(expr $response : $PTN) -gt 0 ]]
119,16 → 144,24
done
echo
# download RPM in cache
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
echo "Updated RPM download. Please wait ..."
echo "Il est temps d'aller prendre un café :-) "
echo "You should now take a Beer ;-) "
if [ $Lang == "fr" ]
then
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
else
echo "Updated RPM download. Please wait ..."
echo "You should now take a coffe (or a good beer) ;-)"
fi
urpmi --auto --auto-update --quiet --test --retry 2
if [ "$?" != "0" ]
then
echo
echo "Une erreur a été détectée lors de la récupération des paquetages."
echo "An error occurs when downloading RPMS"
if [ $Lang == "fr" ]
then
echo "Une erreur a été détectée lors de la récupération des paquetages."
else
echo "An error occurs when downloading RPMS"
fi
rpm_error
exit 1
fi
137,8 → 170,12
if [ "$?" != "0" ]
then
echo
echo "Une erreur a été détectée lors de la mise à jour des paquetages."
echo "An error occurs when updating packages"
if [ $Lang == "fr" ]
then
echo "Une erreur a été détectée lors de la mise à jour des paquetages."
else
echo "An error occurs when updating packages"
fi
rpm_error
exit 1
fi
145,14 → 182,22
# Clean the RPM cache
urpmi --clean
# Download of ALCASAR specifics RPM in cache (and test)
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
echo "Download of complementary packages. Please wait ..."
if [ $Lang == "fr" ]
then
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
else
echo "Download of complementary packages. Please wait ..."
fi
urpmi --auto $PACKAGES --quiet --test --retry 2
if [ "$?" != "0" ]
then
echo
echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
echo "An error occurs when downloading complementary packages"
if [ $Lang == "fr" ]
then
echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
else
echo "An error occurs when downloading complementary packages"
fi
rpm_error
exit 1
fi
161,8 → 206,12
if [ "$?" != "0" ]
then
echo
echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
echo "An error occurs when installing complementary packages"
if [ $Lang == "fr" ]
then
echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
else
echo "An error occurs when installing complementary packages"
fi
rpm_error
exit 1
fi
180,4 → 229,3
# Clean the RPM cache
urpmi --clean
exit 0
 
/scripts/sbin/alcasar-bl.sh
63,7 → 63,7
}
function bl_enable (){
$SED "s/^reportinglevel =.*/reportinglevel = 3/g" /etc/dansguardian/dansguardian.conf
if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
then
service dansguardian restart
service dnsmasq restart
73,7 → 73,7
function bl_disable (){
rm -rf $DIR_DNS_BL_ENABLED/*
$SED "s/^reportinglevel =.*/reportinglevel = -1/g" /etc/dansguardian/dansguardian.conf
if [ "$PARENT_SCRIPT" != "/usr/local/bin/alcasar-conf.sh" ] # don't launch on install stage
if [ "$PARENT_SCRIPT" != "alcasar-conf.sh" ] # don't launch on install stage
then
service dansguardian restart
service dnsmasq restart
/scripts/sbin/alcasar-bypass.sh
43,7 → 43,7
# désactivation du contournement
if (pgrep dnsmasq) > /dev/null ; then /etc/init.d/dnsmasq stop ; fi
echo "Configure dnsmasq ..."
$SED "s?^#conf-dir=.*?conf-dir=/usr/local/etc/alcasar-dnsfilter-enabled?g" /etc/dnsmasq-blackhole.conf
$SED "s?^#conf-dir=.*?conf-dir=/usr/local/share/dnsmasq-bl-enabled?g" /etc/dnsmasq-blackhole.conf
$SED "s?^#no-dhcp-interface=.*?no-dhcp-interface=eth1?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
rm -f /etc/sysconfig/network-scripts/ifcfg-eth1
for i in chilli squid dansguardian havp mysqld radiusd httpd freshclam dnsmasq
/scripts/alcasar-watchdog.sh
87,7 → 87,7
if [ $net_pb != "0" ]
then
/bin/sed -i "s?^\$network_pb.*?\$network_pb = False;?g" $Index_Page
/bin/sed -i "s?^address=\/#\/.*?conf-dir=/usr/local/etc/alcasar-dnsfilter-enabled?g" /etc/dnsmasq-blackhole.conf
/bin/sed -i "s?^address=\/#\/.*?conf-dir=/usr/local/share/dnsmasq-bl-enabled?g" /etc/dnsmasq-blackhole.conf
/bin/sed -i "/^address=/d" /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
fi
/scripts/alcasar-conf.sh
6,11 → 6,13
# This script is distributed under the Gnu General Public License (GPL)
 
# Ce script permet la mise à jour ALCASAR
# - création et chargement de l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
# - application des directives du fichier de conf central (/usr/local/etc/alcasar.conf)
# - création de l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
# - chargement d'une archive (lors de la mise à jour d'un alcasar)
# - application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" (lors d'un changement de conf à chaud)
# This script allows ALCASAR update
# - create and load the configuration files backup (/tmp/alcasar-conf.tar.gz)
# - apply ALCASAR central configuration file (/usr/local/etc/alcasar.conf)
# - create the configuration files backup (/tmp/alcasar-conf.tar.gz)
# - load the bachup of configuration files (during the update process)
# - apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" (when hot modification are needed)
 
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
37,11 → 39,17
DATE=`date '+%d %B %Y - %Hh%M'`
private_network_calc ()
{
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ + masque du réseau de consult (192.168.182.0/24)
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ + masque du réseau de consult (192.168.182.0/24)
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)
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2` # private network broadcast (ie.: 192.168.182.255)
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup` # last octet of LAN address
private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup` # last octet of LAN broadcast
PRIVATE_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 1` # First network address (ex.: 192.168.182.1)
PRIVATE_SECOND_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 2` # second network address (ex.: 192.168.182.2)
PRIVATE_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1` # last network address (ex.: 192.168.182.254)
}
 
usage="Usage: alcasar-conf.sh {--create or -create} | {--load or -load} | {--apply or -apply}"
60,10 → 68,6
--create|-create)
[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
mkdir $DIR_UPDATE
# Sauvegarde du fichier général de DNSMASQ ---- provisoire le temps que le bug de dnsmasq soit corrigé.
if [ `grep -c "^OPTIONS=\"\$OPTIONS --server=" /etc/sysconfig/dnsmasq` -eq "1" ]
then cp /etc/sysconfig/dnsmasq $DIR_UPDATE
fi
# Sauvegarde de la base des usagers
/usr/local/sbin/alcasar-mysql.sh -dump
cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
234,14 → 238,10
--load|-load)
cd /tmp
tar -xf /tmp/alcasar-conf*.tar.gz
# récupération du fichier général de dnsmasq en attendant sa correction du bug pour les DNS externes
[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq \
&& chown root.root /etc/sysconfig/dnsmasq \
&& chmod 644 /etc/sysconfig/dnsmasq
# Récupération du logo
# 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
# Récupération des certificats (CA et serveur)
# Retrieve the security certificates (CA and server)
[ -e $DIR_UPDATE/alcasar-ca.crt ] && cp -f $DIR_UPDATE/alcasar-ca.crt /etc/pki/CA/
[ -e $DIR_UPDATE/alcasar-ca.key ] && cp -f $DIR_UPDATE/alcasar-ca.key /etc/pki/CA/private/
[ -e $DIR_UPDATE/alcasar.crt ] && cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
249,11 → 249,11
[ -e $DIR_UPDATE/server-chain.crt ] && cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
chown -R root:apache /etc/pki
chmod -R 750 /etc/pki
# Import de la dernière base usagers
# Import of the users database
mysql -u$DB_USER -p$radiuspwd < `ls $DIR_UPDATE/radius*`
# Récupération des paramêtres locaux. Suppression des fichier de la blacklist (dorénavant exploités dans /usr/local/share)
# Retrieve lacal parameters & Remove blacklist files (now in /usr/local/share)
[ -d $DIR_UPDATE/etc ] && rm -rf $DIR_UPDATE/etc/alcasar-dnsfilter* && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
# Récupération des fichiers de Dansguardian
# Retrieve Dansguardian files
[ -e $DIR_UPDATE/exceptioniplist ] && cp -f $DIR_UPDATE/exceptioniplist /etc/dansguardian/lists/
[ -e $DIR_UPDATE/exceptionsitelist ] && cp -f $DIR_UPDATE/exceptionsitelist /etc/dansguardian/lists/
[ -e $DIR_UPDATE/urlregexplist ] && cp -f $DIR_UPDATE/urlregexplist /etc/dansguardian/lists/
263,13 → 263,16
[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
chown -R dansguardian:apache /etc/dansguardian/lists
chmod -R g+rw /etc/dansguardian/lists
# Start / Stop DNS/URL filtering
PARENT_SCRIPT=$0
# Adapt DNS/URL filtering
PARENT_SCRIPT=`basename $0`
export PARENT_SCRIPT
$DIR_SBIN/alcasar-bl.sh -adapt
$DIR_SBIN/alcasar-bl.sh -reload
[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq
# Prise en compte des comptes de gestion (admin + manager + backup)
# retrieve dnsmasq general config file
[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq \
&& chown root.root /etc/sysconfig/dnsmasq \
&& chmod 644 /etc/sysconfig/dnsmasq
# admin profile update (admin + manager + backup)
$DIR_SBIN/alcasar-profil.sh --list
# Start / Stop SSH Daemon
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
279,7 → 282,7
else
/sbin/chkconfig --del sshd
fi
# Effacement du répertoire d'update
# Remove the update folder
rm -rf $DIR_UPDATE
;;
--apply|-apply)
325,22 → 328,24
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
private_network_calc
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
if [ $DHCP_mode = "off" ]
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
then
$DIR_SBIN/alcasar-dhcp.sh --off
fi
if [ $DHCP_mode = "off" ]
then
$DIR_SBIN/alcasar-dhcp.sh --off
fi
# Logout everybody
$DIR_SBIN/alcasar-logout.sh all
$DIR_SBIN/alcasar-logout.sh all
# Services stop
for i in squid ntpd chilli httpd network
do
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
done
for i in squid ntpd chilli httpd network
do
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
done
fi
 
# /etc/hosts
cat <<EOF > /etc/hosts
361,7 → 366,6
ntpd: $PRIVATE_NETWORK_SHORT
EOF
# Alcasar Control Center
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
388,7 → 392,7
echo "server=$DNS1" >> $i
echo "server=$DNS2" >> $i
done
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_IP,192.168.182.254,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
# DG + BL
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
403,24 → 407,32
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
# sudoers
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
then
# Services start
for i in network squid ntpd chilli httpd
do
[ -e /etc/init.d/$i ] && /etc/init.d/$i start 2>/dev/null
done
for i in network squid ntpd chilli httpd
do
[ -e /etc/init.d/$i ] && /etc/init.d/$i start
done
# Reload BL (restart DG, dnsmasq & iptables)
$DIR_SBIN/alcasar-bl.sh -reload
fi
# Start / Stop SSH Daemon
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
if [ $ssh_active = "on" ]
then
/sbin/chkconfig --add sshd
/etc/init.d/sshd start
/bin/systemctl enable sshd.service
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
then
/bin/systemctl start sshd.service
fi
else
/sbin/chkconfig --del sshd
echo "Au redémarrage du serveur, le service SSH sera désactivé !!! ; au besoin l'activer dans l'interface de gestion."
sleep 2
/bin/systemctl disable sshd.service
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
then
/bin/systemctl stop sshd.service
fi
fi
# Reload BL (restart DG, dnsmasq & iptables)
$DIR_SBIN/alcasar-bl.sh -reload
;;
*)
echo "Argument inconnu :$1";