afficher ce qui est fait

This commit is contained in:
Jephté Clain 2014-01-28 16:29:37 +04:00
parent c6727703ef
commit 753cb6c489
1 changed files with 51 additions and 9 deletions

View File

@ -127,6 +127,11 @@ function __network_hostname() {
uecho "Setting /etc/hostname to $hostname" uecho "Setting /etc/hostname to $hostname"
elif [ "$(</etc/hostname)" != "$hostname" ]; then elif [ "$(</etc/hostname)" != "$hostname" ]; then
__network_backup /etc/hostname __network_backup /etc/hostname
if show_debug; then
edebug "Setting /etc/hostname to $hostname"
else
estep /etc/hostname
fi
echo "$hostname" >/etc/hostname echo "$hostname" >/etc/hostname
fi fi
} }
@ -138,6 +143,11 @@ function __network_mailname() {
uecho "Setting /etc/mailname to $host" uecho "Setting /etc/mailname to $host"
elif [ "$(</etc/mailname)" != "$host" ]; then elif [ "$(</etc/mailname)" != "$host" ]; then
__network_backup /etc/mailname __network_backup /etc/mailname
if show_debug; then
edebug "Setting /etc/mailname to $host"
else
estep /etc/mailname
fi
echo "$host" >/etc/mailname echo "$host" >/etc/mailname
fi fi
} }
@ -158,6 +168,12 @@ dc_other_hostnames='$host'"
fi fi
elif testdiff "$tmpfile" /etc/exim4/update-exim4.conf.conf; then elif testdiff "$tmpfile" /etc/exim4/update-exim4.conf.conf; then
__network_backup /etc/exim4/update-exim4.conf.conf __network_backup /etc/exim4/update-exim4.conf.conf
if show_debug; then
edebug "Setting /etc/exim4/update-exim4.conf.conf to:"
cat "$tmpfile" | sed 's/^/ /g' 1>&2
else
estep /etc/exim4/update-exim4.conf.conf
fi
cat "$tmpfile" >/etc/exim4/update-exim4.conf.conf cat "$tmpfile" >/etc/exim4/update-exim4.conf.conf
update-exim4.conf update-exim4.conf
fi fi
@ -186,6 +202,12 @@ function __network_fix_postfix() {
fi fi
elif testdiff "$tmpfile" /etc/postfix/main.cf; then elif testdiff "$tmpfile" /etc/postfix/main.cf; then
__network_backup /etc/postfix/main.cf __network_backup /etc/postfix/main.cf
if show_debug; then
edebug "Setting /etc/postfix/main.cf to:"
cat "$tmpfile" | sed 's/^/ /g' 1>&2
else
estep /etc/postfix/main.cf
fi
cat "$tmpfile" >/etc/postfix/main.cf cat "$tmpfile" >/etc/postfix/main.cf
fi fi
ac_clean "$tmpfile" ac_clean "$tmpfile"
@ -219,6 +241,12 @@ $ip$TAB$host $hostname" "$tmpfile"
fi fi
elif testdiff "$tmpfile" /etc/hosts; then elif testdiff "$tmpfile" /etc/hosts; then
__network_backup /etc/hosts __network_backup /etc/hosts
if show_debug; then
edebug "Setting /etc/hosts to:"
cat "$tmpfile" | sed 's/^/ /g' 1>&2
else
estep /etc/hosts
fi
cat "$tmpfile" >/etc/hosts cat "$tmpfile" >/etc/hosts
fi fi
ac_clean "$tmpfile" ac_clean "$tmpfile"
@ -359,7 +387,7 @@ $1 == "0.0.0.0" && $8 == iface {
print gatewayvar "=\"" $2 "\"" print gatewayvar "=\"" $2 "\""
}')" }')"
} }
#BUG")" #BUG)"
function __network_set_confips() { function __network_set_confips() {
local -a __nsc_confips __nsc_ifaces __nsc_supplips local -a __nsc_confips __nsc_ifaces __nsc_supplips
@ -475,8 +503,12 @@ BEGIN {
gateway = "" gateway = ""
} }
if (i == 1) { if (i == 1) {
if (ip == "dhcp") method = "dhcp" if (ip == "dhcp") {
else method = "static" method = "dhcp"
} else {
method = "static"
mainip = ip
}
} }
if (suffix == "") suffix = "24" if (suffix == "") suffix = "24"
ips[i] = ip ips[i] = ip
@ -500,8 +532,12 @@ BEGIN {
gateway = "" gateway = ""
} }
if (i == 1) { if (i == 1) {
if (ip == "dhcp") method = "dhcp" if (ip == "dhcp") {
else method = "static" method = "dhcp"
} else {
method = "static"
mainip = ip
}
} }
if (suffix == "") suffix = "24" if (suffix == "") suffix = "24"
ips[i] = ip ips[i] = ip
@ -789,7 +825,10 @@ in_iface && $0 ~ "^[ \\t]*down (/sbin/)?ip addr del " {
} }
next next
} }
$1 == "iface" { in_iface = 0; next; } $1 == "iface" {
in_iface = 0
next
}
$1 == "allow-hotplug" { $1 == "allow-hotplug" {
if (($0 " ") ~ (" " iface " ")) have_hotplug = 1 if (($0 " ") ~ (" " iface " ")) have_hotplug = 1
in_iface = 0 in_iface = 0
@ -1019,6 +1058,12 @@ iface lo inet loopback
fi fi
elif testdiff "$interfaces" /etc/network/interfaces; then elif testdiff "$interfaces" /etc/network/interfaces; then
__network_backup /etc/network/interfaces __network_backup /etc/network/interfaces
if show_debug; then
edebug "Setting /etc/network/interfaces to:"
cat "$interfaces" | sed 's/^/ /g' 1>&2
else
estep /etc/network/interfaces
fi
cat "$interfaces" >/etc/network/interfaces cat "$interfaces" >/etc/network/interfaces
fi fi
ac_clean "$interfaces" "$workfile" ac_clean "$interfaces" "$workfile"
@ -1046,12 +1091,9 @@ iface lo inet loopback
mainip="${mainips[0]}" mainip="${mainips[0]}"
fi fi
estep "/etc/hostname"
__network_hostname "$host" __network_hostname "$host"
estep "/etc/mailname"
__network_mailname "$host" __network_mailname "$host"
if [ -n "$mainip" ]; then if [ -n "$mainip" ]; then
estep "/etc/hosts"
__network_hosts "$host" "$mainip" __network_hosts "$host" "$mainip"
fi fi