summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/finish-install
blob: 85ab006eee6fcc15c2bcc8fe097f51bf3303ea24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

use common;
use interactive;
use any;
use authentication;
use network::network;
use network::netconnect;
use security::level;

$ENV{SHARE_PATH} ||= "/usr/share";
my $conf_file = '/etc/sysconfig/finish-install';
my %steps = getVarsFromSh($conf_file);
my $authentication = authentication::get();
my $security = security::level::get();
my $net = {};
my $locale;
network::network::read_net_conf($net);

$::isWizard = 1;
my $in = 'interactive'->vnew;

sub ask_license() {
    any::acceptLicense($in);
}

sub ask_language() {
    require lang;
    $locale = lang::read();
    any::selectLanguage_and_more_standalone($in, $locale);
    lang::write_and_install($locale, $in->do_pkgs);
}

sub ask_keyboard() {
    require keyboard;
    my $keyboard = $locale ? keyboard::lang2keyboard($locale->{lang}) : keyboard::read_or_default();

  choose:
    $keyboard->{KEYBOARD} = $in->ask_from_listf(N("Keyboard"),
                                                N("Please, choose your keyboard layout."),
                                                sub { translate(keyboard::KEYBOARD2text($_[0])) },
                                                [ keyboard::KEYBOARDs() ],
                                                $keyboard->{KEYBOARD}) or return;

    keyboard::group_toggle_choose($in, $keyboard) or goto choose;

    keyboard::configure_and_set_standalone($keyboard);
}

sub ask_network() {
    my $modules_conf = modules::any_conf->read;
    require network::netconnect;
    network::netconnect::real_main($net, $in, $modules_conf);
}

sub ask_authentication() {
    my $meta_class = { getVarsFromSh("/etc/sysconfig/system") }->{META_CLASS};

    my $superuser = {};
    authentication::ask_root_password_and_authentication($in, $net, $superuser, $authentication, $meta_class, $security);
    authentication::set_root_passwd($superuser, $authentication);

    eval { 
	authentication::set($in, $net, $authentication) or goto &ask_authentication;
	network::network::write_network_conf($net);
    };
    if (my $err = $@) {
	$in->ask_warn(N("Error"), formatError($err));
	goto &ask_authentication;
    }
}

sub ask_users() {
    my $users = []; 
    any::ask_users($in, $users, $security, []);
    any::add_users($users, $authentication);
}

sub call {
    my ($step_name) = @_;
    my $f_name = 'ask_' . $step_name;
    if (member('no', map { lc($steps{$_}) } lc($step_name), uc($step_name))) {
        log::l("ignoring $f_name");
    } else {
        log::l("calling $f_name");
        my $f = $::{$f_name} or internal_error "bad function $f_name";
        eval { $f->() };
        log::l("$f_name failed: $@") if $@;
    }
}

call('license');
call('language');
call('keyboard');
call('network');
if (defined $::WizardWindow) {
    $::WizardWindow->destroy;
    undef $::WizardWindow;
}
$::Wizard_pix_up = 'redhat-config-users';
call('authentication');
call('users');
setVarsInSh($conf_file, { FINISH_INSTALL => 'no' });

$in->exit(0);