maj squelette
This commit is contained in:
parent
55fdea8116
commit
136b8e225e
160
ulib/debian
160
ulib/debian
|
@ -114,40 +114,92 @@ END {
|
||||||
|
|
||||||
__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS=
|
__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS=
|
||||||
|
|
||||||
function debian_network_fix_confbrs() {
|
function network_parse_confbr() {
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_confips() {
|
function network_format_confbr() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_parse_confip() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_parse_ipsuffix() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_format_confip() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_format_ipsuffix() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_set_confbrs() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_set_confips() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_fix_confbrs() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_fix_confips() {
|
||||||
# $2==mainiface, l'interface associée aux adresses ip non qualifiées
|
# $2==mainiface, l'interface associée aux adresses ip non qualifiées
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_mainiface() {
|
function network_fix_mainiface() {
|
||||||
# confips[0] est la configuration ip de l'interface principale
|
# confips[0] est la configuration ip de l'interface principale
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_confs() {
|
function network_fix_confs() {
|
||||||
network_fix_confbrs "${1:-confbrs}"
|
network_fix_confbrs "${1:-confbrs}"
|
||||||
network_fix_confips "${2:-confips}"
|
network_fix_confips "${2:-confips}"
|
||||||
network_fix_mainiface "${1:-confbrs}" "${2:-confips}" "$3"
|
network_fix_mainiface "${1:-confbrs}" "${2:-confips}" "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function network_interfaces_check_confbr() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_interfaces_check_confip() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_interfaces_remove_iface() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_interfaces_add_confbr() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function network_interfaces_add_confip() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
#XXX
|
#XXX
|
||||||
function debian_network_backup() {
|
function network_backup() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local backup="$file.orig$(date +%Y%m%d)"
|
local backup="$file.orig$(date +%Y%m%d)"
|
||||||
[ -f "$backup" ] || cat "$file" >"$backup" 2>/dev/null
|
[ -f "$backup" ] || cat "$file" >"$backup" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_hostname() {
|
function network_hostname() {
|
||||||
local hostname="${1%%.*}"
|
local hostname="${1%%.*}"
|
||||||
[ -f /etc/hostname ] || touch /etc/hostname
|
[ -f /etc/hostname ] || touch /etc/hostname
|
||||||
if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then
|
if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then
|
||||||
uecho "Setting /etc/hostname to $hostname"
|
uecho "Setting /etc/hostname to $hostname"
|
||||||
elif [ "$(</etc/hostname)" != "$hostname" ]; then
|
elif [ "$(</etc/hostname)" != "$hostname" ]; then
|
||||||
debian_network_backup /etc/hostname
|
network_backup /etc/hostname
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/hostname to $hostname"
|
edebug "Setting /etc/hostname to $hostname"
|
||||||
else
|
else
|
||||||
|
@ -157,13 +209,13 @@ function debian_network_hostname() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_mailname() {
|
function network_mailname() {
|
||||||
local host="$1"
|
local host="$1"
|
||||||
[ -f /etc/mailname ] || touch /etc/mailname
|
[ -f /etc/mailname ] || touch /etc/mailname
|
||||||
if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then
|
if [ -n "$__DEBIAN_NETWORK_DEVEL_SHOW_MODIFS" ]; then
|
||||||
uecho "Setting /etc/mailname to $host"
|
uecho "Setting /etc/mailname to $host"
|
||||||
elif [ "$(</etc/mailname)" != "$host" ]; then
|
elif [ "$(</etc/mailname)" != "$host" ]; then
|
||||||
debian_network_backup /etc/mailname
|
network_backup /etc/mailname
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/mailname to $host"
|
edebug "Setting /etc/mailname to $host"
|
||||||
else
|
else
|
||||||
|
@ -173,7 +225,7 @@ function debian_network_mailname() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_exim4() {
|
function network_fix_exim4() {
|
||||||
local host="$1" oldhost="$2"
|
local host="$1" oldhost="$2"
|
||||||
local tmpfile; ac_set_tmpfile tmpfile
|
local tmpfile; ac_set_tmpfile tmpfile
|
||||||
|
|
||||||
|
@ -188,7 +240,7 @@ dc_other_hostnames='$host'"
|
||||||
uecho "/etc/exim4/update-exim4.conf.conf: pas de modifications"
|
uecho "/etc/exim4/update-exim4.conf.conf: pas de modifications"
|
||||||
fi
|
fi
|
||||||
elif testdiff "$tmpfile" /etc/exim4/update-exim4.conf.conf; then
|
elif testdiff "$tmpfile" /etc/exim4/update-exim4.conf.conf; then
|
||||||
debian_network_backup /etc/exim4/update-exim4.conf.conf
|
network_backup /etc/exim4/update-exim4.conf.conf
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/exim4/update-exim4.conf.conf to:"
|
edebug "Setting /etc/exim4/update-exim4.conf.conf to:"
|
||||||
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
||||||
|
@ -201,7 +253,7 @@ dc_other_hostnames='$host'"
|
||||||
ac_clean "$tmpfile"
|
ac_clean "$tmpfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_postfix() {
|
function network_fix_postfix() {
|
||||||
local host="$1" oldhost="$2"
|
local host="$1" oldhost="$2"
|
||||||
local tmpfile; ac_set_tmpfile tmpfile
|
local tmpfile; ac_set_tmpfile tmpfile
|
||||||
|
|
||||||
|
@ -222,7 +274,7 @@ function debian_network_fix_postfix() {
|
||||||
uecho "/etc/postfix/main.cf: pas de modifications"
|
uecho "/etc/postfix/main.cf: pas de modifications"
|
||||||
fi
|
fi
|
||||||
elif testdiff "$tmpfile" /etc/postfix/main.cf; then
|
elif testdiff "$tmpfile" /etc/postfix/main.cf; then
|
||||||
debian_network_backup /etc/postfix/main.cf
|
network_backup /etc/postfix/main.cf
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/postfix/main.cf to:"
|
edebug "Setting /etc/postfix/main.cf to:"
|
||||||
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
||||||
|
@ -234,7 +286,7 @@ function debian_network_fix_postfix() {
|
||||||
ac_clean "$tmpfile"
|
ac_clean "$tmpfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_hosts() {
|
function network_hosts() {
|
||||||
local host="$1" hostname="${1%%.*}" ip="$2"
|
local host="$1" hostname="${1%%.*}" ip="$2"
|
||||||
local shost="${host//./\\.}"
|
local shost="${host//./\\.}"
|
||||||
local tmpfile; ac_set_tmpfile tmpfile
|
local tmpfile; ac_set_tmpfile tmpfile
|
||||||
|
@ -261,7 +313,7 @@ $ip$TAB$host $hostname" "$tmpfile"
|
||||||
uecho "/etc/hosts: pas de modifications"
|
uecho "/etc/hosts: pas de modifications"
|
||||||
fi
|
fi
|
||||||
elif testdiff "$tmpfile" /etc/hosts; then
|
elif testdiff "$tmpfile" /etc/hosts; then
|
||||||
debian_network_backup /etc/hosts
|
network_backup /etc/hosts
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/hosts to:"
|
edebug "Setting /etc/hosts to:"
|
||||||
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
cat "$tmpfile" | sed 's/^/ /g' 1>&2
|
||||||
|
@ -273,7 +325,7 @@ $ip$TAB$host $hostname" "$tmpfile"
|
||||||
ac_clean "$tmpfile"
|
ac_clean "$tmpfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_parse_confip() {
|
function network_parse_confip() {
|
||||||
# confip --> iface [ipspecs@] [ipspecs]
|
# confip --> iface [ipspecs@] [ipspecs]
|
||||||
local __npc_tmp
|
local __npc_tmp
|
||||||
splitfsep2 "$1" : "${2:-iface}" __npc_tmp
|
splitfsep2 "$1" : "${2:-iface}" __npc_tmp
|
||||||
|
@ -281,14 +333,14 @@ function debian_network_parse_confip() {
|
||||||
[ -n "$4" ] && set_var "$4" "$__npc_tmp"
|
[ -n "$4" ] && set_var "$4" "$__npc_tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_parse_ipspec() {
|
function network_parse_ipspec() {
|
||||||
# ipspec --> ip suffix gateway
|
# ipspec --> ip suffix gateway
|
||||||
local __npi_tmp
|
local __npi_tmp
|
||||||
splitfsep "$1" / "${2:-ip}" __npi_tmp
|
splitfsep "$1" / "${2:-ip}" __npi_tmp
|
||||||
splitfsep "$__npi_tmp" + "${3:-suffix}" "${4:-gateway}"
|
splitfsep "$__npi_tmp" + "${3:-suffix}" "${4:-gateway}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_parse_confbr() {
|
function network_parse_confbr() {
|
||||||
# confbr --> br [ifaces@] [ifaces]
|
# confbr --> br [ifaces@] [ifaces]
|
||||||
local __npc_tmp
|
local __npc_tmp
|
||||||
splitfsep "$1" : "${2:-br}" __npc_tmp
|
splitfsep "$1" : "${2:-br}" __npc_tmp
|
||||||
|
@ -296,7 +348,7 @@ function debian_network_parse_confbr() {
|
||||||
[ -n "$4" ] && set_var "$4" "$__npc_tmp"
|
[ -n "$4" ] && set_var "$4" "$__npc_tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_confips() {
|
function network_fix_confips() {
|
||||||
# confips@
|
# confips@
|
||||||
local -a __nfc_confips __nfc_ipspecs __nfc_ifaces __nfc_ips
|
local -a __nfc_confips __nfc_ipspecs __nfc_ifaces __nfc_ips
|
||||||
local __nfc_confip __nfc_iface __nfc_ipspec __nfc_ip __nfc_suffix __nfc_gateway __nfc_first
|
local __nfc_confip __nfc_iface __nfc_ipspec __nfc_ip __nfc_suffix __nfc_gateway __nfc_first
|
||||||
|
@ -304,15 +356,15 @@ function debian_network_fix_confips() {
|
||||||
array_copy __nfc_confips "${1:-confips}"
|
array_copy __nfc_confips "${1:-confips}"
|
||||||
# recenser les interfaces et créer les tableaux __IFACE_ipspecs
|
# recenser les interfaces et créer les tableaux __IFACE_ipspecs
|
||||||
for __nfc_confip in "${__nfc_confips[@]}"; do
|
for __nfc_confip in "${__nfc_confips[@]}"; do
|
||||||
debian_network_parse_confip "$__nfc_confip" __nfc_iface __nfc_ipspecs
|
network_parse_confip "$__nfc_confip" __nfc_iface __nfc_ipspecs
|
||||||
array_addu __nfc_ifaces "$__nfc_iface"
|
array_addu __nfc_ifaces "$__nfc_iface"
|
||||||
eval "local -a __nfc_${__nfc_iface}_ipspecs"
|
eval "local -a __nfc_${__nfc_iface}_ipspecs"
|
||||||
done
|
done
|
||||||
# puis constuire la liste des adresses IP associées à chaque interface
|
# puis constuire la liste des adresses IP associées à chaque interface
|
||||||
for __nfc_confip in "${__nfc_confips[@]}"; do
|
for __nfc_confip in "${__nfc_confips[@]}"; do
|
||||||
debian_network_parse_confip "$__nfc_confip" __nfc_iface __nfc_ipspecs
|
network_parse_confip "$__nfc_confip" __nfc_iface __nfc_ipspecs
|
||||||
for __nfc_ipspec in "${__nfc_ipspecs[@]}"; do
|
for __nfc_ipspec in "${__nfc_ipspecs[@]}"; do
|
||||||
debian_network_parse_ipspec "$__nfc_ipspec" __nfc_ip __nfc_suffix __nfc_gateway
|
network_parse_ipspec "$__nfc_ipspec" __nfc_ip __nfc_suffix __nfc_gateway
|
||||||
if ! array_contains __nfc_ips "$__nfc_ip"; then
|
if ! array_contains __nfc_ips "$__nfc_ip"; then
|
||||||
[ -n "$__nfc_suffix" ] || __nfc_suffix=24
|
[ -n "$__nfc_suffix" ] || __nfc_suffix=24
|
||||||
if [ -z "$__nfc_gateway" ] && array_isempty "__nfc_${__nfc_iface}_ipspecs"; then
|
if [ -z "$__nfc_gateway" ] && array_isempty "__nfc_${__nfc_iface}_ipspecs"; then
|
||||||
|
@ -334,7 +386,7 @@ function debian_network_fix_confips() {
|
||||||
array_copy "${1:-confips}" __nfc_confips
|
array_copy "${1:-confips}" __nfc_confips
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_fix_confbrs() {
|
function network_fix_confbrs() {
|
||||||
# confbrs@
|
# confbrs@
|
||||||
local -a __nfc_confbrs __nfc_ifaces __nfc_brs __nfc_ips
|
local -a __nfc_confbrs __nfc_ifaces __nfc_brs __nfc_ips
|
||||||
local __nfc_confbr __nfc_br __nfc_iface __nfc_ip __nfc_suffix __nfc_gateway
|
local __nfc_confbr __nfc_br __nfc_iface __nfc_ip __nfc_suffix __nfc_gateway
|
||||||
|
@ -342,13 +394,13 @@ function debian_network_fix_confbrs() {
|
||||||
array_copy __nfc_confbrs "${1:-confbrs}"
|
array_copy __nfc_confbrs "${1:-confbrs}"
|
||||||
# recenser les bridges et créer les tableaux __BR_ifaces
|
# recenser les bridges et créer les tableaux __BR_ifaces
|
||||||
for __nfc_confbr in "${__nfc_confbrs[@]}"; do
|
for __nfc_confbr in "${__nfc_confbrs[@]}"; do
|
||||||
debian_network_parse_confbr "$__nfc_confbr" __nfc_br __nfc_ifaces
|
network_parse_confbr "$__nfc_confbr" __nfc_br __nfc_ifaces
|
||||||
array_addu __nfc_brs "$__nfc_br"
|
array_addu __nfc_brs "$__nfc_br"
|
||||||
eval "local -a __nfc_${__nfc_br}_ifaces"
|
eval "local -a __nfc_${__nfc_br}_ifaces"
|
||||||
done
|
done
|
||||||
# puis constuire la liste des interfaces associées à chaque bridge
|
# puis constuire la liste des interfaces associées à chaque bridge
|
||||||
for __nfc_confbr in "${__nfc_confbrs[@]}"; do
|
for __nfc_confbr in "${__nfc_confbrs[@]}"; do
|
||||||
debian_network_parse_confbr "$__nfc_confbr" __nfc_br __nfc_ifaces
|
network_parse_confbr "$__nfc_confbr" __nfc_br __nfc_ifaces
|
||||||
array_extendu "__nfc_${__nfc_br}_ifaces" __nfc_ifaces
|
array_extendu "__nfc_${__nfc_br}_ifaces" __nfc_ifaces
|
||||||
done
|
done
|
||||||
# puis construire le tableau final
|
# puis construire le tableau final
|
||||||
|
@ -360,14 +412,14 @@ function debian_network_fix_confbrs() {
|
||||||
array_copy "${1:-confbrs}" __nfc_confbrs
|
array_copy "${1:-confbrs}" __nfc_confbrs
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_resolve_mainiface() {
|
function network_resolve_mainiface() {
|
||||||
local __nrm_mainiface="${1:-mainiface}" __nrm_mainconfbr="$2" __nrm_mainconfip="$3"
|
local __nrm_mainiface="${1:-mainiface}" __nrm_mainconfbr="$2" __nrm_mainconfip="$3"
|
||||||
[ -n "${!__nrm_mainiface}" ] || debian_network_parse_confbr "$__nrm_mainconfbr" "$__nrm_mainiface"
|
[ -n "${!__nrm_mainiface}" ] || network_parse_confbr "$__nrm_mainconfbr" "$__nrm_mainiface"
|
||||||
[ -n "${!__nrm_mainiface}" ] || debian_network_parse_confip "$__nrm_mainconfip" "$__nrm_mainiface"
|
[ -n "${!__nrm_mainiface}" ] || network_parse_confip "$__nrm_mainconfip" "$__nrm_mainiface"
|
||||||
[ -n "${!__nrm_mainiface}" ] || set_var "$__nrm_mainiface" eth0
|
[ -n "${!__nrm_mainiface}" ] || set_var "$__nrm_mainiface" eth0
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_set_confip() {
|
function network_set_confip() {
|
||||||
eval "$(ip addr show dev "$1" | awk "BEGIN {
|
eval "$(ip addr show dev "$1" | awk "BEGIN {
|
||||||
mainipvar = \"${2:-mainip}\"
|
mainipvar = \"${2:-mainip}\"
|
||||||
supplipsvar = \"${3:-supplips}\"
|
supplipsvar = \"${3:-supplips}\"
|
||||||
|
@ -397,7 +449,7 @@ END {
|
||||||
set_var "$2" "$(array_join "$2" ,)"
|
set_var "$2" "$(array_join "$2" ,)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_set_gateway() {
|
function network_set_gateway() {
|
||||||
eval "$(route -n | awk "BEGIN {
|
eval "$(route -n | awk "BEGIN {
|
||||||
iface = \"$1\"
|
iface = \"$1\"
|
||||||
gatewayvar = \"${2:-gateway}\"
|
gatewayvar = \"${2:-gateway}\"
|
||||||
|
@ -410,20 +462,20 @@ $1 == "0.0.0.0" && $8 == iface {
|
||||||
}
|
}
|
||||||
#BUG)"
|
#BUG)"
|
||||||
|
|
||||||
function debian_network_set_confips() {
|
function network_set_confips() {
|
||||||
local -a __nsc_confips __nsc_ifaces __nsc_supplips
|
local -a __nsc_confips __nsc_ifaces __nsc_supplips
|
||||||
local __nsc_iface __nsc_mainip __nsc_gateway
|
local __nsc_iface __nsc_mainip __nsc_gateway
|
||||||
array_from_lines __nsc_ifaces "$(ip link | grep -v '<.*LOOPBACK.*>' | grep '<.*UP.*>' | awk '{ sub(/:$/, "", $2); print $2}')"
|
array_from_lines __nsc_ifaces "$(ip link | grep -v '<.*LOOPBACK.*>' | grep '<.*UP.*>' | awk '{ sub(/:$/, "", $2); print $2}')"
|
||||||
for __nsc_iface in "${__nsc_ifaces[@]}"; do
|
for __nsc_iface in "${__nsc_ifaces[@]}"; do
|
||||||
debian_network_set_confip "$__nsc_iface" __nsc_mainip __nsc_supplips
|
network_set_confip "$__nsc_iface" __nsc_mainip __nsc_supplips
|
||||||
[ -n "$__nsc_mainip" ] || continue
|
[ -n "$__nsc_mainip" ] || continue
|
||||||
debian_network_set_gateway "$__nsc_iface" __nsc_gateway
|
network_set_gateway "$__nsc_iface" __nsc_gateway
|
||||||
array_add __nsc_confips "$__nsc_iface:$__nsc_mainip${__nsc_gateway:++$__nsc_gateway}${__nsc_supplips:+,$__nsc_supplips}"
|
array_add __nsc_confips "$__nsc_iface:$__nsc_mainip${__nsc_gateway:++$__nsc_gateway}${__nsc_supplips:+,$__nsc_supplips}"
|
||||||
done
|
done
|
||||||
array_copy "${1:-confips}" __nsc_confips
|
array_copy "${1:-confips}" __nsc_confips
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_set_confbrs() {
|
function network_set_confbrs() {
|
||||||
local -a __nsc_ifaces __nsc_tmpconfbrs __nsc_confbrs
|
local -a __nsc_ifaces __nsc_tmpconfbrs __nsc_confbrs
|
||||||
local __nsc_confbr __nsc_br __nsc_iface
|
local __nsc_confbr __nsc_br __nsc_iface
|
||||||
array_from_lines __nsc_ifaces "$(ip link | grep -v '<.*LOOPBACK.*>' | grep '<.*UP.*>' | awk '{ sub(/:$/, "", $2); print $2}')"
|
array_from_lines __nsc_ifaces "$(ip link | grep -v '<.*LOOPBACK.*>' | grep '<.*UP.*>' | awk '{ sub(/:$/, "", $2); print $2}')"
|
||||||
|
@ -570,7 +622,7 @@ BEGIN {
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
|
|
||||||
function debian_network_update_bridge() {
|
function network_update_bridge() {
|
||||||
# vérifier la configuration (interfaces de ifaces[@] en manual, présence du
|
# vérifier la configuration (interfaces de ifaces[@] en manual, présence du
|
||||||
# bridge, bridge en auto, adresse ip principale statique ou en dhcp,
|
# bridge, bridge en auto, adresse ip principale statique ou en dhcp,
|
||||||
# adresses ip supplémentaires), puis si nécessaire, supprimer l'ancienne
|
# adresses ip supplémentaires), puis si nécessaire, supprimer l'ancienne
|
||||||
|
@ -804,7 +856,7 @@ END {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function debian_network_update_iface() {
|
function network_update_iface() {
|
||||||
# vérifier la configuration (présence de l'interface, interface en auto,
|
# vérifier la configuration (présence de l'interface, interface en auto,
|
||||||
# adresse ip principale statique ou en dhcp, adresses ip supplémentaires),
|
# adresse ip principale statique ou en dhcp, adresses ip supplémentaires),
|
||||||
# puis si nécessaire, supprimer l'ancienne configuration et créer la
|
# puis si nécessaire, supprimer l'ancienne configuration et créer la
|
||||||
|
@ -967,16 +1019,16 @@ function network_config() {
|
||||||
array_copy confips __nc_confips
|
array_copy confips __nc_confips
|
||||||
array_copy confbrs __nc_confbrs
|
array_copy confbrs __nc_confbrs
|
||||||
|
|
||||||
debian_network_fix_confips confips
|
network_fix_confips confips
|
||||||
debian_network_fix_confbrs confbrs
|
network_fix_confbrs confbrs
|
||||||
|
|
||||||
local mainbr # bridge principal
|
local mainbr # bridge principal
|
||||||
local mainip # adresse IP principale de l'interface principale
|
local mainip # adresse IP principale de l'interface principale
|
||||||
local confbr confip br iface suffix gateway
|
local confbr confip br iface suffix gateway
|
||||||
local -a ipspecs
|
local -a ipspecs
|
||||||
|
|
||||||
debian_network_resolve_mainiface mainiface "${confbrs[0]}" "${confips[0]}"
|
network_resolve_mainiface mainiface "${confbrs[0]}" "${confips[0]}"
|
||||||
debian_network_parse_confbr "${confbrs[0]}" mainbr
|
network_parse_confbr "${confbrs[0]}" mainbr
|
||||||
[ -n "$mainbr" ] || mainbr=br0
|
[ -n "$mainbr" ] || mainbr=br0
|
||||||
|
|
||||||
if [ -n "${confips[*]}" -o -n "${confbrs[*]}" ]; then
|
if [ -n "${confips[*]}" -o -n "${confbrs[*]}" ]; then
|
||||||
|
@ -989,11 +1041,11 @@ function network_config() {
|
||||||
local -a brifaces
|
local -a brifaces
|
||||||
ifaces_with_ips=()
|
ifaces_with_ips=()
|
||||||
for confip in "${confips[@]}"; do
|
for confip in "${confips[@]}"; do
|
||||||
debian_network_parse_confip "$confip" iface
|
network_parse_confip "$confip" iface
|
||||||
array_addu ifaces_with_ips "$iface"
|
array_addu ifaces_with_ips "$iface"
|
||||||
done
|
done
|
||||||
for confbr in "${confbrs[@]}"; do
|
for confbr in "${confbrs[@]}"; do
|
||||||
debian_network_parse_confbr "$confbr" br ifaces
|
network_parse_confbr "$confbr" br ifaces
|
||||||
array_add brifaces "$br"
|
array_add brifaces "$br"
|
||||||
for iface in "${ifaces[@]}"; do
|
for iface in "${ifaces[@]}"; do
|
||||||
if array_contains ifaces_with_ips "$iface"; then
|
if array_contains ifaces_with_ips "$iface"; then
|
||||||
|
@ -1004,7 +1056,7 @@ function network_config() {
|
||||||
done
|
done
|
||||||
local -a confstdips confbrips
|
local -a confstdips confbrips
|
||||||
for confip in "${confips[@]}"; do
|
for confip in "${confips[@]}"; do
|
||||||
debian_network_parse_confip "$confip" iface
|
network_parse_confip "$confip" iface
|
||||||
[ -n "$iface" ] || iface="$mainiface"
|
[ -n "$iface" ] || iface="$mainiface"
|
||||||
if array_contains brifaces "$iface"; then
|
if array_contains brifaces "$iface"; then
|
||||||
array_add confbrips "$confip"
|
array_add confbrips "$confip"
|
||||||
|
@ -1034,37 +1086,37 @@ iface lo inet loopback
|
||||||
local -a tmpifaces
|
local -a tmpifaces
|
||||||
local tmpbr
|
local tmpbr
|
||||||
for confip in "${confbrips[@]}"; do
|
for confip in "${confbrips[@]}"; do
|
||||||
debian_network_parse_confip "$confip" br ipspecs
|
network_parse_confip "$confip" br ipspecs
|
||||||
[ -n "$br" ] || br="$mainbr"
|
[ -n "$br" ] || br="$mainbr"
|
||||||
|
|
||||||
if [ -z "$mainip" -a "$br" == "$mainiface" ]; then
|
if [ -z "$mainip" -a "$br" == "$mainiface" ]; then
|
||||||
debian_network_parse_ipspec "${ipspecs[0]}" mainip suffix gateway
|
network_parse_ipspec "${ipspecs[0]}" mainip suffix gateway
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ifaces=()
|
ifaces=()
|
||||||
for confbr in "${confbrs[@]}"; do
|
for confbr in "${confbrs[@]}"; do
|
||||||
debian_network_parse_confbr "$confbr" tmpbr tmpifaces
|
network_parse_confbr "$confbr" tmpbr tmpifaces
|
||||||
if [ "$tmpbr" == "$br" ]; then
|
if [ "$tmpbr" == "$br" ]; then
|
||||||
array_copy ifaces tmpifaces
|
array_copy ifaces tmpifaces
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if debian_network_update_bridge "$interfaces" "$workfile" "$br" ipspecs ifaces; then
|
if network_update_bridge "$interfaces" "$workfile" "$br" ipspecs ifaces; then
|
||||||
cat "$workfile" >"$interfaces"
|
cat "$workfile" >"$interfaces"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# configurer chaque interface classique
|
# configurer chaque interface classique
|
||||||
for confip in "${confstdips[@]}"; do
|
for confip in "${confstdips[@]}"; do
|
||||||
debian_network_parse_confip "$confip" iface ipspecs
|
network_parse_confip "$confip" iface ipspecs
|
||||||
[ -n "$iface" ] || iface="$mainiface"
|
[ -n "$iface" ] || iface="$mainiface"
|
||||||
|
|
||||||
if [ -z "$mainip" -a "$iface" == "$mainiface" ]; then
|
if [ -z "$mainip" -a "$iface" == "$mainiface" ]; then
|
||||||
debian_network_parse_ipspec "${ipspecs[0]}" mainip suffix gateway
|
network_parse_ipspec "${ipspecs[0]}" mainip suffix gateway
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if debian_network_update_iface "$interfaces" "$workfile" "$iface" ipspecs; then
|
if network_update_iface "$interfaces" "$workfile" "$iface" ipspecs; then
|
||||||
cat "$workfile" >"$interfaces"
|
cat "$workfile" >"$interfaces"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -1078,7 +1130,7 @@ iface lo inet loopback
|
||||||
uecho "/etc/network/interfaces: pas de modifications"
|
uecho "/etc/network/interfaces: pas de modifications"
|
||||||
fi
|
fi
|
||||||
elif testdiff "$interfaces" /etc/network/interfaces; then
|
elif testdiff "$interfaces" /etc/network/interfaces; then
|
||||||
debian_network_backup /etc/network/interfaces
|
network_backup /etc/network/interfaces
|
||||||
if show_debug; then
|
if show_debug; then
|
||||||
edebug "Setting /etc/network/interfaces to:"
|
edebug "Setting /etc/network/interfaces to:"
|
||||||
cat "$interfaces" | sed 's/^/ /g' 1>&2
|
cat "$interfaces" | sed 's/^/ /g' 1>&2
|
||||||
|
@ -1112,10 +1164,10 @@ iface lo inet loopback
|
||||||
mainip="${mainips[0]}"
|
mainip="${mainips[0]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debian_network_hostname "$host"
|
network_hostname "$host"
|
||||||
debian_network_mailname "$host"
|
network_mailname "$host"
|
||||||
if [ -n "$mainip" ]; then
|
if [ -n "$mainip" ]; then
|
||||||
debian_network_hosts "$host" "$mainip"
|
network_hosts "$host" "$mainip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eend
|
eend
|
||||||
|
|
Loading…
Reference in New Issue