From d16b0d72c9ea1087f7aa0704739a6e45e9e3d52d Mon Sep 17 00:00:00 2001 From: Damien Chaumette Date: Tue, 7 Jan 2003 14:28:26 +0000 Subject: add network::easy_dhcp function. Quietly setup eth0 in dhcp and restart network. --- perl-install/network/network.pm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'perl-install/network') diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index bce84c86f..92c11c2b8 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -13,7 +13,7 @@ use log; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); -@EXPORT = qw(resolv configureNetworkIntf netmask dns is_ip masked_ip findIntf addDefaultRoute read_all_conf dnsServers guessHostname configureNetworkNet read_resolv_conf read_interface_conf add2hosts gateway configureNetwork2 write_conf sethostname down_it read_conf write_resolv_conf up_it); +@EXPORT = qw(resolv configureNetworkIntf netmask dns is_ip masked_ip findIntf addDefaultRoute read_all_conf dnsServers guessHostname configureNetworkNet read_resolv_conf read_interface_conf add2hosts gateway configureNetwork2 write_conf sethostname down_it read_conf write_resolv_conf up_it, easy_dhcp); #-###################################################################################### #- Functions @@ -415,6 +415,32 @@ sub read_all_conf { } } +sub easy_dhcp { + my ($in) = @_; + my ($netc, $intf); + $netc->{autodetect} = {}; + + require network::netconnect; + network::netconnect::detect($netc->{autodetect}); + + #- only for a single network card + if ($netc->{autodetect}{lan}{eth0} && !$netc->{autodetect}{lan}{eth1}) { + $netc->{NETWORKING} = "yes"; + $netc->{FORWARD_IPV4} = "false"; + $netc->{HOSTNAME} = "localhost.localdomain"; + $netc->{DOMAINNAME} = "localdomain"; + $intf->{eth0}{DEVICE} = "eth0"; + $intf->{eth0}{BOOTPROTO} = "dhcp"; + $intf->{eth0}{ONBOOT} = "yes"; + $intf->{eth0}{NETMASK} = "255.255.255.0"; + + configureNetwork2($in, '', $netc, $intf); + + run_program::rooted('', "/etc/rc.d/init.d/network restart") or return; + } else { return 0 } + 1; +} + #- configureNetwork2 : configure the network interfaces. #- input #- $prefix -- cgit v1.2.1