| 233,24 → 233,13 |
| { |
| # Detect external/internal interfaces |
| if [ -z "$EXTIF" ]; then |
| GwListSorted=$(/usr/sbin/ip r list | grep default | cut -d" " -f5 | uniq ) |
| nb_gw=$(echo $GwListSorted | wc -w) |
| if [ $nb_gw -eq 0 ]; then |
| EXTIF=$(/usr/sbin/ip route list | awk '/ via / {print $5}' | uniq) |
| if [ -z "$EXTIF" ]; then |
| if [ "$Lang" == 'fr' ] |
| then echo "Aucune passerelle par défaut configurée" |
| else echo "No default gateway configured" |
| fi |
| exit 1 |
| elif [ $nb_gw -eq 1 ]; then |
| EXTIF="$GwListSorted" |
| else |
| if [ "$Lang" == 'fr' ] |
| then echo -n "Erreur : Plusieurs interfaces ont une passerelle par défaut ( " |
| else echo -n "Error : Several interfaces have a default gateway ( " |
| fi |
| echo "$GwListSorted" | tr "\n" " " |
| echo ")" |
| exit 1 |
| fi |
| fi |
| if [ "$Lang" == 'fr' ] |
| 259,34 → 248,36 |
| fi |
| |
| if [ -z "$INTIF" ]; then |
| IntifListSorted=$(/usr/sbin/ip -br link show | cut -d' ' -f1 | grep -v "^\(lo\|tun0\|$EXTIF\)\$" | uniq | sort) |
| IntifCount=$(echo "$IntifListSorted" | wc -w) |
| if [ $IntifCount -eq 0 ]; then |
| interfacesList=$(/usr/sbin/ip -br link show | cut -d' ' -f1 | grep -v "^\(lo\|tun0\|$EXTIF\)\$") |
| interfacesCount=$(echo "$interfacesList" | wc -w) |
| 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 [ $IntifCount -eq 1 ]; then |
| INTIF="$IntifListSorted" |
| elif [ $interfacesCount -eq 1 ]; then |
| INTIF="$interfacesList" |
| else |
| IntifPreferred=$(echo "$IntifListSorted" | head -1 | cut -d' ' -f1) |
| 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 disponibles pour le réseau interne :' |
| else echo 'List of available interfaces for internal network:' |
| then echo 'Liste des interfaces disponible :' |
| else echo 'List of available interfaces:' |
| fi |
| echo "$IntifListSorted" |
| echo "$interfacesSorted" |
| response='' |
| while true; do |
| if [ "$Lang" == 'fr' ] |
| then echo -n "Choix de l'interface interne ? [$IntifPreferred] " |
| else echo -n "Choice of internal interface ? [$IntifPreferred] " |
| then echo -n "Choix de l'interface interne ? [$interfacePreferred] " |
| else echo -n "Choice of internal interface ? [$interfacePreferred] " |
| fi |
| read response |
| [ -z "$response" ] && response="$IntifPreferred" |
| |
| [ -z "$response" ] && response="$interfacePreferred" |
| |
| # Check if interface exist |
| if [ "$(echo "$IntifListSorted" | grep -c "^$response\$")" -eq 1 ]; then |
| if [ "$(echo "$interfacesList" | grep -c "^$response\$")" -eq 1 ]; then |
| INTIF="$response" |
| break |
| else |