summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/ethernet.pm4
-rw-r--r--perl-install/network/network.pm18
2 files changed, 16 insertions, 6 deletions
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 91eac7d69..b3e4eb1ee 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -195,6 +195,7 @@ sub configureNetwork {
$last or return;
if ($last->{BOOTPROTO} =~ /^(dhcp|bootp)$/) {
$netc->{minus_one} = 1;
+ $netc->{DHCP} = 1;
my $dhcp_hostname = $netc->{HOSTNAME};
$::isInstall and $in->set_help('configureNetworkHostDHCP');
$in->ask_from(N("Configuring network"),
@@ -203,7 +204,8 @@ Some DHCP servers require the hostname to work.
Your host name should be a fully-qualified host name,
such as ``mybox.mylab.myco.com''."),
[ { label => N("Host name"), val => \$netc->{HOSTNAME} } ]) or goto configureNetwork_step_1;
- $netc->{HOSTNAME} ne $dhcp_hostname and $netc->{DHCP_HOSTNAME} = $netc->{HOSTNAME};
+ #$netc->{HOSTNAME} ne $dhcp_hostname and $netc->{DHCP_HOSTNAME} = $netc->{HOSTNAME};
+ $intf->{DHCP_HOSTNAME} = $netc->{HOSTNAME};
} else {
configureNetworkNet($in, $netc, $last ||= {}, @l) or goto configureNetwork_step_1;
}
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index e07ef1bfe..d2db378dd 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -67,10 +67,10 @@ sub write_conf {
add2hash($netc, {
NETWORKING => "yes",
FORWARD_IPV4 => "false",
- HOSTNAME => "localhost.$netc->{DOMAINNAME}",
+ if_(!$netc->{DHCP}, HOSTNAME => "localhost.$netc->{DOMAINNAME}"),
});
- setVarsInSh($file, $netc, qw(NETWORKING FORWARD_IPV4 DHCP_HOSTNAME HOSTNAME DOMAINNAME GATEWAY GATEWAYDEV NISDOMAIN));
+ setVarsInSh($file, $netc, if_(!$netc->{DHCP}, HOSTNAME), qw(NETWORKING FORWARD_IPV4 DOMAINNAME GATEWAY GATEWAYDEV NISDOMAIN));
}
sub write_resolv_conf {
@@ -119,7 +119,7 @@ sub write_resolv_conf {
}
sub write_interface_conf {
- my ($file, $intf, $prefix) = @_;
+ my ($file, $intf, $dhcp_hostname, $prefix) = @_;
if ($::o->{miscellaneous}{track_network_id} && -e "$prefix/sbin/ip") {
$intf->{HWADDR} = undef;
@@ -131,12 +131,20 @@ sub write_interface_conf {
}
my @ip = split '\.', $intf->{IPADDR};
my @mask = split '\.', $intf->{NETMASK};
+
+ if ($dhcp_hostname) {
+ $intf->{DHCP_HOSTNAME} = $dhcp_hostname;
+ } else {
+ add2hash($intf, { NEEDHOSTNAME => "yes" });
+ }
+
add2hash($intf, {
BROADCAST => join('.', mapn { int($_[0]) | ((~int($_[1])) & 255) } \@ip, \@mask),
NETWORK => join('.', mapn { int($_[0]) & $_[1] } \@ip, \@mask),
ONBOOT => bool2yesno(!member($intf->{DEVICE}, map { $_->{device} } detect_devices::probeall())),
});
- setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR), if_($intf->{wireless_eth}, qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV)));
+
+ setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR), if_($intf->{wireless_eth}, qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV)), if_($dhcp_hostname, DHCP_HOSTNAME), if_(!$dhcp_hostname, NEEDHOSTNAME));
}
sub add2hosts {
@@ -472,7 +480,7 @@ sub configureNetwork2 {
$netc->{wireless_eth} and $in->do_pkgs->install(qw(wireless-tools));
write_conf("$etc/sysconfig/network", $netc);
write_resolv_conf("$etc/resolv.conf", $netc);
- write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $prefix) foreach grep { $_->{DEVICE} } values %$intf;
+ write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $intf->{DHCP_HOSTNAME}, $prefix) foreach grep { $_->{DEVICE} } values %$intf;
add2hosts("$etc/hosts", "localhost", "127.0.0.1");
add2hosts("$etc/hosts", $netc->{HOSTNAME}, map { $_->{IPADDR} } values %$intf);