From ce971f65c6ba5901b3ec57da501b45b78fab256d Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 9 Mar 2005 16:44:43 +0000 Subject: write selected dhcp client in ifcfg files --- perl-install/network/ethernet.pm | 14 +++++++++++++- perl-install/network/netconnect.pm | 6 ++---- perl-install/network/network.pm | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'perl-install/network') diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 3932cb332..d2a32e54e 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -9,7 +9,19 @@ use common; use run_program; use network::tools; -our @dhcp_clients = qw(dhcp-client dhcpcd pump dhcpxd); +our @dhcp_clients = qw(dhclient dhcpcd pump dhcpxd); + +sub install_dhcp_client { + my ($in, $ethntf) = @_; + my %packages = ( + "dhclient" => "dhcp-client", + ); + my $client = $ethntf->{DHCP_CLIENT}; + #- use default dhcp client if none is provided + $client ||= $dhcp_clients[0]; + $client = $packages{$client} if exists $packages{$client}; + $in->do_pkgs->install($client); +} sub write_ether_conf { my ($in, $modules_conf, $netcnx, $netc, $intf) = @_; diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index 19ad857bf..2d45e2998 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -1011,8 +1011,7 @@ Do you really want to reconfigure this device?"), delete $ethntf->{NETWORK}; delete $ethntf->{BROADCAST}; delete $ethntf->{TYPE} if $netcnx->{type} ne 'adsl' || !member($adsl_type, qw(manual dhcp)); - $netc->{dhcp_client} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)) || "dhcp-client"; - $netc->{dhcp_client} = "dhcp-client" if $netc->{dhcp_client} eq "dhclient"; + $ethntf->{DHCP_CLIENT} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)); }, name => sub { join('', N("Configuring network device %s (driver %s)", $ethntf->{DEVICE}, $module), @@ -1037,7 +1036,7 @@ notation (for example, 1.2.3.4).")), { text => N("Start at boot"), val => \$onboot, type => "bool" }, ), if_($auto_ip, - { label => N("DHCP client"), val => \$netc->{dhcp_client}, + { label => N("DHCP client"), val => \$ethntf->{DHCP_CLIENT}, list => \@network::ethernet::dhcp_clients, advanced => 1 }, { label => N("DHCP timeout (in seconds)"), val => \$ethntf->{DHCP_TIMEOUT}, advanced => 1 }, { text => N("Get DNS servers from DHCP"), val => \$peerdns, type => "bool", advanced => 1 }, @@ -1081,7 +1080,6 @@ notation (for example, 1.2.3.4).")), $ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR}; $netc->{$_} = $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE); if ($auto_ip) { - $in->do_pkgs->install($netc->{dhcp_client}); #- delete gateway settings if gateway device is invalid or if reconfiguring the gateway interface to dhcp $delete_gateway_settings->($ntf_name); } diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 1de40d996..4feb2061c 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -164,7 +164,7 @@ sub write_interface_conf { setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR METRIC MII_NOT_SUPPORTED TYPE USERCTL), 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_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_HOSTNAME NEEDHOSTNAME PEERDNS PEERYP PEERNTPD DHCP_TIMEOUT)), + if_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_CLIENT DHCP_HOSTNAME NEEDHOSTNAME PEERDNS PEERYP PEERNTPD DHCP_TIMEOUT)), if_($intf->{DEVICE} =~ /^ippp\d+$/, qw(DIAL_ON_IFUP)) ); substInFile { s/^DEVICE='(`.*`)'/DEVICE=$1/g } $file; #- remove quotes if DEVICE is the result of a command @@ -650,11 +650,11 @@ sub configureNetwork2 { foreach (grep { !/^ppp\d+/ } keys %$intf) { unlink("$etc/sysconfig/network-scripts/$_"); write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_", $intf->{$_}, $netc, $::prefix); + $intf->{$_}{BOOTPROTO} eq "dhcp" and network::ethernet::install_dhcp_client($in, $intf->{$_}); } add2hosts("$etc/hosts", $netc->{HOSTNAME}, "127.0.0.1") if $netc->{HOSTNAME}; add2hosts("$etc/hosts", "localhost", "127.0.0.1"); - any { $_->{BOOTPROTO} eq "dhcp" } values %$intf and $in->do_pkgs->install($netc->{dhcp_client} || 'dhcp-client'); if ($netc->{ZEROCONF_HOSTNAME}) { $in->do_pkgs->ensure_binary_is_installed('tmdns', 'tmdns', 'auto') if !$in->do_pkgs->is_installed('bind'); $in->do_pkgs->ensure_binary_is_installed('zcip', 'zcip', 'auto'); -- cgit v1.2.1