correction d'un bug

paramétrer /etc/network/interfaces dans __DEBIAN_NETWORK_INTERFACES pour les tests
This commit is contained in:
Jephte CLAIN 2014-02-26 23:29:30 +04:00
parent 8f99945561
commit dc1be77e2f
1 changed files with 17 additions and 16 deletions

View File

@ -68,6 +68,7 @@ function service_enable() {
# Gestion des interfaces réseau # Gestion des interfaces réseau
__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS= __DEBIAN_NETWORK_DEVEL_SHOW_MODIFS=
__DEBIAN_NETWORK_INTERFACES=/etc/network/interfaces
function __network_parse_confbr() { function __network_parse_confbr() {
local br; local -a ifaces local br; local -a ifaces
@ -368,7 +369,7 @@ function network_interfaces_check_confbr() {
local br="$1" local br="$1"
local -a ifaces; array_copy ifaces __nicc_ifaces local -a ifaces; array_copy ifaces __nicc_ifaces
local nifile="${3:-/etc/network/interfaces}" local nifile="${3:-$__DEBIAN_NETWORK_INTERFACES}"
awkrun <"$nifile" -f br="$br" ifaces[@]=__nicc_ifaces ' awkrun <"$nifile" -f br="$br" ifaces[@]=__nicc_ifaces '
BEGIN { BEGIN {
@ -442,7 +443,7 @@ function network_interfaces_check_confip() {
local iface="$1" gateway="$2" local iface="$1" gateway="$2"
local -a ipsuffixes; array_copy ipsuffixes __nicc_ipsuffixes local -a ipsuffixes; array_copy ipsuffixes __nicc_ipsuffixes
local nifile="${4:-/etc/network/interfaces}" local nifile="${4:-$__DEBIAN_NETWORK_INTERFACES}"
awkrun <"$nifile" -f iface="$iface" gateway="$gateway" ipsuffixes[@]=ipsuffixes ' awkrun <"$nifile" -f iface="$iface" gateway="$gateway" ipsuffixes[@]=ipsuffixes '
BEGIN { BEGIN {
@ -625,7 +626,7 @@ END {
function network_interfaces_remove_iface() { function network_interfaces_remove_iface() {
# Supprimer dans le fichier $2(=/etc/network/interfaces) toute la # Supprimer dans le fichier $2(=/etc/network/interfaces) toute la
# configuration qui concerne l'interface $1 # configuration qui concerne l'interface $1
local iface="$1" nifile="${2:-/etc/network/interfaces}" local iface="$1" nifile="${2:-$__DEBIAN_NETWORK_INTERFACES}"
local tmpfile; ac_set_tmpfile tmpfile local tmpfile; ac_set_tmpfile tmpfile
local modified local modified
@ -642,7 +643,7 @@ function network_interfaces_remove_ifaces() {
local -a __niri_ifaces; array_copy __niri_ifaces "${1:-ifaces}" local -a __niri_ifaces; array_copy __niri_ifaces "${1:-ifaces}"
local -a ifaces; array_copy ifaces __niri_ifaces local -a ifaces; array_copy ifaces __niri_ifaces
local nifile="${2:-/etc/network/interfaces}" local nifile="${2:-$__DEBIAN_NETWORK_INTERFACES}"
local workfile; ac_set_tmpfile workfile local workfile; ac_set_tmpfile workfile
local tmpfile; ac_set_tmpfile tmpfile local tmpfile; ac_set_tmpfile tmpfile
local iface modified local iface modified
@ -678,7 +679,7 @@ function network_interfaces_add_confip() {
local iface="$1" gateway="$2" local iface="$1" gateway="$2"
local -a ipsuffixes; array_copy ipsuffixes __niac_ipsuffixes local -a ipsuffixes; array_copy ipsuffixes __niac_ipsuffixes
local nifile="${4:-/etc/network/interfaces}" local nifile="${4:-$__DEBIAN_NETWORK_INTERFACES}"
local mainip netmask method local mainip netmask method
network_parse_ipsuffix "${ipsuffixes[0]}" mainip netmask network_parse_ipsuffix "${ipsuffixes[0]}" mainip netmask
@ -718,7 +719,7 @@ function network_interfaces_add_confbr() {
local br="$1" local br="$1"
local -a ifaces; array_copy ifaces __niac_ifaces local -a ifaces; array_copy ifaces __niac_ifaces
local -a confips; array_copy confips __niac_confips local -a confips; array_copy confips __niac_confips
local nifile="${4:-/etc/network/interfaces}" local nifile="${4:-$__DEBIAN_NETWORK_INTERFACES}"
local iface confip local iface confip
for iface in "${ifaces[@]}"; do for iface in "${ifaces[@]}"; do
@ -1011,7 +1012,7 @@ function network_config() {
if [ -n "$modify" ]; then if [ -n "$modify" ]; then
# faire une copie de travail # faire une copie de travail
local interfaces; ac_set_tmpfile interfaces local interfaces; ac_set_tmpfile interfaces
cat /etc/network/interfaces >"$interfaces" cat "$__DEBIAN_NETWORK_INTERFACES" >"$interfaces"
if [ -n "$reset_interfaces" ]; then if [ -n "$reset_interfaces" ]; then
echo >"$interfaces" "\ echo >"$interfaces" "\
@ -1031,7 +1032,7 @@ iface lo inet loopback
done done
for confip in "${confips[@]}"; do for confip in "${confips[@]}"; do
network_parse_confip "$confip" iface gateway ipsuffixes network_parse_confip "$confip" iface gateway ipsuffixes
network_interfaces_remove_iface "$iface" network_interfaces_remove_iface "$iface" "$interfaces"
done done
# puis recréer la configuration # puis recréer la configuration
@ -1048,21 +1049,21 @@ iface lo inet loopback
# Fin de traitement # Fin de traitement
if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then
if testdiff "$interfaces" /etc/network/interfaces; then if testdiff "$interfaces" "$__DEBIAN_NETWORK_INTERFACES"; then
uecho "Setting /etc/network/interfaces to:" uecho "Setting $__DEBIAN_NETWORK_INTERFACES to:"
cat "$interfaces" | sed 's/^/ /g' 1>&2 cat "$interfaces" | sed 's/^/ /g' 1>&2
else else
uecho "/etc/network/interfaces: pas de modifications" uecho "$__DEBIAN_NETWORK_INTERFACES: pas de modifications"
fi fi
elif testdiff "$interfaces" /etc/network/interfaces; then elif testdiff "$interfaces" "$__DEBIAN_NETWORK_INTERFACES"; then
__network_backup /etc/network/interfaces __network_backup "$__DEBIAN_NETWORK_INTERFACES"
if show_debug; then if show_debug; then
edebug "Setting /etc/network/interfaces to:" edebug "Setting $__DEBIAN_NETWORK_INTERFACES to:"
cat "$interfaces" | sed 's/^/ /g' 1>&2 cat "$interfaces" | sed 's/^/ /g' 1>&2
else else
estep /etc/network/interfaces estep "$__DEBIAN_NETWORK_INTERFACES"
fi fi
cat "$interfaces" >/etc/network/interfaces cat "$interfaces" >"$__DEBIAN_NETWORK_INTERFACES"
modified=1 modified=1
fi fi
ac_clean "$interfaces" ac_clean "$interfaces"