summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/finish-install
blob: 4d615762e8d7549205454948fd6d121c3f7f3379 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/perl

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

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

$ENV{SHARE_PATH} ||= "/usr/share";
my $authentication = authentication::get();
my $security = security::level::get();
network::netconnect::read_net_conf(my $netcnx = {}, my $netc = {}, my $intf = {});

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

sub ask_language() {
    require lang;
    my $locale = lang::read();
    any__selectLanguage_and_more_standalone($in, $locale);
    lang::write($locale);
    lang__set($locale);
    Gtk2->set_locale;
}

sub ask_keyboard() {
    require keyboard;
    my $keyboard = keyboard::read();

  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::setxkbmap($keyboard);
    eval {
	my $xfree_conf = Xconfig::xfree->read;
	my $xkb = keyboard::keyboard2full_xkb($keyboard);
	$xfree_conf->set_keyboard($xkb);
	$xfree_conf->write;
    };

    keyboard::write($keyboard);
    system('/etc/init.d/keytable', 'restart');
}

sub ask_network() {
    my $modules_conf = modules::any_conf->read;
    modules::load_category($modules_conf, 'net');

    require network::netconnect;
    network::netconnect::real_main('', $netcnx, $in, $modules_conf, $netc, undef, $intf);
}

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

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

    eval { 
	authentication::set($in, $netc, $authentication);
	network::network::write_conf($netc);
    };
    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 ($f_name) = @_;
    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('ask_language');
call('ask_keyboard');
call('ask_network');
$::WizardWindow->destroy; undef $::WizardWindow;
$::Wizard_pix_up = 'redhat-config-users';
call('ask_authentication');
call('ask_users');
setVarsInSh('/etc/sysconfig/finish-install', { FINISH_INSTALL => 'no' });

$in->exit(0);


sub lang__set {
    my ($locale) = @_;
    put_in_hash(\%ENV, lang::i18n_env($locale));
    lang::bindtextdomain();
}

sub any__selectLanguage_and_more_standalone {
    my ($in, $locale) = @_;
    eval {
	local $::isWizard = 1;
      language:
	# keep around previous settings so that selectLanguage can keep UTF-8 flag:
	local $::Wizard_no_previous = 1;
	my $old_lang = $locale->{lang};
	$in->{locale} = $locale;
	$locale->{lang} = any::selectLanguage($in, $locale->{lang});
	$locale->{IM} = lang::get_default_im($locale->{lang}) if $old_lang ne $locale->{lang};
	undef $::Wizard_no_previous;
	any::selectCountry($in, $locale) or goto language;
    };
    if ($@) {
	if ($@ =~ /^one lang only/) {
	    any::selectCountry($in, $locale) or $in->exit(0);
	} elsif ($@ !~ /wizcancel/) {
	    die;
	} else {
	    $in->exit(0);
	}
    }
}