From 455a9ed27c9ffdfd2e93df58e97eec12a502a12a Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 29 Dec 2003 18:46:45 +0000 Subject: (wip but requested for string freeze) - do not silently discard errors by ignoring exceptions - use new wizard layer - begin to renew wizard steps (mdk10.0 specs) --- perl-install/network/network.pm | 152 +--------------------------------------- 1 file changed, 1 insertion(+), 151 deletions(-) (limited to 'perl-install/network/network.pm') diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 15109a9f1..abd0cf486 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -16,7 +16,7 @@ use vars qw(@ISA @EXPORT); use log; @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(add2hosts addDefaultRoute configureNetwork2 dns dnsServers down_it findIntf gateway guessHostname is_ip is_ip_forbidden masked_ip netmask read_all_conf read_conf read_interface_conf read_resolv_conf resolv sethostname up_it write_conf write_resolv_conf); #-###################################################################################### #- Functions @@ -313,156 +313,6 @@ sub gateway { join(".", @masked); } -sub configureNetworkIntf { - my ($netc, $in, $intf, $net_device, $skip, $module) = @_; - my $text; - if (is_wireless_intf($module)) { - $intf->{wireless_eth} = 1; - $netc->{wireless_eth} = 1; - $intf->{WIRELESS_MODE} = "Managed"; - $intf->{WIRELESS_ESSID} = "any"; - } - if ($net_device eq $intf->{DEVICE}) { - $skip and return 1; - $text = N("WARNING: this device has been previously configured to connect to the Internet. -Simply accept to keep this device configured. -Modifying the fields below will override this configuration."); - } - else { - $text = N("Please enter the IP configuration for this machine. -Each item should be entered as an IP address in dotted-decimal -notation (for example, 1.2.3.4)."); - } - my $auto_ip = $intf->{BOOTPROTO} !~ /static/; - my $onboot = $intf->{ONBOOT} ? $intf->{ONBOOT} =~ /yes/ : bool2yesno(!member($intf->{DEVICE}, map { $_->{device} } detect_devices::pcmcia_probe())); - my $needhostname = $intf->{NEEDHOSTNAME} !~ /no/; - my $hotplug = $::isStandalone && !$intf->{MII_NOT_SUPPORTED} || 1; - my $track_network_id = $::isStandalone && $intf->{HWADDR} || detect_devices::isLaptop(); - delete $intf->{NETWORK}; - delete $intf->{BROADCAST}; - my @fields = qw(IPADDR NETMASK); - - $in->ask_from(N("Configuring network device %s", $intf->{DEVICE}), - (N("Configuring network device %s", $intf->{DEVICE}) . ($module ? N(" (driver %s)", $module) : '') . "\n\n") . - $text, - [ { label => N("Automatic IP"), val => \$auto_ip, type => "bool", text => N("(bootp/dhcp/zeroconf)") }, - { label => N("IP address"), val => \$intf->{IPADDR}, disabled => sub { $auto_ip } }, - { label => N("Netmask"), val => \$intf->{NETMASK}, disabled => sub { $auto_ip } }, - - { label => N("DHCP host name"), val => \$intf->{DHCP_HOSTNAME}, disabled => sub { ! ($auto_ip && $needhostname) }, advanced => 1 }, - { text => N("Track network card id (useful for laptops)"), val => \$track_network_id, type => "bool", advanced => 1 }, - { text => N("Network Hotplugging"), val => \$hotplug, type => "bool", advanced => 1 }, - { text => N("Assign host name from DHCP address"), val => \$needhostname, type => "bool", disabled => sub { ! $auto_ip }, advanced => 1 }, - { text => N("Start at boot"), val => \$onboot, type => "bool", advanced => 1 }, - if_($intf->{wireless_eth}, - { label => "WIRELESS_MODE", val => \$intf->{WIRELESS_MODE}, list => [ "Ad-hoc", "Managed", "Master", "Repeater", "Secondary", "Auto" ] }, - { label => "WIRELESS_ESSID", val => \$intf->{WIRELESS_ESSID} }, - { label => "WIRELESS_NWID", val => \$intf->{WIRELESS_NWID} }, - { label => "WIRELESS_FREQ", val => \$intf->{WIRELESS_FREQ} }, - { label => "WIRELESS_SENS", val => \$intf->{WIRELESS_SENS} }, - { label => "WIRELESS_RATE", val => \$intf->{WIRELESS_RATE} }, - { label => "WIRELESS_ENC_KEY", val => \$intf->{WIRELESS_ENC_KEY} }, - { label => "WIRELESS_RTS", val => \$intf->{WIRELESS_RTS} }, - { label => "WIRELESS_FRAG", val => \$intf->{WIRELESS_FRAG} }, - { label => "WIRELESS_IWCONFIG", val => \$intf->{WIRELESS_IWCONFIG} }, - { label => "WIRELESS_IWSPY", val => \$intf->{WIRELESS_IWSPY} }, - { label => "WIRELESS_IWPRIV", val => \$intf->{WIRELESS_IWPRIV} } - ), - ], - complete => sub { - - $intf->{BOOTPROTO} = $auto_ip ? join('', if_($auto_ip, "dhcp")) : "static"; - $netc->{DHCP} = $auto_ip; - return 0 if $auto_ip; - - if (my @bad = map_index { if_(!is_ip($intf->{$_}), $::i) } @fields) { - $in->ask_warn('', N("IP address should be in format 1.2.3.4")); - return 1, $bad[0]; - } - - if (is_ip_forbidden($intf->{IPADDR})) { - $in->ask_warn('', N("Warning : IP address %s is usually reserved !", $intf->{IPADDR})); - } - - return 0 if !$intf->{WIRELESS_FREQ}; - if ($intf->{WIRELESS_FREQ} !~ /[0-9.]*[kGM]/) { - $in->ask_warn('', N("Freq should have the suffix k, M or G (for example, \"2.46G\" for 2.46 GHz frequency), or add enough '0' (zeroes).")); - return 1,6; - } - if ($intf->{WIRELESS_RATE} !~ /[0-9.]*[kGM]/) { - $in->ask_warn('', N("Rate should have the suffix k, M or G (for example, \"11M\" for 11M), or add enough '0' (zeroes).")); - return 1,8; - } - }, - focus_out => sub { - $intf->{NETMASK} ||= netmask($intf->{IPADDR}) unless $_[0] - } - ) or return; - $intf->{ONBOOT} = bool2yesno($onboot); - $intf->{NEEDHOSTNAME} = bool2yesno($needhostname); - $intf->{MII_NOT_SUPPORTED} = bool2yesno(!$hotplug); - $intf->{HWADDR} = $track_network_id or delete $intf->{HWADDR}; - 1; -} - -sub configureNetworkNet { - my ($in, $netc, $intf, @devices) = @_; - - $netc->{dnsServer} ||= dns($intf->{IPADDR}); - my $gateway_ex = gateway($intf->{IPADDR}); -#- $netc->{GATEWAY} ||= gateway($intf->{IPADDR}); - - $in->ask_from(N("Configuring network"), -N("Please enter your host name. -Your host name should be a fully-qualified host name, -such as ``mybox.mylab.myco.com''. -You may also enter the IP address of the gateway if you have one.") . N(" - -Enter a Zeroconf host name without any dot if you don't -want to use the default host name."), - [ { label => N("Host name"), val => \$netc->{HOSTNAME} }, - { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME}, disabled => sub { is_dynamic_ip($intf) } }, - { label => N("DNS server"), val => \$netc->{dnsServer} }, - { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} }, - if_(@devices > 1, - { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => \@devices }, - ), - ], - complete => sub { - if ($netc->{dnsServer} && !is_ip($netc->{dnsServer})) { - $in->ask_warn('', N("DNS server address should be in format 1.2.3.4")); - return 1; - } - if ($netc->{GATEWAY} && !is_ip($netc->{GATEWAY})) { - $in->ask_warn('', N("Gateway address should be in format 1.2.3.4")); - return 1; - } - if ($netc->{ZEROCONF_HOSTNAME} && $netc->{ZEROCONF_HOSTNAME} =~ /\./) { - $in->ask_warn('', N("Zeroconf host name must not contain a .")); - return 1; - } - 0; - } - ); -} - -sub miscellaneous_choose { - my ($in, $u) = @_; - - $in->ask_from('', - N("Proxies configuration"), - [ { label => N("HTTP proxy"), val => \$u->{http_proxy} }, - { label => N("FTP proxy"), val => \$u->{ftp_proxy} }, - ], - complete => sub { - $u->{http_proxy} =~ m,^($|http://), or $in->ask_warn('', N("Proxy should be http://...")), return 1,0; - $u->{ftp_proxy} =~ m,^($|ftp://|http://), or $in->ask_warn('', N("URL should begin with 'ftp:' or 'http:'")), return 1,1; - 0; - } - ) or return; - 1; -} - sub proxy_configure { my ($u) = @_; setExportedVarsInSh("$::prefix/etc/profile.d/proxy.sh", $u, qw(http_proxy ftp_proxy)); -- cgit v1.2.1