summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-12-29 18:46:45 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-12-29 18:46:45 +0000
commit455a9ed27c9ffdfd2e93df58e97eec12a502a12a (patch)
treeaa3db96e42b0f1897aeb5f480aaad95f7a780a69 /perl-install/network
parent9353e81b58fcf496bc0d75ef1cf380a3e04b13f7 (diff)
downloaddrakx-455a9ed27c9ffdfd2e93df58e97eec12a502a12a.tar
drakx-455a9ed27c9ffdfd2e93df58e97eec12a502a12a.tar.gz
drakx-455a9ed27c9ffdfd2e93df58e97eec12a502a12a.tar.bz2
drakx-455a9ed27c9ffdfd2e93df58e97eec12a502a12a.tar.xz
drakx-455a9ed27c9ffdfd2e93df58e97eec12a502a12a.zip
(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)
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/adsl.pm140
-rw-r--r--perl-install/network/ethernet.pm113
-rw-r--r--perl-install/network/isdn.pm55
-rw-r--r--perl-install/network/modem.pm107
-rw-r--r--perl-install/network/netconnect.pm1070
-rw-r--r--perl-install/network/network.pm152
-rw-r--r--perl-install/network/tools.pm91
7 files changed, 965 insertions, 763 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index 02520011e..fa7099afb 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -11,10 +11,11 @@ use MDK::Common::Globals "network", qw($in $prefix);
@ISA = qw(Exporter);
@EXPORT = qw(adsl_ask_info adsl_detect adsl_conf adsl_conf_backend);
-sub configure {
- my ($netcnx, $netc, $intf, $first_time) = @_;
- conf_adsl_step1:
+sub get_wizard {
+ my ($wiz, $_type) = @_;
+ my $netc = $wiz->{var}{netc};
+
my %l = (
'pppoe' => N("use pppoe"),
'pptp' => N("use pptp"),
@@ -22,57 +23,70 @@ sub configure {
'speedtouch' => N("Alcatel speedtouch usb") . if_($netc->{autodetect}{adsl}{speedtouch}, N(" - detected")),
'sagem' => N("Sagem (using pppoa) usb") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
'sagem_dhcp' => N("Sagem (using dhcp) usb") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
+ # 'eci' => N("ECI Hi-Focus"), # this one needs eci agreement
);
- my $type = $in->ask_from_list(N("Connect to the Internet"),
- N("The most common way to connect with adsl is pppoe.
+ $wiz->{var}{adsl} = {
+ connection_list => \%l,
+ type => "",
+ };
+ add2hash($wiz->{pages},
+ {
+ adsl => {
+ name => N("Connect to the Internet") . "\n\n" .
+ N("The most common way to connect with adsl is pppoe.
Some connections use pptp, a few use dhcp.
If you don't know, choose 'use pppoe'"),
- [ sort values %l ],
- $l{ find { $netc->{autodetect}{adsl}{$_} } keys %l }
- ) or return;
- $type = find { $l{$_} eq $type } keys %l;
- if ($type eq 'pppoe') {
- $in->do_pkgs->install("rp-$type");
- $netcnx->{type} = "adsl_$type";
- adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1;
- } elsif ($type eq 'dhcp') {
- $in->do_pkgs->ensure_is_installed('dhcpcd', '/sbin/dhcpcd', 'auto');
- go_ethernet($netc, $intf, 'dhcp', '', '', $first_time) or goto conf_adsl_step1;
- } elsif ($type eq 'pptp') {
- $in->do_pkgs->ensure_is_installed('pptp-adsl', '/usr/bin/pptp', 'auto');
- $netcnx->{type} = "adsl_$type";
- $netcnx->{"adsl_$type"} = {};
- adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1;
- } elsif ($type =~ /sagem/) {
- $type = 'sagem' . ($type =~ /dhcp/ ? "_dhcp" : "");
- $in->do_pkgs->ensure_is_installed('adiusbadsl', '/usr/sbin/adictrl', 'auto');
- $in->do_pkgs->ensure_is_installed('dhcpcd', '/sbin/dhcpcd', 'auto') if $type =~ /dhcp/;
- $netcnx->{type} = "adsl_$type";
- $netcnx->{"adsl_$type"} = {};
- adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1;
- } elsif ($type =~ /speedtouch/) {
- $type = 'speedtouch';
- $in->do_pkgs->ensure_is_installed('speedtouch', '/usr/sbin/pppoa3', 'auto');
- $netcnx->{type} = "adsl_$type";
- $netcnx->{"adsl_$type"} = {};
- $netcnx->{"adsl_$type"}{vpivci} = '';
- adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1;
- }
- # elsif ($type =~ /ECI/) {
-# $type = 'eci';
-# $in->do_pkgs->install(qw(eciadsl)) if !$::testing;
-# $netcnx->{type} = "adsl_$type";
-# $netcnx->{"adsl_$type"} = {};
-# $netcnx->{"adsl_$type"}{vpivci} = '';
-# adsl_conf($netcnx->{"adsl_$type"}, $netc, $intf, $type) or goto conf_adsl_step1;
-# }
- else {
- die "unknown adsl connection type !!!";
- }
- $type =~ /speedtouch|eci/ or $netconnect::need_restart_network = 1;
- 1;
-}
+ data => [
+ {
+ label => N("ADSL connection type :"), val_ref => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
+ ],
+ pre => sub {
+ $wiz->{var}{adsl}{type} = $l{sagem}; # debug
+ $wiz->{var}{adsl}{type} ||= find { $netc->{autodetect}{adsl}{$_} } keys %l;
+ print "\n\ntype is «$wiz->{var}{adsl}{type}»\n\n";
+ },
+ post => sub {
+ $wiz->{var}{adsl}{type} = find { $l{$_} eq $wiz->{var}{adsl}{type} } keys %l;
+ my $adsl = $wiz->{var}{adsl}{connection};
+ my $type = $wiz->{var}{adsl}{type};
+ my $netcnx = $wiz->{var}{netcnx};
+ $netcnx->{type} = "adsl_$type";
+
+ my %packages = (
+ 'dhcp' => [ 'dhcpcd' ],
+ 'eci' => [ 'eciadsl' ],
+ 'pppoe' => [ 'rp-pppoe' ],
+ 'pptp' => [ 'pptp-adsl' ],
+ 'sagem' => [ 'adiusbadsl' ],
+ 'sagem_dhcp' => [ qw(adiusbadsl dhcpcd) ],
+ 'speedtouch' => [ 'speedtouch' ],
+ );
+ $in->do_pkgs->install(@{$packages{$type}});
+ $netcnx->{"adsl_$type"} = {};
+ $netcnx->{"adsl_$type"}{vpivci} = '' if $type =~ /eci|speedtouch/;
+ return 'ethernet' if $type eq 'dhcp';
+ adsl_probe_info($adsl, $netc, $type);
+ # my ($adsl, $netc, $intf, $adsl_type) = @_;
+ # ask_info2($adsl, $netc);
+ return "hw_account";
+ },
+ },
+ adsl_conf2 => {
+ #$adsl_type =~ /sagem|speedtouch|eci/ or conf_network_card($netc, $intf, 'static', '10.0.0.10') or goto adsl_conf_step_1;
+ #adsl_conf_backend($adsl, $netc, $adsl_type) or goto adsl_conf_step_1;
+ #1;
+ },
+ ethernet => {
+ #go_ethernet($netc, $intf, 'dhcp', '', '', $first_time);
+ },
+ end => {
+ post => sub {
+ $wiz->{var}{adsl}{type} =~ /speedtouch|eci/ or $netconnect::need_restart_network = 1;
+ },
+ },
+ });
+};
sub adsl_probe_info {
my ($adsl, $netc, $adsl_type) = @_;
@@ -91,32 +105,14 @@ sub adsl_probe_info {
add2hash($adsl, { login => $login, passwd => $passwd, passwd2 => '' });
}
-sub adsl_ask_info {
- my ($adsl, $netc, $adsl_type) = @_;
- adsl_probe_info($adsl, $netc, $adsl_type);
- ask_info2($adsl, $netc);
-}
-
-sub adsl_detect() {
- my ($adsl) = {};
+sub adsl_detect {
+ my ($adsl) = @_;
require detect_devices;
$adsl->{speedtouch} = detect_devices::getSpeedtouch();
$adsl->{sagem} = detect_devices::getSagem();
return $adsl if $adsl->{speedtouch} || $adsl->{sagem};
}
-sub adsl_conf {
- my ($adsl, $netc, $intf, $adsl_type) = @_;
- $adsl ||= {};
-
- adsl_conf_step_1:
- adsl_ask_info($adsl, $netc, $adsl_type) or return;
- adsl_conf_step_2:
- $adsl_type =~ /sagem|speedtouch|eci/ or conf_network_card($netc, $intf, 'static', '10.0.0.10') or goto adsl_conf_step_1;
- adsl_conf_backend($adsl, $netc, $adsl_type) or goto adsl_conf_step_1;
- 1;
-}
-
sub adsl_conf_backend {
my ($adsl, $netc, $adsl_type, $o_netcnx) = @_;
defined $o_netcnx and $netc->{adsltype} = $o_netcnx->{type};
@@ -221,8 +217,8 @@ You can provide it now via a floppy or your windows partition,
or skip and do it later."), $l) or return;
my $destination = "$prefix/usr/share/speedtouch/";
- $answer eq 'Use a floppy' and network::tools::copy_firmware('floppy', $destination, 'mgmt.o') || goto firmware;
- $answer eq 'Use my Windows partition' and network::tools::copy_firmware('windows', $destination, 'alcaudsl.sys') || goto firmware;
+ $answer eq 'Use a floppy' && network::tools::copy_firmware('floppy', $destination, 'mgmt.o') || goto firmware;
+ $answer eq 'Use my Windows partition' && network::tools::copy_firmware('windows', $destination, 'alcaudsl.sys') || goto firmware;
$answer eq 'Do it later' and $in->ask_warn('', N("You need the Alcatel microcode.
Download it at:
%s
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 8b97ecb54..f67033862 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -13,34 +13,14 @@ use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix);
@ISA = qw(Exporter);
-@EXPORT = qw(configureNetwork conf_network_card conf_network_card_backend go_ethernet);
+@EXPORT = qw(conf_network_card conf_network_card_backend go_ethernet);
-sub configure_cable {
- my ($netcnx, $netc, $intf, $first_time) = @_;
-
- $netcnx->{type} = 'cable';
-
- $in->ask_from(N("Connect to the Internet"),
- N("Which dhcp client do you want to use ? (default is dhcp-client)"),
- [ { val => \$netcnx->{dhcp_client}, list => ["dhcp-client", "dhcpcd", "dhcpxd"] } ],
- ) or return;
-
- $in->do_pkgs->install($netcnx->{dhcp_client});
-
- go_ethernet($netc, $intf, 'dhcp', '', '', $first_time);
- write_cnx_script($netc, "cable",
-qq(
-/sbin/ifup $netc->{NET_DEVICE}
-),
-qq(
-/sbin/ifdown $netc->{NET_DEVICE}
-), $netcnx->{type});
- 1;
-}
+my (@cards, @ether_steps, $last, %last);
-sub configure_lan {
- my ($netcnx, $netc, $intf, $first_time) = @_;
- configureNetwork($netc, $intf, $first_time) or return;
+
+sub ether_conf{
+ # my ($netcnx, $netc, $intf, $first_time) = @_;
+ my ($in, $prefix, $netc, $intf) = @_;
configureNetwork2($in, $prefix, $netc, $intf);
$netc->{NETWORKING} = "yes";
if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) {
@@ -60,28 +40,6 @@ qq(
1;
}
-sub conf_network_card {
- my ($netc, $intf, $type, $ipadr, $o_netadr) = @_;
- #-type =static or dhcp
- modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1);
- my @all_cards = conf_network_card_backend($netc, $intf, $type, undef, $ipadr, $o_netadr) or
- $in->ask_warn('', N("No ethernet network adapter has been detected on your system.
-I cannot set up this connection type.")), return;
-
- my $interface = $in->ask_from_listf(N("Choose the network interface"),
- N("Please choose which network adapter you want to use to connect to Internet."),
- sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") },
- \@all_cards) or return;
-
- modules::write_conf($prefix) if $::isStandalone;
-
- my $_device = conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $o_netadr);
-# if ( $::isStandalone and !($type eq "dhcp")) {
-# $in->ask_yesorno(N("Network interface"),
-# N("I'm about to restart the network device:\n") . $device . N("\nDo you agree?"), 1) and configureNetwork2($in, $prefix, $netc, $intf) and system("$prefix/sbin/ifdown $device;$prefix/sbin/ifup $device");
-# }
- 1;
-}
#- conf_network_card_backend : configure the network cards and return the list of them, or configure one specified interface : WARNING, you have to setup the ethernet cards, by calling load_category($in, 'network/main|gigabit|usb', !$::expert, 1) or load_category_backend before calling this function. Basically, you call this function in 2 times.
#- input
@@ -132,65 +90,6 @@ sub conf_network_card_backend {
$o_interface;
}
-sub go_ethernet {
- my ($netc, $intf, $type, $ipadr, $netadr, $first_time) = @_;
- conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return;
- $netc->{NET_INTERFACE} = $netc->{NET_DEVICE};
- configureNetwork($netc, $intf, $first_time) or return;
- 1;
-}
-
-sub configureNetwork {
- my ($netc, $intf, $_first_time) = @_;
- local $_;
- modules::interactive::load_category($in, 'network/main|gigabit|usb|pcmcia', !$::expert, 1) or return;
- my @all_cards = conf_network_card_backend($netc, $intf);
- my @l = map { $_->[0] } @all_cards;
-
- foreach (@all_cards) {
- modules::remove_alias($_->[1]);
- modules::add_alias($_->[0], $_->[1]);
- }
-
- configureNetwork_step_1:
- $netc ||= {};
- my ($last, %last);
- foreach (@all_cards) {
- my $intf2 = findIntf($intf ||= {}, $_->[0]);
- add2hash($intf2, $last{$_->[0]});
- add2hash($intf2, { NETMASK => '255.255.255.0' });
- configureNetworkIntf($netc, $in, $intf2, $netc->{NET_DEVICE}, 0, $_->[1]) or return;
-
- $last = $last{$_->[0]} = $intf2;
- }
- $last or return;
-
- configureNetwork_step_2:
- if (is_dynamic_ip($intf)) {
- $netc->{minus_one} = 1;
-
- $in->ask_from(N("Configuring network"), N("
-
-Enter a Zeroconf host name without any dot if you don't
-want to use the default host name."),
- [ { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} },
- { label => N("Host name"), val => \$netc->{HOSTNAME}, advanced => 1 }
- ],
- complete => sub {
- if ($netc->{ZEROCONF_HOSTNAME} =~ /\./) {
- $in->ask_warn('', N("Zeroconf host name must not contain a ."));
- return 1;
- }
- 0;
- }
- ) or goto configureNetwork_step_1;
- } else {
- configureNetworkNet($in, $netc, $intf, @l) or goto configureNetwork_step_1;
- }
- network::network::miscellaneous_choose($in, $::o->{miscellaneous} ||= {}) or goto configureNetwork_step_2;
- 1;
-}
-
# automatic net aliases configuration
sub configure_eth_aliases() {
foreach (detect_devices::getNet()) {
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index d0e083fef..b66edfe75 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -16,36 +16,6 @@ use MDK::Common::File;
@ISA = qw(Exporter);
@EXPORT = qw(isdn_write_config isdn_write_config_backend get_info_providers_backend isdn_ask_info isdn_ask_protocol isdn_ask isdn_detect isdn_detect_backend isdn_get_list isdn_get_info);
-sub configure {
- my ($netcnx, $netc) = @_;
- configure_device($netcnx, $netc, $_) foreach values %{$netc->{autodetect}{isdn}};
-}
-
-sub configure_device {
- my ($netcnx, $netc, $isdn) = @_;
- isdn_step_1:
- defined $isdn->{id} and goto intern_pci;
-
- my $e = $in->ask_from_list_(N("Network Configuration Wizard"),
- N("What kind is your ISDN connection?"), [ N_("Internal ISDN card"), N_("External ISDN modem") ]
- ) or return;
-
- if ($e =~ /card/) {
- intern_pci:
- $netc->{isdntype} = 'isdn_internal';
- $netcnx->{isdn_internal} = $isdn;
- $netcnx->{isdn_internal} = isdn_read_config($netcnx->{isdn_internal});
- isdn_detect($netcnx->{isdn_internal}, $netc) or goto isdn_step_1;
- } else {
- $netc->{isdntype} = 'isdn_external';
- $netcnx->{isdn_external}{device} = $netc->{autodetect}{modem};
- $netcnx->{isdn_external} = isdn_read_config($netcnx->{isdn_external});
- $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40';
- require network::modem;
- network::modem::ppp_choose($in, $netc, $netcnx->{isdn_external}) or goto isdn_step_1;
- }
- 1;
-}
sub isdn_write_config {
my ($isdn, $netc) = @_;
@@ -224,31 +194,6 @@ If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
1;
}
-sub isdn_detect {
- my ($isdn, $netc) = @_;
- if ($isdn->{id}) {
- log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
- $isdn->{description} =~ s/\|/ -- /;
-
- isdn_detect_step_0:
- defined $isdn->{type} and my $new = $in->ask_yesorno(N("ISDN Configuration"), N("Do you want to start a new configuration ?"), 1);
-
- if ($isdn->{type} eq '' || $new) {
- isdn_ask($isdn, $netc, N("I have detected an ISDN PCI card, but I don't know its type. Please select a PCI card on the next screen.")) or goto isdn_detect_step_0;
- } else {
- isdn_detect_step_1:
- $isdn->{protocol} = isdn_ask_protocol() or goto isdn_detect_step_0;
- isdn_detect_step_2:
- isdn_ask_info($isdn, $netc) or goto isdn_detect_step_1;
- isdn_write_config($isdn, $netc) or goto isdn_detect_step_2;
- }
- } else {
- isdn_ask($isdn, $netc, N("No ISDN PCI card found. Please select one on the next screen.")) or return;
- }
- $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- 1;
-}
-
sub isdn_detect_backend() {
my $isdn = { };
each_index {
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index 159b61698..f1ef4d9f7 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -8,50 +8,12 @@ use detect_devices;
use mouse;
use network::tools;
-sub configure {
- my ($in, $netcnx, $mouse, $netc) = @_;
- $netcnx->{type} = 'modem';
- my $modem = $netcnx->{$netcnx->{type}};
- $modem->{device} = $netc->{autodetect}{modem};
- my %l = getVarsFromSh("$::prefix/usr/share/config/kppprc");
- $modem->{connection} = $l{Name};
- $modem->{domain} = $l{Domain};
- ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
- foreach (cat_("/etc/sysconfig/network-scripts/chat-ppp0")) {
- /.*ATDT(\d*)/ and $modem->{phone} = $1;
- }
- foreach (cat_("/etc/sysconfig/network-scripts/ifcfg-ppp0")) {
- /NAME=(['"]?)(.*)\1/ and $modem->{login} = $2;
- }
- my $secret = network::tools::read_secret_backend();
- foreach (@$secret) {
- $modem->{passwd} = $_->{passwd} if $_->{login} eq $modem->{login};
- }
-
- ppp_choose($in, $netc, $modem, $mouse) or return;
- write_cnx_script($netc, "modem",
- q(
-/sbin/route del default
-ifup ppp0
-),
- q(ifdown ppp0
-killall pppd
-), $netcnx->{type});
- 1;
-}
-
-#-----modem conf
-sub ppp_configure {
- my ($in, $modem) = @_;
- $modem or return;
+sub ppp_configure_raw {
+ my ($in, $netc, $modem) = @_;
+ $netc->{DOMAINNAME2} = $modem->{domain};
$in->do_pkgs->install('ppp') if !$::testing;
$in->do_pkgs->install('kdenetwork-kppp') if $in->do_pkgs->is_installed('kdebase');
- ppp_configure_raw($modem);
-}
-
-sub ppp_configure_raw {
- my ($modem) = @_;
any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
my %toreplace;
@@ -211,67 +173,4 @@ END
network::network::proxy_configure($::o->{miscellaneous});
}
-sub ppp_choose {
- my ($in, $netc, $modem, $o_mouse) = @_;
- $o_mouse ||= {};
-
- $o_mouse->{device} ||= readlink "$::prefix/dev/mouse";
- my $need_to_ask = $modem->{device} || !$netc->{autodetect}{winmodem};
- step_1:
- $need_to_ask and $modem->{device} = $in->ask_from_listf_raw({ messsages => N("Please choose which serial port your modem is connected to."),
- interactive_help_id => 'selectSerialPort',
- },
- \&mouse::serial_port2text,
- [ grep { $_ ne $o_mouse->{device} } (if_(-e '/dev/modem', '/dev/modem'), mouse::serial_ports()) ]) || return;
-
- #my $secret = network::tools::read_secret_backend();
- #my @cnx_list = map { $_->{server} } @$secret;
- $in->ask_from('', N("Dialup options"), [
- { label => N("Connection name"), val => \$modem->{connection} },
- { label => N("Phone number"), val => \$modem->{phone} },
- { label => N("Login ID"), val => \$modem->{login} },
- { label => N("Password"), val => \$modem->{passwd}, hidden => 1 },
- { label => N("Authentication"), val => \$modem->{auth}, list => [ N_("PAP"), N_("Terminal-based"), N_("Script-based"), N_("CHAP") ] },
- { label => N("Domain name"), val => \$modem->{domain} },
- { label => N("First DNS Server (optional)"), val => \$modem->{dns1} },
- { label => N("Second DNS Server (optional)"), val => \$modem->{dns2} },
- ]) or do { if ($need_to_ask) { goto step_1 } else { return } };
- $netc->{DOMAINNAME2} = $modem->{domain};
- ppp_configure($in, $modem);
- $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- 1;
-}
-
-sub winmodemConfigure {
- my ($in, $netcnx, $mouse, $netc) = @_;
- my %relocations = (ltmodem => $in->do_pkgs->check_kernel_module_packages('ltmodem'));
- my $type;
-
- $netc->{autodetect}{winmodem} or ($in->ask_warn(N("Warning"), N("You don't have any winmodem")) ? return 1 : $in->exit(0));
-
- foreach (keys %{$netc->{autodetect}{winmodem}}) {
- /Hcf/ and $type = "hcfpcimodem";
- /Hsf/ and $type = "hsflinmodem";
- /LT/ and $type = "ltmodem";
- $relocations{$type} || $type && $in->do_pkgs->what_provides($type) or $type = undef;
- }
-
- $type or ($in->ask_warn(N("Warning"), N("Your modem isn't supported by the system.
-Take a look at http://www.linmodems.org")) ? return 1 : $in->exit(0));
- my $e = $in->ask_from_list(N("Title"), N("\"%s\" based winmodem detected, do you want to install needed software ?", $type), [N("Install rpm"), N("Do nothing")]) or return 0;
- if ($e =~ /rpm/) {
- if ($in->do_pkgs->install($relocations{$type} ? @{$relocations{$type}} : $type)) {
- unless ($::isInstall) {
- #- fallback to modem configuration (beware to never allow test it).
- $netcnx->{type} = 'modem';
- #$type eq 'ltmodem' and $netc->{autodetect}{modem} = '/dev/ttyS14';
- return configure($in, $netcnx, $mouse, $netc);
- }
- } else {
- return 0;
- }
- }
- return 1;
-}
-
1;
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index 2e8f1eec3..cd4829d08 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -15,20 +15,29 @@ use MDK::Common::Globals "network", qw($in $prefix $connect_file $disconnect_fil
my %conf;
sub detect {
- my ($auto_detect) = @_;
- require network::isdn;
- $auto_detect->{isdn} = network::isdn::isdn_detect_backend();
-
- modules::load_category('network/main|gigabit|usb');
- require network::ethernet;
- $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::conf_network_card_backend() };
-
- require network::adsl;
- $auto_detect->{adsl} = network::adsl::adsl_detect();
-
- my ($modem, @pci_modems) = detect_devices::getModem();
- $modem->{device} and $auto_detect->{modem} = $modem->{device};
- @pci_modems and $auto_detect->{winmodem}{$_->{driver}} = $_->{description} foreach @pci_modems;
+ my ($auto_detect, $o_class) = @_;
+ my %l = (
+ isdn => sub {
+ require network::isdn;
+ $auto_detect->{isdn} = network::isdn::isdn_detect_backend();
+ },
+ lan => sub { # ethernet
+ modules::load_category('network/main|gigabit|usb');
+ require network::ethernet;
+ $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::conf_network_card_backend() };
+ },
+ adsl => sub {
+ require network::adsl;
+ $auto_detect->{adsl} = network::adsl::adsl_detect();
+ },
+ modem => sub {
+ my ($modem, @pci_modems) = detect_devices::getModem();
+ $modem->{device} and $auto_detect->{modem} = $modem->{device};
+ @pci_modems and $auto_detect->{winmodem}{$_->{driver}} = $_->{description} foreach @pci_modems;
+ },
+ );
+ $l{$_}->() foreach ($o_class || (keys %l));
+ return;
}
sub init_globals {
@@ -41,203 +50,891 @@ sub init_globals {
connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg");
}
-sub main {
- my ($prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
- my $netc = $o_netc || {};
- my $mouse = $o_mouse || {};
- my $intf = $o_intf || {};
- my $first_time = $o_first_time || 0;
-
- init_globals($in, $prefix);
- $netc->{minus_one} = 0; #When one configure an eth in dhcp without gateway
- $::isStandalone and read_net_conf($prefix, $netcnx, $netc);
- $netc->{NET_DEVICE} = $netcnx->{NET_DEVICE} if $netcnx->{NET_DEVICE}; # REDONDANCE with read_conf. FIXME
- $netc->{NET_INTERFACE} = $netcnx->{NET_INTERFACE} if $netcnx->{NET_INTERFACE}; # REDONDANCE with read_conf. FIXME
- network::network::read_all_conf($prefix, $netc, $intf);
+sub detect_timezone() {
+ my %tmz2country = (
+ 'Europe/Paris' => N("France"),
+ 'Europe/Amsterdam' => N("Netherlands"),
+ 'Europe/Rome' => N("Italy"),
+ 'Europe/Brussels' => N("Belgium"),
+ 'America/New_York' => N("United States"),
+ 'Europe/London' => N("United Kingdom")
+ );
+ my %tm_parse = MDK::Common::System::getVarsFromSh('/etc/sysconfig/clock');
+ my @country;
+ foreach (keys %tmz2country) {
+ if ($_ eq $tm_parse{ZONE}) {
+ unshift @country, $tmz2country{$_};
+ } else { push @country, $tmz2country{$_} };
+ }
+ \@country;
+}
- modules::mergein_conf("$prefix/etc/modules.conf");
- my $direct_net_install;
- if ($first_time && $::isInstall && ($in->{method} eq "ftp" || $in->{method} eq "http" || $in->{method} eq "nfs")) {
- !$::expert && !$o_noauto || $in->ask_okcancel(N("Network Configuration"),
- N("Because you are doing a network installation, your network is already configured.
-Click on Ok to keep your configuration, or cancel to reconfigure your Internet & Network connection.
-"), 1) and do {
- $netcnx->{type} = 'lan';
- output_with_perm("$prefix$connect_file", 0755,
- qq(
-ifup eth0
-));
- output("$prefix$disconnect_file", 0755,
- qq(
-ifdown eth0
-));
- $direct_net_install = 1;
- goto step_5;
-};
- }
+# configuring all network devices
+ sub main {
+ my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
+ my $netc = $o_netc || {};
+ my $mouse = $o_mouse || {};
+ my $intf = $o_intf || {};
+ my $first_time = $o_first_time || 0;
+ my ($network_configured, $direct_net_install, $cnx_type, $type, $interface, @cards, @all_cards, @devices);
+ my (%connection_steps, %connections, %rconnections, @connection_list);
+ my ($ntf_name, $ipadr, $netadr, $gateway_ex, $up, $modem, $isdn, $isdn_type, $adsl_type, $need_restart_network);
+ my ($module, $text, $auto_ip, $net_device, $onboot, $needhostname, $hotplug, $track_network_id, @fields); # lan config
+ my $success = 1;
+ my $ethntf = {};
+ use Data::Dumper;
+
+ my %yesno = (yes => N("Yes"), no => N("No"));
+
+ my %wireless_mode = (N("Ad-hoc") => "Ad-hoc",
+ N("Managed") => "Managed",
+ N("Master") => "Master",
+ N("Repeater") => "Repeater",
+ N("Secondary") => "Secondary",
+ N("Auto") => "Auto",
+ );
+
+
+ init_globals($in, $::prefix);
+ $netc->{NET_DEVICE} = $netcnx->{NET_DEVICE} if $netcnx->{NET_DEVICE}; # REDONDANCE with read_conf. FIXME
+ $netc->{NET_INTERFACE} = $netcnx->{NET_INTERFACE} if $netcnx->{NET_INTERFACE}; # REDONDANCE with read_conf. FIXME
+ network::network::read_all_conf($::prefix, $netc, $intf);
- $netc->{autodetection} = 1;
- $netc->{autodetect} = {};
+ modules::mergein_conf("$::prefix/etc/modules.conf");
- step_1:
- $::Wizard_no_previous = 1;
- my @profiles = get_profiles();
- eval { $in->ask_from_({ title => N("Network Configuration Wizard"),
- messages => N("Welcome to The Network Configuration Wizard.
+ $netc->{autodetection} = 0;
+ $netc->{autodetect} = {};
+
+ my $next_cnx_step = sub {
+ my $next = connection_steps{$cnx_type};
+ # FIXME: we want this in standalone mode too:
+ $need_restart_network = 1 if $next =~ /lan|cable/;
+ if ($next eq "multiple_internet_cnx") {
+ return 1 < scalar(keys %{$netc->{internet_cnx}}) ? "multiple_internet_cnx" : $connection_steps{multiple_internet_cnx};
+ }
+ return $next;
+ };
+
+ my $ppp_first_step = sub {
+ $mouse ||= {};
+ $mouse->{device} ||= readlink "$::prefix/dev/mouse";
+ write_cnx_script($netc, "modem", join("\n", if_($::testing, "/sbin/route del default"), "ifup ppp0"),
+ q(ifdown ppp0
+killall pppd
+), $netcnx->{type});
+ my $need_to_ask = $modem->{device} || !$netc->{autodetect}{winmodem};
+ return $need_to_ask ? "ppp_choose" : "ppp_choose2";
+ };
+
+ # main wizard:
+ my $wiz;
+ $wiz =
+ {
+ defaultimage => "wiz_drakconnect.png",
+ name => N("Network & Internet Configuration"),
+ pages => {
+ install =>
+ {
+ if_($::isInstall, no_back => 1),
+ name => N("Welcome to The Network Configuration Wizard.
We are about to configure your internet/network connection.
If you don't want to use the auto detection, deselect the checkbox.
"),
- interactive_help_id => 'configureNetwork',
- },
- [
- if_(@profiles > 1, { label => N("Choose the profile to configure"), val => \$netcnx->{PROFILE}, list => \@profiles }),
- { text => N("Use auto detection"), val => \$netc->{autodetection}, type => 'bool' },
- { text => N("Expert Mode"), val => \$::expert, type => 'bool' },
- ]
- ) or goto step_5 }; $in->exit(0) if $@ =~ /wizcancel/;
- undef $::Wizard_no_previous;
- set_profile($netcnx);
- if ($netc->{autodetection}) {
- my $_w = $in->wait_message(N("Network Configuration Wizard"), N("Detecting devices..."));
- detect($netc->{autodetect});
- }
+ interactive_help_id => 'configureNetwork',
+ data => [
+ { text => N("Use auto detection"), val => \$netc->{autodetection}, type => 'bool' },
+ { text => N("Expert Mode"), val => \$::expert, type => 'bool' },
+ ],
+ post => sub {
+ if ($netc->{autodetection}) {
+ my $_w = $in->wait_message(N("Network Configuration Wizard"), N("Detecting devices..."));
+ detect($netc->{autodetect});
+ }
+
+ $conf{$_} = values %{$netc->{autodetect}{$_}} ? 1 : 0 foreach 'lan';
+ $conf{$_} = $netc->{autodetect}{$_} ? 1 : 0 foreach qw(adsl cable modem winmodem);
+ $conf{isdn} = any { $_->{driver} } values %{$netc->{autodetect}{isdn}};
+ return "connection";
+ },
+ },
- my %net_conf_callbacks = (adsl => sub { require network::adsl; network::adsl::configure($netcnx, $netc, $intf, $first_time) },
- cable => sub { require network::ethernet; network::ethernet::configure_cable($netcnx, $netc, $intf, $first_time) },
- isdn => sub { require network::isdn; network::isdn::configure($netcnx, $netc) },
- lan => sub { require network::ethernet; network::ethernet::configure_lan($netcnx, $netc, $intf, $first_time) },
- modem => sub { require network::modem; network::modem::configure($in, $netcnx, $mouse, $netc) },
- winmodem => sub { require network::modem; network::modem::winmodemConfigure($in, $netcnx, $mouse, $netc) },
- );
-
-
- $conf{$_} = values %{$netc->{autodetect}{$_}} ? 1 : 0 foreach 'lan';
- $conf{$_} = $netc->{autodetect}{$_} ? 1 : 0 foreach qw(adsl cable modem winmodem);
- $conf{isdn} = any { $_->{driver} } values %{$netc->{autodetect}{isdn}};
- step_2:
-
- my @l = (
- [ join('', N("Normal modem connection"), if_($conf{modem}, " - " . N("detected on port %s", $netc->{autodetect}{modem}))), \$conf{modem} ],
- [ join('', N("Winmodem connection"), if_($conf{winmodem}, " - " . N("detected"))), \$conf{winmodem} ],
- [ join('', N("ISDN connection"), if_($conf{isdn}, " - " . N("detected %s", join(', ', map { $_->{description} } values %{$netc->{autodetect}{isdn}})))), \$conf{isdn} ],
- [ join('', N("ADSL connection"), if_($conf{adsl}, " - " . N("detected"))), \$conf{adsl} ],
- [ join('', N("Cable connection"), if_($conf{cable}, " - " . N("cable connection detected"))), \$conf{cable} ],
- [ join('', N("LAN connection"), if_($conf{lan}, " - " . N("ethernet card(s) detected"))), \$conf{lan} ]
- );
- eval { $in->ask_from_({ title => N("Network Configuration Wizard"),
- messages => N("Choose the connection you want to configure"),
- interactive_help_id => 'configureNetwork',
- },
- [ map { { text => $_->[0], val => $_->[1], type => 'bool' } } @l ],
- changed => sub {
- return if !$netc->{autodetection};
- my $c = 0;
- #- $conf{adsl} and $c++;
- $conf{cable} and $c++;
- my $a = keys(%{$netc->{autodetect}{lan}});
- 0 < $a && $a <= $c and $conf{lan} = undef;
- }
- ) or goto step_1;
- load_conf($netcnx, $netc, $intf);
- foreach my $type (keys %net_conf_callbacks) {
- $conf{$type} and do {
- #-PO here, "forward" is the standard gtk+ button for "next"; check what is displayed in your language
- $in->ask_okcancel(N("Network Configuration Wizard"), N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.", translate($type), N("Next")), 1) or goto step_2;
- &{$net_conf_callbacks{$type}} or goto step_2;
- $netconnect::need_restart_network = 1 if $type =~ /lan|cable/;
- }
- }
- };
- if (my $err = $@) {
- $err =~ /wizcancel/ ? $in->exit(0) : die $err;
- }
-
- step_2_1:
- my $nb = keys %{$netc->{internet_cnx}};
-
- if ($nb > 1) {
- # BUG: remember to remove reference to profiles in mcc if we do not restore this feature
- eval { $in->ask_from(N("Network Configuration Wizard"),
- N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n") . if_(!$::isStandalone, "You may want to configure some profiles after the installation, in the Mandrake Control Center"),
- [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice}, list => [ keys %{$netc->{internet_cnx}} ] } ]
- ) or goto step_2 }; $in->exit(0) if $@ =~ /wizcancel/;
- } elsif ($nb == 1) {
- $netc->{internet_cnx_choice} = (keys %{$netc->{internet_cnx}})[0];
- }
-
- eval { $in->ask_yesorno(N("Network configuration"), N("Configuration is complete, do you want to apply settings ?"), 1) or goto step_2_2 } if !$::isInstall;
- $in->exit(0) if $@ =~ /wizcancel/;
-
- member($netc->{internet_cnx_choice}, ('adsl', 'isdn')) and $netc->{at_boot} = $in->ask_yesorno(N("Network Configuration Wizard"), N("Do you want to start the connection at boot?"));
+ connection =>
+ {
+ pre => sub {
+ if (!$::isInstall) {
+ $conf{$_} = 0 foreach qw(adsl cable isdn lan modem winmodem);
+ }
+ my @connections =
+ (
+ #-PO: here, "(detected)" string will be appended to eg "ADSL connection"
+ [ N("Normal modem connection"), N("(detected on port %s)", $netc->{autodetect}{modem}), "modem" ],
+ [ N("Winmodem connection"), N("(detected)"), "winmodem" ],
+ [ N("ISDN connection"), N("(detected %s)", join(', ', map { $_->{description} } values %{$netc->{autodetect}{isdn}})), "isdn" ],
+ [ N("ADSL connection"), N("(detected)"), "adsl" ],
+ [ N("Cable connection"), N("(detected)"), "cable" ],
+ [ N("LAN connection"), N("(detected)"), "lan" ],
+ # if we ever want to split out wireless connection, we'd to split out modules between network/main and network/wlan:
+ if_(0, [ N("Wireless connection"), N("(detected)"), "lan" ]),
+ );
+
+ foreach (@connections) {
+ my ($str, $extra_str, $type) = @$_;
+ my $string = join('', $str, if_($conf{$type}, " - ", $extra_str));
+ $connections{$string} = $type;
+ }
+ %rconnections = reverse %connections;
+ if ($::isInstall) {
+ @connection_list = map {
+ my (undef, undef, $type) = @$_;
+ +{ text => $rconnections{$type}, val => \$conf{$type}, type => 'bool' }
+ } @connections;
+ } else {
+ @connection_list = ({ val => \$type, type => 'list', list => [ map { $_->[0] } @connections ], });
+ }
+ },
+ if_(!$::isInstall, no_back => 1),
+ name => N("Choose the connection you want to configure"),
+ interactive_help_id => 'configureNetwork',
+ data => \@connection_list,
+ changed => sub {
+ return if !$netc->{autodetection};
+ my $c = 0;
+ #- $conf{adsl} and $c++;
+ $conf{cable} and $c++;
+ my $a = keys(%{$netc->{autodetect}{lan}});
+ 0 < $a && $a <= $c and $conf{lan} = undef;
+ },
+ complete => sub {
+ # at least one connection type must be choosen
+ return 0 if !$::isInstall;
+ return !any { $conf{$_} } keys %conf;
+ },
+ post => sub {
+ load_conf($netcnx, $netc, $intf) if $::isInstall; # :-(
+ # while in installer, we need to link connections steps depending of which connections the user selected
+ my @l;
+ if ($::isInstall) {
+ @l = grep { $conf{$_} } keys %conf;
+ } else {
+ $type = $connections{$type};
+ @l = ($type);
+ }
+ my $first = shift @l;
+ my @steps = (@l,
+ "multiple_internet_cnx",
+ ($::isInstall ? "miscellaneous_choose" : "apply_settings"));
+ foreach my $cnx ($first, @l) {
+ $connection_steps{$cnx} = shift @steps;
+ }
+ # FIXME: s/$type/"${type}_standalone"/ (because of newer steps for standalone mode just break all but lan paths:
+ return $::isInstall ? "prepare_detection" : "${type}_standalone";
+ },
+ },
- if ($netc->{internet_cnx_choice}) {
- write_cnx_script($netc);
- $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
- } else {
- unlink "$prefix/etc/sysconfig/network-scripts/net_cnx_up";
- unlink "$prefix/etc/sysconfig/network-scripts/net_cnx_down";
- undef $netc->{NET_DEVICE};
- }
+ prepare_detection =>
+ {
+ name => N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.",
+ translate($type), N("Next")),
+ post => $next_cnx_step,
+ },
- my $success = 1;
- network::network::configureNetwork2($in, $prefix, $netc, $intf);
- my $network_configured = 1;
-
- step_2_2:
- eval { if ($netconnect::need_restart_network && $::isStandalone && (!$::expert || $in->ask_yesorno(N("Network configuration"),
- N("The network needs to be restarted. Do you want to restart it ?"), 1))) {
- if (!$::testing && !run_program::rooted($prefix, "/etc/rc.d/init.d/network restart")) {
- $success = 0;
- $in->ask_okcancel(N("Network Configuration"),
- N("A problem occured while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
- }
- }
- }; $in->exit(0) if $@ =~ /wizcancel/;
+
+ hw_account =>
+ { # ask_info2
+ #my ($cnx, $netc) = @_;
+
+ name => N("Connection Configuration") . "\n\n" .
+ N("Please fill or check the field below"),
+ data => [],
+ pre => sub {
+ push @{$wiz->{pages}{hw_account}{data}}, map {
+ my ($dstruct, $field, $item) = @$_;
+ $item->{val} = \$wiz->{var}{$dstruct}{$field};
+ if__($wiz->{var}{$dstruct}{$field}, $item);
+ } ([ "cnx", "irq", { label => N("Card IRQ") } ],
+ [ "cnx", "mem", { label => N("Card mem (DMA)") } ],
+ [ "cnx", "io", { label => N("Card IO") } ],
+ [ "cnx", "io0", { label => N("Card IO_0") } ],
+ [ "cnx", "io1", { label => N("Card IO_1") } ],
+ [ "cnx", "phone_in", { label => N("Your personal phone number") } ],
+ [ "netc", "DOMAINNAME2", { label => N("Provider name (ex provider.net)") } ],
+ [ "cnx", "phone_out", { label => N("Provider phone number") } ],
+ [ "netc", "dnsServer2", { label => N("Provider dns 1 (optional)") } ],
+ [ "netc", "dnsServer3", { label => N("Provider dns 2 (optional)") } ],
+ [ "cnx", "vpivci", { label => N("Choose your country"), list => detect_timezone() } ],
+ [ "cnx", "dialing_mode", { label => N("Dialing mode"), list => ["auto", "manual"] } ],
+ [ "cnx", "speed", { label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"] } ],
+ [ "cnx", "huptimeout", { label => N("Connection timeout (in sec)") } ],
+ );
+ push @{$wiz->{pages}{hw_account}{data}},
+ ({ label => N("Account Login (user name)"), val => \$wiz->{var}{cnx}{login} },
+ {
+ label => N("Account Password"), val => \$wiz->{var}{cnx}{passwd}, hidden => 1 },
+ );
+ }
+ },
+ post => sub {
+ my $netc = $wiz->{var}{netc};
+ if ($netc->{vpivci}) {
+ my %h = (N("Belgium") => '8_35' ,
+ N("France") => '8_35' ,
+ N("Italy") => '8_35' ,
+ N("Netherlands") => '8_48' ,
+ N("United Kingdom") => '0_38' ,
+ N("United States") => '8_35',
+ );
+ $netc->{vpivci} = $h{$netc->{vpivci}};
+ }
+ },
+
+ cable =>
+ {
+ name => N("Connect to the Internet") . "\n\n" .
+ N("Which dhcp client do you want to use ? (default is dhcp-client)"),
+ data =>
+ [ { val => \$netcnx->{dhcp_client}, list => ["dhcp-client", "dhcpcd", "dhcpxd"] } ],
+
+ post => sub {
+ $netcnx->{type} = $type = 'cable';
+ $in->do_pkgs->install($netcnx->{dhcp_client});
+ write_cnx_script($netc, "cable", qq(
+/sbin/ifup $netc->{NET_DEVICE}
+),
+ qq(
+/sbin/ifdown $netc->{NET_DEVICE}
+), $netcnx->{type});
+ return "go_ethernet";
+ },
+ },
+
+ go_ethernet =>
+ {
+ pre => sub {
+ # my ($netc, $intf, $type, $ipadr, $netadr, $first_time) = @_;
+ conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return;
+ $netc->{NET_INTERFACE} = $netc->{NET_DEVICE};
+ configureNetwork($netc, $intf, $first_time) or return;
+ },
+ },
+
+ isdn =>
+ {
+ pre=> sub {
+ detect($netc->{autodetect}, 'isdn') if !$::isInstall && !$netc->{autodetection};
+ # FIXME: offer to pick any card from values %{$netc->{autodetect}{isdn}}
+ $isdn = top(values %{$netc->{autodetect}{isdn}});
+ isdn_step_1:
+ defined $isdn->{id} and goto intern_pci;
+ },
+ # !intern_pci:
+ name => N("What kind is your ISDN connection?"),
+ data => [ { val => \$isdn_type, type => "list", list => [ N_("Internal ISDN card"), N_("External ISDN modem") ], } ],
+ post => sub {
+ if ($isdn_type =~ /card/) {
+ intern_pci:
+ $netc->{isdntype} = 'isdn_internal';
+ $netcnx->{isdn_internal} = $isdn;
+ $netcnx->{isdn_internal} = isdn_read_config($netcnx->{isdn_internal});
+ isdn_detect($netcnx->{isdn_internal}, $netc) or goto isdn_step_1;
+ } else {
+ $netc->{isdntype} = 'isdn_external';
+ $netcnx->{isdn_external}{device} = $netc->{autodetect}{modem};
+ $netcnx->{isdn_external} = isdn_read_config($netcnx->{isdn_external});
+ $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40';
+ require network::modem;
+ $modem = $netcnx->{isdn_external};
+ return &$ppp_first_step->();
+ };
- write_initscript();
- $::isStandalone && member($netc->{internet_cnx_choice}, ('modem', 'adsl', 'isdn')) and
- $success = ask_connect_now($netc->{internet_cnx_choice});
+ },
+ },
+
+ isdn_detect =>
+ {
+ pre => sub {
+ my ($isdn, $netc) = @_;
+ if ($isdn->{id}) {
+ log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
+ $isdn->{description} =~ s/\|/ -- /;
+
+ isdn_detect_step_0:
+ defined $isdn->{type} and my $new = $in->ask_yesorno(N("ISDN Configuration"), N("Do you want to start a new configuration ?"), 1);
+
+ if ($isdn->{type} eq '' || $new) {
+ isdn_ask($isdn, $netc, N("I have detected an ISDN PCI card, but I don't know its type. Please select a PCI card on the next screen.")) or goto isdn_detect_step_0;
+ } else {
+ isdn_detect_step_1:
+ $isdn->{protocol} = isdn_ask_protocol() or goto isdn_detect_step_0;
+ isdn_detect_step_2:
+ isdn_ask_info($isdn, $netc) or goto isdn_detect_step_1;
+ isdn_write_config($isdn, $netc) or goto isdn_detect_step_2;
+ }
+ } else {
+ isdn_ask($isdn, $netc, N("No ISDN PCI card found. Please select one on the next screen.")) or return;
+ }
+ $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
+ 1;
+ }
+ },
- step_3:
- my $m = $success ? join('', N("Congratulations, the network and Internet configuration is finished.
+ winmodem =>
+ {
+ pre => sub {
+ my ($in, $netcnx, $mouse, $netc) = @_;
+ my %relocations = (ltmodem => $in->do_pkgs->check_kernel_module_packages('ltmodem'));
+ my $type;
+
+ detect($netc->{autodetect}, 'lan') if !$::isInstall && !$netc->{autodetection};
+ $netc->{autodetect}{winmodem} or ($in->ask_warn(N("Warning"), N("You don't have any winmodem")) ? return 1 : $in->exit(0));
+
+ foreach (keys %{$netc->{autodetect}{winmodem}}) {
+ /Hcf/ and $type = "hcfpcimodem";
+ /Hsf/ and $type = "hsflinmodem";
+ /LT/ and $type = "ltmodem";
+ $relocations{$type} || $type && $in->do_pkgs->what_provides($type) or $type = undef;
+ }
+
+ $type or ($in->ask_warn(N("Warning"), N("Your modem isn't supported by the system.
+Take a look at http://www.linmodems.org")) ? return 1 : $in->exit(0));
+ my $e = $in->ask_from_list(N("Title"), N("\"%s\" based winmodem detected, do you want to install needed software ?", $type), [N("Install rpm"), N("Do nothing")]) or return 0;
+ if ($e =~ /rpm/) {
+ if ($in->do_pkgs->install($relocations{$type} ? @{$relocations{$type}} : $type)) {
+ unless ($::isInstall) {
+ #- fallback to modem configuration (beware to never allow test it).
+ $netcnx->{type} = 'modem';
+ #$type eq 'ltmodem' and $netc->{autodetect}{modem} = '/dev/ttyS14';
+ return configure($in, $netcnx, $mouse, $netc);
+ }
+ } else {
+ return 0;
+ }
+ }
+ return 1;
+ },
+ },
+
+ no_winmodem =>
+ {
+ name => N("Warning") . "\n\n" . N("You don't have any winmodem"),
+ },
+
+ no_supported_winmodem =>
+ {
+ name => N("Warning") . "\n\n" . N("Your modem isn't supported by the system.
+Take a look at http://www.linmodems.org")
+ },
+
+
+
+
+ modem =>
+ {
+ pre => sub {
+ my ($in, $netcnx, $mouse, $netc) = @_;
+ $netcnx->{type} = 'modem';
+ my $modem = $netcnx->{$netcnx->{type}};
+ $modem->{device} = $netc->{autodetect}{modem};
+ my %l = getVarsFromSh("$::prefix/usr/share/config/kppprc");
+ $modem->{connection} = $l{Name};
+ $modem->{domain} = $l{Domain};
+ ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
+
+ foreach (cat_("/etc/sysconfig/network-scripts/chat-ppp0")) {
+ /.*ATDT(\d*)/ and $modem->{phone} = $1;
+ }
+ foreach (cat_("/etc/sysconfig/network-scripts/ifcfg-ppp0")) {
+ /NAME=(['"]?)(.*)\1/ and $modem->{login} = $2;
+ }
+ my $secret = network::tools::read_secret_backend();
+ foreach (@$secret) {
+ $modem->{passwd} = $_->{passwd} if $_->{login} eq $modem->{login};
+ }
+
+ return &$ppp_first_step->();
+ },
+ },
+
+ # FIXME: only if $need_to_ask
+ ppp_choose =>
+ {
+ pre => sub {
+ $mouse ||= {};
+ $mouse->{device} ||= readlink "$::prefix/dev/mouse";
+ write_cnx_script($netc, "modem", join("\n", if_($::testing, "/sbin/route del default"), "ifup ppp0"),
+ q(ifdown ppp0
+killall pppd
+), $netcnx->{type});
+ my $need_to_ask = $modem->{device} || !$netc->{autodetect}{winmodem};
+ },
+
+ name => N("Please choose which serial port your modem is connected to."),
+ interactive_help_id => 'selectSerialPort',
+ data => [ { var => \$modem->{device}, format => \&mouse::serial_port2text, type => "list",
+ list => [ grep { $_ ne $o_mouse->{device} } (if_(-e '/dev/modem', '/dev/modem'), mouse::serial_ports()) ] } ],
+
+ next => "ppp_choose2",
+ },
+
+ ppp_choose2 =>
+ {
+ pre => sub {
+ #my $secret = network::tools::read_secret_backend();
+ #my @cnx_list = map { $_->{server} } @$secret;
+ },
+ name => N("Dialup options"),
+ data => [
+ { label => N("Connection name"), val => \$modem->{connection} },
+ { label => N("Phone number"), val => \$modem->{phone} },
+ { label => N("Login ID"), val => \$modem->{login} },
+ { label => N("Password"), val => \$modem->{passwd}, hidden => 1 },
+ { label => N("Authentication"), val => \$modem->{auth}, list => [ N_("PAP"), N_("Terminal-based"), N_("Script-based"), N_("CHAP") ] },
+ { label => N("Domain name"), val => \$modem->{domain} },
+ { label => N("First DNS Server (optional)"), val => \$modem->{dns1} },
+ { label => N("Second DNS Server (optional)"), val => \$modem->{dns2} },
+ ],
+ post => sub {
+ network::modem::ppp_configure($in, $netc, $modem);
+ $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
+ &$next_cnx_step->();
+ },
+ },
+
+
+ lan_standalone =>
+ {
+ pre => sub {
+ detect($netc->{autodetect}, 'lan') if !$::isInstall;
+ modules::interactive::load_category($in, 'network/main|gigabit|usb|pcmcia', !$::expert, 1);
+ @all_cards = network::ethernet::conf_network_card_backend($netc, $intf);
+ @cards = map { $_->[0] } @all_cards;
+ foreach my $card (@all_cards) {
+ modules::remove_alias($card->[1]);
+ modules::add_alias($card->[0], $card->[1]);
+ }
+ },
+ name => N("Select the network interface to configure:"),
+ data => [ { label => N("Net Device"), val => \$ntf_name, list => [ detect_devices::getNet() ], allow_empty_list => 1 } ],
+ post => sub {
+ delete $ethntf->{$_} foreach keys %$ethntf;
+ add2hash($ethntf, $intf->{$ntf_name});
+ return 'lan';
+ },
+ },
+
+
+ # FIXME: is_install: no return for each card "last step" because of manual popping
+ # better construct an hash of { current_netintf => next_step } which next_step = last_card ? next_eth_step : next_card ?
+ lan =>
+ {
+ pre => sub {
+ # FIXME: set $module
+ $net_device = $netc->{NET_DEVICE};
+ if ($net_device eq $ethntf->{DEVICE}) {
+ $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).");
+ }
+ $auto_ip = $ethntf->{BOOTPROTO} !~ /static/;
+ $onboot = $ethntf->{ONBOOT} ? $ethntf->{ONBOOT} =~ /yes/ : bool2yesno(!member($ethntf->{DEVICE},
+ map { $_->{device} } detect_devices::pcmcia_probe()));
+ $needhostname = $ethntf->{NEEDHOSTNAME} !~ /no/;
+ $hotplug = $::isStandalone && !$ethntf->{MII_NOT_SUPPORTED} || 1;
+ $track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop();
+ delete $ethntf->{NETWORK};
+ delete $ethntf->{BROADCAST};
+ @fields = qw(IPADDR NETMASK);
+ },
+ name => sub { N("Configuring network device %s", $ethntf->{DEVICE}) . ($module ? N(" (driver %s)", $module) : '') . "\n\n" . $text },
+ data => sub {
+ [ { label => N("Automatic IP"), val => \$auto_ip, type => "bool", text => N("(bootp/dhcp/zeroconf)") },
+ { label => N("IP address"), val => \$ethntf->{IPADDR}, disabled => sub { $auto_ip } },
+ { label => N("Netmask"), val => \$ethntf->{NETMASK}, disabled => sub { $auto_ip } },
+ { label => N("DHCP host name"), val => \$ethntf->{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 },
+ ],
+ },
+ complete => sub {
+ $ethntf->{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($ethntf->{$_}), $::i) } @fields) {
+ $in->ask_warn('', N("IP address should be in format 1.2.3.4"));
+ return 1, $bad[0];
+ }
+ $in->ask_warn('', N("Warning : IP address %s is usually reserved !", $ethntf->{IPADDR})) if is_ip_forbidden($ethntf->{IPADDR});
+ },
+ focus_out => sub {
+ $ethntf->{NETMASK} ||= netmask($ethntf->{IPADDR}) unless $_[0]
+ },
+ post => sub {
+ $ethntf->{ONBOOT} = bool2yesno($onboot);
+ $ethntf->{NEEDHOSTNAME} = bool2yesno($needhostname);
+ $ethntf->{MII_NOT_SUPPORTED} = bool2yesno(!$hotplug);
+ $ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR};
+
+ #FIXME "wireless" if $ethntf->{wireless_eth};
+ # FIXME: only ask for zeroconf if no dynamic host *AND* no adsl/isdn/modem (aka type being lan|wireless)
+ return is_dynamic_ip($intf) ?
+ (is_dynamic_host($ethntf) ? "dhcp_hostname" : "zeroconf")
+ : "static_hostname";
+ },
+ },
+
+ wireless =>
+ {
+ pre => sub {
+ if (is_wireless_intf($module)) {
+ $ethntf->{wireless_eth} = 1;
+ $netc->{wireless_eth} = 1;
+ $ethntf->{WIRELESS_MODE} = "Managed";
+ $ethntf->{WIRELESS_ESSID} = "any";
+ }
+ },
+ name => N("Please enter the wireless parameters for this card:"),
+ data => [
+ { label => N("Operating Mode"), val => \$ethntf->{WIRELESS_MODE},
+ list => [ keys %wireless_mode ] },
+ { label => N("Netwok name (ESSID)"), val => \$ethntf->{WIRELESS_ESSID} },
+ { label => N("Network ID"), val => \$ethntf->{WIRELESS_NWID} },
+ { label => N("Operating frequency"), val => \$ethntf->{WIRELESS_FREQ} },
+ { label => N("Sensitivity threshold"), val => \$ethntf->{WIRELESS_SENS} },
+ { label => N("Bitrate (in b/s)"), val => \$ethntf->{WIRELESS_RATE} },
+ { label => N("Encryption key"), val => \$ethntf->{WIRELESS_ENC_KEY} },
+ { label => N("RTS/CTS)"), val => \$ethntf->{WIRELESS_RTS},
+ help => N("RTS/CTS adds a handshake before each packet transmission to make sure that the
+channel is clear. This adds overhead, but increase performance in case of hidden
+nodes or large number of active nodes. This parameters set the size of the
+smallest packet for which the node sends RTS, a value equal to the maximum
+packet size disable the scheme. You may also set this parameter to auto, fixed
+or off.")
+ },
+ { label => N("Fragmentation"), val => \$ethntf->{WIRELESS_FRAG} },
+ { label => N("Iwconfig command extra arguments"), val => \$ethntf->{WIRELESS_IWCONFIG}, advanced => 1,
+ help => N("Here, one can configure some extra wireless parameters such as:
+ap, channel, commit, enc, power, retry, sens, txpower (nick is already set as the hostname).
+
+See iwpconfig(8) man page for further information."),
+ },
+ { label => N("Iwspy command extra arguments"), val => \$ethntf->{WIRELESS_IWSPY}, advanced => 1,
+ help => N("Iwspy is used to set a list of addresses in a wireless network
+interface and to read back quality of link information for each of those.
+
+This information is the same as the one available in /proc/net/wireless :
+quality of the link, signal strength and noise level.
+
+See iwpspy(8) man page for further information."),
+ },
+ { label => N("Iwpriv command extra arguments"), val => \$ethntf->{WIRELESS_IWPRIV}, advanced => 1,
+ help => N("Iwpriv enable to set up optionals (private) parameters of a wireless network
+interface.
+
+Iwpriv deals with parameters and setting specific to each driver (as opposed to
+iwconfig which deals with generic ones).
+
+In theory, the documentation of each device driver should indicate how to use
+those interface specific commands and their effect.
+
+See iwpriv(8) man page for further information."),
+ }
+ ],
+ complete => sub {
+ if ($ethntf->{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 ($ethntf->{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;
+ }
+ },
+ post => sub {
+ # untranslate parameters
+ $ethntf->{WIRELESS_MODE} = $wireless_mode{$ethntf->{WIRELESS_MODE}};
+ },
+ },
+
+ conf_network_card =>
+ {
+ pre => sub {
+ # my ($netc, $intf, $type, $ipadr, $o_netadr) = @_;
+ #-type =static or dhcp
+ modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1);
+ @all_cards = conf_network_card_backend($netc, $intf, $type, undef, $ipadr, $netadr) or
+ # FIXME: fix this
+ $in->ask_warn('', N("No ethernet network adapter has been detected on your system.
+I cannot set up this connection type.")), return;
+
+ },
+ name => N("Choose the network interface") . "\n\n" .
+ N("Please choose which network adapter you want to use to connect to Internet."),
+ data => [ { var => \$interface, type => "list", list => \@all_cards, } ],
+ format => sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") },
+
+ post => sub {
+ modules::write_conf($::prefix) if $::isStandalone;
+ my $_device = conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr);
+ return "lan";
+ },
+ },
+
+ static_hostname =>
+ {
+ pre => sub {
+ my ($in, $netc, $intf, @devices) = @_;
+
+ $netc->{dnsServer} ||= dns($intf->{IPADDR});
+ $gateway_ex = gateway($intf->{IPADDR});
+ #- $netc->{GATEWAY} ||= gateway($intf->{IPADDR});
+ },
+ name => 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."),
+ data =>
+ [ { label => N("Host name"), val => \$netc->{HOSTNAME} },
+ { 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;
+ }
+ },
+ next => "miscellaneous_choose",
+ },
+
+ dhcp_hostname =>
+ {
+ },
+
+ zeroconf =>
+ {
+ name => N("Enter a Zeroconf host name which will be the one that your machine will get back to other machines on the network:"),
+ data => [ { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} } ],
+ complete => sub {
+ if ($netc->{ZEROCONF_HOSTNAME} =~ /\./) {
+ $in->ask_warn('', N("Zeroconf host name must not contain a ."));
+ return 1;
+ }
+ },
+ next => "miscellaneous_choose",
+ },
+
+ multiple_internet_cnx =>
+ {
+ pre => sub {
+ my $nb = keys %{$netc->{internet_cnx}};
+ if ($nb > 1) {
+ # BUG: remember to remove reference to profiles in mcc if we do not restore this feature
+ $in->ask_from("",
+ N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n") . if_(!$::isStandalone, "You may want to configure some profiles after the installation, in the Mandrake Control Center"),
+ [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice}, list => [ keys %{$netc->{internet_cnx}} ] } ]
+ ) or goto step_2;
+ } elsif ($nb == 1) {
+ $netc->{internet_cnx_choice} = (keys %{$netc->{internet_cnx}})[0];
+ }
+ },
+ post => sub { $::isInstall ? "miscellaneous_choose" : "apply_settings" },
+ },
+
+ miscellaneous_choose =>
+ {
+ name => N("Proxies configuration"),
+ data => [
+ { label => N("HTTP proxy"), val => \$::o->{miscellaneous}->{http_proxy} },
+ { label => N("FTP proxy"), val => \$::o->{miscellaneous}->{ftp_proxy} },
+ ],
+ complete => sub {
+ if ($::o->{miscellaneous}->{http_proxy} !~ m,^($|http://),) {
+ $in->ask_warn('', N("Proxy should be http://..."));
+ return 1, 0;
+ }
+ if ($::o->{miscellaneous}->{ftp_proxy} !~ m,^($|ftp://|http://),) {
+ $in->ask_warn('', N("URL should begin with 'ftp:' or 'http:'"));
+ return 1, 1;
+ }
+ 0;
+ },
+ # FIXME: call ether_conf();
+ post => sub { return !$::isInstall ? "apply_settings" : "network_on_boot" },
+ },
+
+ apply_settings =>
+ {
+ name => N("Configuration is complete, do you want to apply settings ?"),
+ data => [], # FIXME: yesorno
+ next => "network_on_boot",
+ },
+
+ network_on_boot =>
+ {
+ pre => sub {
+ member($netc->{internet_cnx_choice}, ('adsl', 'isdn')) and $netc->{at_boot} = $in->ask_yesorno(N("Network Configuration Wizard"), N("Do you want to start the connection at boot?"));
+
+ if ($netc->{internet_cnx_choice}) {
+ write_cnx_script($netc);
+ $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
+ } else {
+ unlink "$::prefix/etc/sysconfig/network-scripts/net_cnx_up";
+ unlink "$::prefix/etc/sysconfig/network-scripts/net_cnx_down";
+ undef $netc->{NET_DEVICE};
+ }
+
+ network::network::configureNetwork2($in, $::prefix, $netc, $intf);
+ $network_configured = 1;
+ },
+ name => N("Do you want to start the connection at boot?"),
+ data => [], # FIXME yes/no
+ },
+
+ restart =>
+ {
+ # FIXME: condition is "if ($netconnect::need_restart_network && $::isStandalone && (!$::expert || $in->ask_yesorno(..."
+ name => N("The network needs to be restarted. Do you want to restart it ?"),
+ # data => [ { label => N("Connection:"), val => \$type, type => 'list', list => [ sort values %l ] }, ],
+ post => sub {
+ if (!$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) {
+ $success = 0;
+ $in->ask_okcancel(N("Network Configuration"),
+ N("A problem occured while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
+ }
+ write_initscript();
+ return $::isStandalone && member($netc->{internet_cnx_choice}, qw(modem adsl isdn)) ? "ask_connect_now" : "end";
+ },
+ },
+
+ ask_connect_now =>
+ {
+ no_back => 1,
+ name => N("Do you want to try to connect to the Internet now?"),
+ data => [], # FIXME: yes/no
+ post => sub {
+ my ($a) = @_;
+ my ($type) = $netc->{internet_cnx_choice};
+ $up = 1;
+ #- FIXME : code the exception to be generated by ask_yesorno, to be able to remove the $::Wizard_no_previous=1;
+ if ($a) {
+ # local $::isWizard = 0;
+ my $_w = $in->wait_message('', N("Testing your connection..."), 1);
+ connect_backend();
+ my $s = 30;
+ $type =~ /modem/ and $s = 50;
+ $type =~ /adsl/ and $s = 35;
+ $type =~ /isdn/ and $s = 20;
+ sleep $s;
+ $up = connected();
+ }
+ $success = $up;
+ return $a ? "disconnect" : "end";
+ }
+ },
+ disconnect =>
+ {
+ name => sub {
+ $up ? N("The system is now connected to the Internet.") .
+ if_($::isInstall, N("For security reasons, it will be disconnected now.")) :
+ N("The system doesn't seem to be connected to the Internet.
+Try to reconfigure your connection.");
+ },
+ no_back => 1,
+ end => 1,
+ post => sub {
+ $::isInstall and disconnect_backend();
+ return "end";
+ },
+ },
+
+ end =>
+ {
+ name => sub {
+ return $success ? join('', N("Congratulations, the network and Internet configuration is finished.
"), if_($::isStandalone && $in->isa('interactive::gtk'),
-N("After this is done, we recommend that you restart your X environment to avoid any hostname-related problems."))) :
- N("Problems occured during configuration.
+ N("After this is done, we recommend that you restart your X environment to avoid any hostname-related problems."))) :
+ N("Problems occured during configuration.
Test your connection via net_monitor or mcc. If your connection doesn't work, you might want to relaunch the configuration.");
- $::Wizard_no_previous = 1;
- $::Wizard_finished = 1;
- eval { $in->ask_okcancel(N("Network Configuration"), $m, 1) }; $in->exit(0) if $@ =~ /wizcancel/;
- undef $::Wizard_no_previous;
- undef $::Wizard_finished;
-
- step_5:
- $network_configured or network::network::configureNetwork2($in, $prefix, $netc, $intf);
+ },
+ end => 1,
+ },
+ },
+ };
+
+ my $use_wizard = 1;
+ if ($::isInstall) {
+ if ($first_time && $in->{method} =~ /^(ftp|http|nfs)$/) {
+ !$::expert && !$o_noauto || $in->ask_okcancel(N("Network Configuration"),
+ N("Because you are doing a network installation, your network is already configured.
+Click on Ok to keep your configuration, or cancel to reconfigure your Internet & Network connection.
+"), 1)
+ and do {
+ $netcnx->{type} = 'lan';
+ output_with_perm("$::prefix$connect_file", 0755, qq(ifup eth0
+));
+ output("$::prefix$disconnect_file", 0755, qq(
+ifdown eth0
+));
+ $direct_net_install = 1;
+ $use_wizard = 0;
+ };
+ } else {
+ $wiz->{pages}{welcome} = $wiz->{pages}{install};
+ }
+ } else {
+ $wiz->{pages}{welcome} = $wiz->{pages}{connection};
+ };
+
+ if ($use_wizard) {
+ require wizards;
+ $wiz->{var} = {
+ netc => $o_netc || {},
+ mouse => $o_mouse || {},
+ intf => $o_intf || {},
+ };
+ wizards->new->safe_process($wiz, $in);
+ }
+
+ # install needed packages:
+ $network_configured or network::network::configureNetwork2($in, $::prefix, $netc, $intf);
my $connect_cmd;
if ($netcnx->{type} =~ /modem/ || $netcnx->{type} =~ /isdn_external/) {
$connect_cmd = qq(
#!/bin/bash
if [ -n "\$DISPLAY" ]; then
-if [ -e /usr/bin/kppp ]; then
-/sbin/route del default
-/usr/bin/kppp &
-else
-/usr/sbin/net_monitor --connect
-fi
-else
-$connect_file
+ if [ -e /usr/bin/kppp ]; then
+ /sbin/route del default
+ /usr/bin/kppp &
+ else
+ /usr/sbin/net_monitor --connect
+ fi
+ else
+ $connect_file
fi
);
} elsif ($netcnx->{type}) {
$connect_cmd = qq(
#!/bin/bash
if [ -n "\$DISPLAY" ]; then
-/usr/sbin/net_monitor --connect
+ /usr/sbin/net_monitor --connect
else
-$connect_file
+ $connect_file
fi
);
} else {
@@ -250,9 +947,9 @@ fi
$connect_cmd = qq(
#!/bin/bash
if [ -n "\$DISPLAY" ]; then
-/usr/sbin/net_monitor --connect
+ /usr/sbin/net_monitor --connect
else
-$connect_file
+ $connect_file
fi
);
}
@@ -338,11 +1035,6 @@ sub stop_internet {
run_program::rooted($prefix, $disconnect_file);
}
-my @connection_types = (N_("modem"), N_(" isdn"), N_(" adsl"), N_(" cable"), N_(" local network"));
-
-#---------------------------------------------
-# WONDERFULL pad
-#---------------------------------------------
1;
=head1 network::netconnect::detect()
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));
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index 05ef51c94..9735aef4b 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -9,7 +9,7 @@ use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_pro
use MDK::Common::System qw(getVarsFromSh);
@ISA = qw(Exporter);
-@EXPORT = qw(ask_connect_now ask_info2 connect_backend connected connected_bg disconnect_backend is_dynamic_ip is_wireless_intf passwd_by_login read_providers_backend read_secret_backend test_connected write_cnx_script write_initscript write_secret_backend);
+@EXPORT = qw(ask_info2 connect_backend connected connected_bg disconnect_backend is_dynamic_ip is_wireless_intf passwd_by_login read_providers_backend read_secret_backend test_connected write_cnx_script write_initscript write_secret_backend);
@EXPORT_OK = qw($in);
sub write_cnx_script {
@@ -69,96 +69,12 @@ sub passwd_by_login {
}
}
-sub ask_connect_now {
- my ($type) = @_;
- $::Wizard_no_previous = 1;
- my $up = 1;
- #- FIXME : code the exception to be generated by ask_yesorno, to be able to remove the $::Wizard_no_previous=1;
- if ($in->ask_yesorno(N("Internet configuration"),
- N("Do you want to try to connect to the Internet now?")
- )) {
- {
- my $_w = $in->wait_message('', N("Testing your connection..."), 1);
- connect_backend();
- my $s = 30;
- $type =~ /modem/ and $s = 50;
- $type =~ /adsl/ and $s = 35;
- $type =~ /isdn/ and $s = 20;
- sleep $s;
- $up = connected();
- }
- my $m = $up ? N("The system is now connected to the Internet.") .
- if_($::isInstall, N("For security reasons, it will be disconnected now.")) :
- N("The system doesn't seem to be connected to the Internet.
-Try to reconfigure your connection.");
- $::Wizard_no_previous = 1;
- $::Wizard_finished = 1;
- $in->ask_okcancel(N("Network Configuration"), $m, 1);
- undef $::Wizard_no_previous;
- undef $::Wizard_finished;
- $::isInstall and disconnect_backend();
- }
- undef $::Wizard_no_previous;
- $up;
-}
-
sub connect_backend() { run_program::rooted($prefix, "$connect_file &") }
sub disconnect_backend() { run_program::rooted($prefix, "$disconnect_file &") }
sub read_providers_backend { my ($file) = @_; map { /(.*?)=>/ } catMaybeCompressed($file) }
-sub ask_info2 {
- my ($cnx, $netc) = @_;
-
- $in->ask_from(N("Connection Configuration"),
- N("Please fill or check the field below"),
- [
- if__($cnx->{irq}, { label => N("Card IRQ"), val => \$cnx->{irq} }),
- if__($cnx->{mem}, { label => N("Card mem (DMA)"), val => \$cnx->{mem} }),
- if__($cnx->{io}, { label => N("Card IO"), val => \$cnx->{io} }),
- if__($cnx->{io0}, { label => N("Card IO_0"), val => \$cnx->{io0} }),
- if__($cnx->{io1}, { label => N("Card IO_1"), val => \$cnx->{io1} }),
- if__($cnx->{phone_in}, { label => N("Your personal phone number"), val => \$cnx->{phone_in} }),
- if__($netc->{DOMAINNAME2}, { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} }),
- if__($cnx->{phone_out}, { label => N("Provider phone number"), val => \$cnx->{phone_out} }),
- if__($netc->{dnsServer2}, { label => N("Provider dns 1 (optional)"), val => \$netc->{dnsServer2} }),
- if__($netc->{dnsServer3}, { label => N("Provider dns 2 (optional)"), val => \$netc->{dnsServer3} }),
- if__($cnx->{vpivci}, { label => N("Choose your country"), val => \$netc->{vpivci}, list => detect_timezone() }),
- if__($cnx->{dialing_mode}, { label => N("Dialing mode"), val => \$cnx->{dialing_mode},list => ["auto", "manual"] }),
- if__($cnx->{speed}, { label => N("Connection speed"), val => \$cnx->{speed}, list => ["64 Kb/s", "128 Kb/s"] }),
- if__($cnx->{huptimeout}, { label => N("Connection timeout (in sec)"), val => \$cnx->{huptimeout} }),
- { label => N("Account Login (user name)"), val => \$cnx->{login} },
- { label => N("Account Password"), val => \$cnx->{passwd}, hidden => 1 },
- ]
- ) or return;
- if ($netc->{vpivci}) {
- foreach ([N("Netherlands"), '8_48'], [N("France"), '8_35'], [N("Belgium"), '8_35'], [N("Italy"), '8_35'], [N("United Kingdom"), '0_38'], [N("United States"), '8_35']) {
- $netc->{vpivci} eq $_->[0] and $netc->{vpivci} = $_->[1];
- }
- }
- 1;
-}
-
-sub detect_timezone() {
- my %tmz2country = (
- 'Europe/Paris' => N("France"),
- 'Europe/Amsterdam' => N("Netherlands"),
- 'Europe/Rome' => N("Italy"),
- 'Europe/Brussels' => N("Belgium"),
- 'America/New_York' => N("United States"),
- 'Europe/London' => N("United Kingdom")
- );
- my %tm_parse = MDK::Common::System::getVarsFromSh('/etc/sysconfig/clock');
- my @country;
- foreach (keys %tmz2country) {
- if ($_ eq $tm_parse{ZONE}) {
- unshift @country, $tmz2country{$_};
- } else { push @country, $tmz2country{$_} };
- }
- \@country;
-}
-
sub connected() { gethostbyname("mandrakesoft.com") ? 1 : 0 }
# request a ref on a bg_connect and a ref on a scalar
@@ -327,4 +243,9 @@ sub is_dynamic_ip {
any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %$intf;
}
+sub is_dynamic_host {
+ my ($intf) = @_;
+ any { defined $_->{DHCP_HOSTNAME} } values %$intf;
+}
+
1;