diff options
Diffstat (limited to 'perl-install/install_steps_newt.pm')
0 files changed, 0 insertions, 0 deletions
![]() |
index : drakx | |
Mageia Installer and base platform for many utilities | Thierry Vignaud [tv] |
summaryrefslogtreecommitdiffstats |
package network::netconnect;
use diagnostics;
use strict;
use vars qw($isdn_init @isdndata);
use common;
use log;
use detect_devices;
use run_program;
use modules;
use any;
use mouse;
use network;
use network::tools;
use MDK::Common::Globals "network", qw($in $prefix $connect_file $disconnect_file $connect_prog);
@EXPORT = qw(start_internet stop_internet);
#- intro is called only in standalone.
sub intro {
my ($prefix, $netcnx, $in) = @_;
my ($netc, $mouse, $intf) = ({}, {}, {});
my $text;
my $connected;
my $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up";
my $disconnect_file = "/etc/sysconfig/network-scripts/net_cnx_down";
my $connect_prog = "/etc/sysconfig/network-scripts/net_cnx_pg";
read_net_conf($prefix, $netcnx, $netc);
if (!$::isWizard) {
if (connected()) {
$text=_("You are currently connected to internet.") . (-e $disconnect_file ? _("\nYou can disconnect or reconfigure your connection.") : _("\nYou can reconfigure your connection."));
$connected=1;
} else {
$text=_("You are not currently connected to Internet.") . (-e $connect_file ? _("\nYou can connect to Internet or reconfigure your connection.") : _("\nYou can reconfigure your connection."));
$connected=0;
}
my @l=(
!$connected && -e $connect_file ? { description => _("Connect to Internet"),
c => 1} : (),
$connected && -e $disconnect_file ? { description => _("Disconnect from Internet"),
c => 2} : (),
{ description => _("Configure network connection (LAN or Internet)"),
c => 3},
);
my $e = $in->ask_from_listf(_("Internet connection & configuration"),
_($text),
sub { $_[0]{description} },
\@l );
run_program::rooted($prefix, $connect_prog) if ($e->{c}==1);
run_program::rooted($prefix, $disconnect_file) if ($e->{c}==2);
main($prefix, $netcnx, $netc, $mouse, $in, $intf, 0, 0) if ($e->{c}==3);
} else {
main($prefix, $netcnx, $netc, $mouse, $in, $intf, 0, 0);
}
}
sub detect {
my ($auto_detect, $net_install) = @_;
my $isdn={};
require network::isdn;
network::isdn->import;
isdn_detect_backend($isdn);
$auto_detect->{isdn}{$_}=$isdn->{$_} foreach qw(description vendor id driver card_type type);
$auto_detect->{isdn}{description} =~ s/.*\|//;
any::setup_thiskind_backend('net', undef);
require network::ethernet;
network::ethernet->import;
my @all_cards = conf_network_card_backend (undef, undef, undef, undef, undef, undef);
require network::adsl;
network::adsl->import;
map {
( !$net_install and adsl_detect($_->[0]) ) ? $auto_detect->{adsl}=$_->[0] : $auto_detect->{lan}{$_->[0]}=$_->[1]; } @all_cards;
my $modem={};
require network::modem;
network::modem->import;
modem_detect_backend($modem);#, $mouse);
$modem->{device} and $auto_detect->{modem}=$modem->{device};
}
sub pre_func {
my ($text) = @_;
$in->isa('interactive_gtk') or return;
$::Wizard_no_previous=1;
if ($::isStandalone) {
$::Wizard_splash=1;
require my_gtk;
my_gtk->import(qw(:wrappers));
my $W = my_gtk->new(_("Network Configuration Wizard"));
gtkadd($W->{window},
gtkpack_(new Gtk::VBox(0, 0),
1, write_on_pixmap(gtkpng ("draknet_step"),
20,200,
_("We are now going to configure the %s connection.",_($text)),
),
0, $W->create_okcancel
)
);
$W->main;
$::Wizard_splash=0;
} else {
#- for i18n : %s is the type of connection of the list: (modem, isdn, adsl, cable, local network);
$in->ask_okcancel(_("Network Configuration Wizard"), _("\n\n\nWe are now going to configure the %s connection.\n\n\nPress OK to continue.",_($_[0])), 1);
}
undef $::Wizard_no_previous;
}
sub init_globals {
my ($in, $prefix) = @_;
MDK::Common::Globals::init(
in => $in,
prefix => $prefix,
connect_file => "/etc/sysconfig/network-scripts/net_cnx_up",
disconnect_file => "/etc/sysconfig/network-scripts/net_cnx_down",
connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg" );
}
sub main {
my ($prefix, $netcnx, $netc, $mouse, $in, $intf, $first_time, $direct_fr, $noauto) = @_;
init_globals ($in, $prefix);
$netc->{minus_one}=0; #When one configure an eth in dhcp without gateway
$::isInstall and $in->set_help('configureNetwork');
$::isStandalone and read_net_conf($prefix, $netcnx, $netc); # REDONDANCE with intro. FIXME
$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::read_all_conf($prefix, $netc ||= {}, $intf ||= {});
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 || $noauto) or $in->ask_okcancel(_("Network Configuration"),
_("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 "$prefix$connect_file",
qq(
ifup eth0
);
output "$prefix$disconnect_file",
qq(
ifdown eth0
);
chmod 0755, "$prefix$disconnect_file";
chmod 0755, "$prefix$connect_file";
$direct_net_install = 1;
goto step_5;
};
}
$netc->{autodetection}=1;
$netc->{autodetect}={};
step_1:
$::Wizard_no_previous=1;
my @profiles=get_profiles();
$in->ask_from(_("Network Configuration Wizard"),
_("Welcome to The Network Configuration Wizard\n\nWe are about to configure your internet/network connection.\nIf you don't want to use the auto detection, deselect the checkbox.\n"),
[
if_(@profiles > 1, { label => _("Choose the profile to configure"), val => \$netcnx->{PROFILE}, list => \@profiles }),
{ label => _("Use auto detection"), val => \$netc->{autodetection}, type => 'bool' },
]
) or goto step_5;
undef $::Wizard_no_previous;
set_profile($netcnx);
if ($netc->{autodetection}) {
my $w = $in->wait_message(_("Network Configuration Wizard"), _("Detecting devices..."));
detect($netc->{autodetect}, $::isInstall && ($in->{method} eq "ftp" || $in->{method} eq "http" || $in->{method} eq "nfs"));
}
step_2:
my $set_default;
my %conf;
$conf{$_} = $netc->{autodetect}{$_} ? 1 : 0 foreach 'modem', 'adsl', 'cable', 'lan';
$conf{isdn} = $netc->{autodetect}{isdn}{description} ? 1: 0;
my @l = (
[_("Normal modem connection"), $netc->{autodetect}{modem}, __("detected on port %s"), \$conf{modem}],
[_("ISDN connection"), $netc->{autodetect}{isdn}{description}, __("detected %s"), \$conf{isdn}],
[_("ADSL connection"), $netc->{autodetect}{adsl}, __("detected on interface %s"), \$conf{adsl}],
[_("Cable connection"), $netc->{autodetect}{cable}, __("cable connection detected"), \$conf{cable}],
[_("LAN connection"), $netc->{autodetect}{lan}, __("ethernet card(s) detected"), \$conf{lan}]
);
my $i=0;
map { defined $set_default or do { $_->[1] and $set_default=$i; }; $i++; } @l;
@l = (
[_("Normal modem connection") . if_($netc->{autodetect}{modem}, " - " . _("detected on port %s", $netc->{autodetect}{modem})), \$conf{modem}],
[_("ISDN connection") . if_($netc->{autodetect}{isdn}{description}, " - " . _("detected %s", $netc->{autodetect}{isdn}{description})), \$conf{isdn}],
[_("ADSL connection") . if_($netc->{autodetect}{adsl}, " - " . _("detected on interface %s", $netc->{autodetect}{adsl})), \$conf{adsl}],
[_("Cable connection") . if_($netc->{autodetect}{cable}, " - " . _("cable connection detected")), \$conf{cable}],
[_("LAN connection") . if_($netc->{autodetect}{lan}, " - " . _("ethernet card(s) detected")), \$conf{lan}]
);
my $e = $in->ask_from(_("Network Configuration Wizard"), _("Choose the connection you want to configure"),
[ map { { label => $_->[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);
$conf{modem} and do { pre_func("modem"); require network::modem; network::modem::configure($netcnx, $mouse, $netc) or goto step_2 };
$conf{isdn} and do { pre_func("isdn"); require network::isdn; network::isdn::configure($netcnx, $netc) or goto step_2 };
$conf{adsl} and do { pre_func("adsl"); require network::adsl; network::adsl::configure($netcnx, $netc, $intf, $first_time) or goto step_2};
$conf{cable} and do { pre_func("cable"); require network::ethernet; network::ethernet::configure_cable($netcnx, $netc, $intf, $first_time) or goto step_2; $netconnect::need_restart_network = 1; };