75,8 → 75,8 |
# ******* Network parameters - paramètres réseau ******* |
HOSTNAME="alcasar" # default hostname |
DOMAIN="localdomain" # default local domain |
EXTIF=`/usr/sbin/ip route|grep default|head -n1|cut -d" " -f5` # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI) |
INTIF=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "lo\|$EXTIF\|tun0"|head -n1|cut -d" " -f2|tr -d ":"` # INTIF is connected to the consultation network |
EXTIF='' # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI) |
INTIF='' # INTIF is connected to the consultation network |
MTU="1500" |
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # Default ALCASAR IP address |
# ****** Paths - chemin des commandes ******* |
150,22 → 150,53 |
unknown_os=`expr $unknown_os + 1` |
fi |
done |
if [ "$ARCH" == "i586" ] |
if [ "$ARCH" != "x86_64" ] |
then |
if [ $Lang == "fr" ] |
then echo -n "Votre architecture matérielle doit être en 64bits" |
else echo -n "You hardware architecture must be 64bits" |
then echo "Votre architecture matérielle doit être en 64bits" |
else echo "You hardware architecture must be 64bits" |
fi |
exit 1 |
fi |
IFS="$old" |
if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]] |
then |
if [ -e /var/tmp/alcasar-conf.tar.gz ] # update |
then |
echo |
if [ $Lang == "fr" ] |
then |
echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée." |
echo "1 - Effectuez une sauvegarde des fichiers de traçabilité et de la base des usagers via l'ACC" |
echo "2 - Installez Linux-Mageia 6.0 (64bits) et ALCASAR (cf. doc d'installation)" |
echo "3 - Importez votre base des usagers" |
else |
echo "The automatic update of ALCASAR can't be performed." |
echo "1 - Save your traceability files and the user database" |
echo "2 - Install Linux-Mageia 6 (64bits) & ALCASAR (cf. installation doc)" |
echo "3 - Import your users database" |
fi |
else |
if [ $Lang == "fr" ] |
then echo "L'installation d'ALCASAR ne peut pas être réalisée." |
else echo "The installation of ALCASAR can't be performed." |
fi |
fi |
echo |
if [ $Lang == "fr" ] |
then echo "Le système d'exploitation doit être remplacé (Mageia6-64bits)" |
else echo "The OS must be replaced (Mageia6-64bits)" |
fi |
exit 0 |
fi |
|
# Test if ALCASAR is already installed |
if [ -e $CONF_FILE ] |
then |
current_version=`grep ^VERSION= $CONF_FILE | cut -d"=" -f2` |
if [ $Lang == "fr" ] |
then echo -n "La version "; echo -n $current_version ; echo " d'ALCASAR est déjà installée"; |
else echo -n "ALCASAR Version "; echo -n $current_version ; echo " is already installed"; |
then echo "La version $current_version d'ALCASAR est déjà installée" |
else echo "ALCASAR version $current_version is already installed" |
fi |
response=0 |
PTN='^[12]$' |
172,10 → 203,8 |
until [[ $(expr $response : $PTN) -gt 0 ]] |
do |
if [ $Lang == "fr" ] |
then |
echo -n "Tapez '1' pour une mise à jour; Tapez '2' pour une réinstallation : " |
else |
echo -n "Hit '1' for an update; Hit '2' for a reinstallation : " |
then echo -n "Tapez '1' pour une mise à jour; Tapez '2' pour une réinstallation : " |
else echo -n "Hit '1' for an update; Hit '2' for a reinstallation : " |
fi |
read response |
done |
193,43 → 222,9 |
mode="update" |
fi |
fi |
if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]] |
then |
if [ -e /var/tmp/alcasar-conf.tar.gz ] # update |
then |
echo |
if [ $Lang == "fr" ] |
then |
echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée." |
echo "1 - Effectuez une sauvegarde des fichiers de traçabilité et de la base des usagers via l'ACC" |
echo "2 - Installez Linux-Mageia 6.0 (64bits) et ALCASAR (cf. doc d'installation)" |
echo "3 - Importez votre base des usagers" |
else |
echo "The automatic update of ALCASAR can't be performed." |
echo "1 - Save your traceability files and the user database" |
echo "2 - Install Linux-Mageia 6 (64bits) & ALCASAR (cf. installation doc)" |
echo "3 - Import your users database" |
fi |
else |
if [ $Lang == "fr" ] |
then |
echo "L'installation d'ALCASAR ne peut pas être réalisée." |
else |
echo "The installation of ALCASAR can't be performed." |
fi |
fi |
echo |
if [ $Lang == "fr" ] |
then |
echo "Le système d'exploitation doit être remplacé (Mageia6-64bits)" |
else |
echo "The OS must be replaced (Mageia6-64bits)" |
fi |
exit 0 |
fi |
# Test free space on /var |
if [ ! -d /var/log/netflow/porttracker ] |
then |
# Test free space on /var |
free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G` |
if [ $free_space -lt 10 ] |
then |
240,6 → 235,71 |
exit 0 |
fi |
fi |
|
# Detect external/internal interfaces |
if [ -z "$EXTIF" ]; then |
EXTIF=$(/usr/sbin/ip route list | awk '/^default / {print $5}') |
if [ -z "$EXTIF" ]; then |
if [ "$Lang" == 'fr' ] |
then echo -n "Aucune passerelle par défaut configurée" |
else echo -n "No default gateway configured" |
fi |
exit 1 |
fi |
fi |
if [ "$Lang" == 'fr' ] |
then echo "Interface externe (Internet) utilisée : $EXTIF" |
else echo "External interface (Internet) used: $EXTIF" |
fi |
|
if [ -z "$INTIF" ]; then |
interfacesList=$(/usr/sbin/ip -br link show | cut -d' ' -f1 | grep -v "^\(lo\|tun0\|$EXTIF\)\$") |
interfacesCount=$(echo "$interfacesList" | wc -l) |
if [ $interfacesCount -eq 0 ]; then |
if [ "$Lang" == 'fr' ] |
then echo "Aucune interface de disponible pour le réseau interne" |
else echo "No interface available for the internal network" |
fi |
exit 1 |
elif [ $interfacesCount -eq 1 ]; then |
INTIF="$interfacesList" |
else |
interfacesSorted=$(/usr/sbin/ip -br addr | grep -v "^\(lo\|tun0\|$EXTIF\) " | sort -b -k3n -k2r -k1) |
interfacePreferred=$(echo "$interfacesSorted" | head -1 | cut -d' ' -f1) |
|
if [ "$Lang" == 'fr' ] |
then echo 'Liste des interfaces disponible :' |
else echo 'List of available interfaces:' |
fi |
echo "$interfacesSorted" |
response='' |
while true; do |
if [ "$Lang" == 'fr' ] |
then echo -n "Choix de l'interface interne ? [$interfacePreferred] " |
else echo -n "Choice of internal interface ? [$interfacePreferred] " |
fi |
read response |
|
[ -z "$response" ] && response="$interfacePreferred" |
|
# Check if interface exist |
if [ $(echo "$interfacesList" | grep -c "^$response\$") -eq 1 ]; then |
INTIF="$response" |
break |
else |
if [ "$Lang" == 'fr' ] |
then echo "Interface \"$response\" introuvable" |
else echo "Interface \"$response\" not found" |
fi |
fi |
done |
fi |
fi |
if [ "$Lang" == 'fr' ] |
then echo "Interface interne utilisée : $INTIF" |
else echo "Internal interface used: $INTIF" |
fi |
|
if [ $Lang == "fr" ] |
then echo -n "Tests des paramètres réseau : " |
else echo -n "Network parameters tests: " |
261,40 → 321,39 |
cd $DIR_INSTALL |
echo -n "." |
# Test Ethernet NIC links state |
DOWN_IF=`/usr/sbin/ip link|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "|grep -v "^w"` |
for i in $DOWN_IF |
do |
echo $i |
if [ $Lang == "fr" ] |
then |
echo "Échec" |
echo "Le lien réseau de la carte $i n'est pas actif." |
echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)" |
else |
echo "Failed" |
echo "The link state of $i interface is down." |
echo "Make sure that this network card is connected to a switch or an A.P." |
fi |
exit 0 |
done |
interfacesDown=$(/usr/sbin/ip -br link | grep "^\($EXTIF\|$INTIF\) " | grep 'NO-CARRIER' | cut -d' ' -f1) |
if [ ! -z "$interfacesDown" ]; then |
for i in $interfacesDown; do |
if [ $Lang == "fr" ] |
then |
echo -e "\nÉchec" |
echo "Le lien réseau de la carte $i n'est pas actif." |
echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)" |
else |
echo -e "\nFailed" |
echo "The link state of $i interface is down." |
echo "Make sure that this network card is connected to a switch or an A.P." |
fi |
done |
exit 1 |
fi |
echo -n "." |
# Test EXTIF config files |
PUBLIC_IP_MASK=`ip addr show $EXTIF|grep "inet "|cut -d" " -f6` |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1` |
PUBLIC_GATEWAY=`ip route list|grep $EXTIF|grep ^default|cut -d" " -f3` |
PUBLIC_IP=`/usr/sbin/ip addr show $EXTIF | grep '^\s*inet\s' | awk '{ print $2 }' | cut -d'/' -f1` |
PUBLIC_GATEWAY=`/usr/sbin/ip route list | awk '/^default / {print $3}'` |
if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ] |
then |
if [ $Lang == "fr" ] |
then |
echo "Échec" |
echo -e "\nÉchec" |
echo "La carte réseau connectée à Internet ($EXTIF) n'est pas correctement configurée." |
echo "Renseignez les champs suivants dans le fichier '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :" |
echo "Appliquez les changements : 'systemctl restart network'" |
else |
echo "Failed" |
echo -e "\nFailed" |
echo "The Internet connected network card ($EXTIF) isn't well configured." |
echo "The folowing parametres must be set in the file '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :" |
echo "Apply the new configuration 'systemctl restart network'" |
echo "Apply the new configuration: 'systemctl restart network'" |
fi |
echo "DEVICE=$EXTIF" |
echo "IPADDR=" |
303,22 → 362,22 |
echo "DNS1=" |
echo "DNS2=" |
echo "ONBOOT=yes" |
exit 0 |
exit 1 |
fi |
echo -n "." |
# Test if default GW is set on EXTIF (router or ISP provider equipment) |
if [ `ip route list|grep $EXTIF|grep -c ^default` -ne "1" ] ; then |
if [ `/usr/sbin/ip route list|grep " $EXTIF "|grep -c '^default '` -ne 1 ] ; then |
if [ $Lang == "fr" ] |
then |
echo "Échec" |
echo -e "\nÉchec" |
echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte." |
echo "Réglez ce problème puis relancez ce script." |
else |
echo "Failed" |
echo -e "\nFailed" |
echo "You haven't configured Internet access or Internet link is on the wrong Ethernet card" |
echo "Resolv this problem, then restart this script." |
fi |
exit 0 |
exit 1 |
fi |
echo -n "." |
# Test if default GW is alive |
327,35 → 386,33 |
then |
if [ $Lang == "fr" ] |
then |
echo "Échec" |
echo -e "\nÉchec" |
echo "Le routeur de sortie ou la Box Internet ($PUBLIC_GATEWAY) ne répond pas." |
echo "Réglez ce problème puis relancez ce script." |
else |
echo "Failed" |
echo -e "\nFailed" |
echo "The Internet gateway or the ISP equipment ($PUBLIC_GATEWAY) doesn't answered." |
echo "Resolv this problem, then restart this script." |
fi |
exit 0 |
exit 1 |
fi |
echo -n "." |
# Test Internet connectivity |
rm -rf /tmp/con_ok.html |
/usr/bin/curl www.google.fr -s -o /tmp/con_ok.html |
if [ ! -e /tmp/con_ok.html ] |
then |
domainTested='www.google.com' |
/usr/bin/curl -s --head "$domainTested" &>/dev/null |
if [ $? -ne 0 ]; then |
if [ $Lang == "fr" ] |
then |
echo "La tentative de connexion vers Internet a échoué (google.fr)." |
echo -e "\nLa tentative de connexion vers Internet a échoué ($domainTested)." |
echo "Vérifiez que la carte $EXTIF est bien connectée au routeur du FAI." |
echo "Vérifiez la validité des adresses IP des DNS." |
else |
echo "The Internet connection try failed (google.fr)." |
echo -e "\nThe Internet connection try failed ($domainTested)." |
echo "Please, verify that the $EXTIF card is connected with the Internet gateway." |
echo "Verify the DNS IP addresses" |
fi |
exit 0 |
exit 1 |
fi |
rm -rf /tmp/con_ok.html |
echo ". : ok" |
} # end of testing () |
|