diff options
Diffstat (limited to 'perl-install/standalone/finish-install')
-rwxr-xr-x | perl-install/standalone/finish-install | 117 |
1 files changed, 92 insertions, 25 deletions
diff --git a/perl-install/standalone/finish-install b/perl-install/standalone/finish-install index 662bcc60d..81a2f00e5 100755 --- a/perl-install/standalone/finish-install +++ b/perl-install/standalone/finish-install @@ -12,6 +12,7 @@ use any; use authentication; use network::network; use security::level; +use messages; my $conf_file = '/etc/sysconfig/finish-install'; my %conf = getVarsFromSh($conf_file); @@ -19,11 +20,14 @@ my $authentication = authentication::get(); my $security = security::level::get(); my $net = {}; my $locale; +my $timezone; network::network::read_net_conf($net); $::isWizard = 1; -my $in = 'interactive'->vnew; -$in->{no_Window_Manager} = 1; +my $in = 'interactive'->vnew('su'); +$in->{untranslated_license} = messages::main_license_raw(); + +any::set_wm_hints_if_needed($in); sub get_conf { my ($name) = @_; @@ -39,11 +43,12 @@ sub ask_language() { require lang; $locale = lang::read(); my ($lang) = cat_("/proc/cmdline") =~ /\blang=(.+?)\b/; - if ($lang && member($lang, lang::list_langs(exclude_non_installed => 1))) { - put_in_hash($locale, lang::lang_to_ourlocale($lang)); + my $h = lang::lang_to_ourlocale($lang); + if ($lang && member($h->{lang}, lang::list_langs(exclude_non_installed => 1))) { + put_in_hash($locale, $h); lang::set($locale); } - any::selectLanguage_and_more_standalone($in, $locale); + any::selectLanguage_standalone($in, $locale); lang::write_and_install($locale, $in->do_pkgs); } @@ -53,7 +58,7 @@ sub ask_keyboard() { choose: $keyboard->{KEYBOARD} = $in->ask_from_listf(N("Keyboard"), - N("Please, choose your keyboard layout."), + N("Please choose your keyboard layout."), sub { translate(keyboard::KEYBOARD2text($_[0])) }, [ keyboard::KEYBOARDs() ], $keyboard->{KEYBOARD}) or return; @@ -66,21 +71,54 @@ sub ask_keyboard() { #- TIMEZONE=simplified: do not ask timezone and make ntp settings advanced sub ask_timezone() { require timezone; - my $t = timezone::read(); - $t->{timezone} = timezone::bestTimezone($locale->{country}) if $locale->{country}; - if (lc(get_conf('TIMEZONE')) eq 'simplified') { - any::configure_time_more($in, $t, 'hide_ntp'); - } else { - any::configure_timezone($in, $t, 'ask_gmt'); - } - timezone::write($t); + $timezone = timezone::read(); + $timezone->{timezone} = timezone::bestTimezone($locale->{country}) if $locale->{country}; + any::configure_timezone($in, $timezone, 'ask_gmt', lc(get_conf('TIMEZONE')) eq 'simplified'); + + $in->do_pkgs->ensure_is_installed('chrony') if $timezone->{ntp}; + timezone::write($timezone); + #- reload sys clock from hc once we know the real timezone - timezone::reload_sys_clock($t); + timezone::reload_sys_clock($timezone); +} + +#- COUNTRY=simplified: guess the country from timezone, do not ask +sub ask_country() { + require lang; + $locale ||= lang::read(); + require Time::ZoneInfo; + my $zones = Time::ZoneInfo->new; + if ($timezone && $zones) { + #- guess only if timezone has been asked already + if (my $zone = $zones->current_zone) { + if (my $country_code = $zones->country($zone)) { + $locale->{country} = $country_code; + } + } + } + any::selectCountry($in, $locale) if lc(get_conf('COUNTRY')) ne 'simplified'; + lang::write_and_install($locale, $in->do_pkgs); } sub ask_network() { require network::tools; + require services; return if network::tools::has_network_connection(); + + #- test again connection after waiting for network up + my $w = $in->wait_message(N("Please wait"), N("Testing your connection...")); + if (services::starts_on_boot('NetworkManager')) { + my $time = 0; + while ($time < 20 && run_program::get_stdout('systemctl show -p SubState NetworkManager-wait-online') =~ /start/) { + $time++; + sleep(1); + } + } else { + services::start('network-up'); + } + undef $w; + return if network::tools::has_network_connection(); + require network::netconnect; my $modules_conf = modules::any_conf->read; network::netconnect::real_main($net, $in, $modules_conf); @@ -88,8 +126,10 @@ sub ask_network() { } sub ask_urpmi() { - #- configure urpmi media if no media are configured - run_program::get_stdout('urpmq', '--list-media') and return; + #- configure urpmi media if no online media are configured + my @media_url = map { top(split(' ', $_)) } run_program::get_stdout('urpmq', '--list-url'); + my @online_media = grep { !m,^(?:file://)?/, } @media_url; + @online_media and return; any::urpmi_add_all_media($in); } @@ -125,25 +165,49 @@ sub ask_users() { $users->[0]{home} ||= '/home/' . $users->[0]{name}; } my $autologin = any::get_autologin(); - my $autologin_first = ($autologin->{autologin} eq $old_user || lc(get_conf('USER_AUTOLOGIN_FIRST')) eq "yes") && $autologin->{desktop}; + my $autologin_first = ($autologin->{user} eq $old_user || lc(get_conf('USER_AUTOLOGIN_FIRST')) eq "yes") && $autologin->{desktop}; if ($superuser) { set_authentication($superuser) or goto &ask_users; } any::add_users($users, $authentication); - any::set_autologin($in->do_pkgs, $users->[0]{name}, $autologin_first) - if $autologin_first; + if ($autologin_first) { + $autologin->{user} = $users->[0]{name}; + $autologin->{desktop} = $autologin_first; + any::set_autologin($in->do_pkgs, $autologin); + } + my $finit_conf = "/etc/finit.conf"; + substInFile { + s/^user .*//; + $_ .= "user $users->[0]{name}\n" if eof; + } $finit_conf if -e $finit_conf; if ($old_user) { + my $new_user = $users->[0]{name}; #- replace home path in user config files my $old_home = "/home/$old_user"; - my $new_home = "/home/$users->[0]{name}"; - run_program::run(qq(grep -rl $old_home $new_home/.??* | while read f; do perl -pi -e 's,$old_home,$new_home,g' "\$f"; done)); + my $new_home = "/home/$new_user"; + run_program::run(qq(grep -D skip -rl $old_home $new_home/.??* | while read f; do perl -pi -e 's,$old_home,$new_home,g' "\$f"; done)); + #- give console rights for current session + my $console_dir = "/var/run/console"; + cp_f($console_dir . "/" . $old_user, $console_dir . "/" . $new_user) if -e $console_dir . "/" . $old_user; + #- update user name in network configurations + #- for now, only support the case of a single user name + require services; + my $using_networkmanager = services::is_service_running('NetworkManager'); + foreach my $f (glob('/etc/sysconfig/network-scripts/ifcfg-*')) { + if (cat_($f) =~ /\nUSERS=$old_user\n/) { + run_program::run('perl', '-pi', '-e', "s,^USERS=$old_user,USERS=$new_user,", $f); + run_program::run('nmcli', 'con', 'load', $f) if $using_networkmanager; + } + } } } sub ask_glx() { require Xconfig::glx; - my $glx = Xconfig::glx::detect_may_install($in); - if ($glx->{supported} && Xconfig::glx::choose_interactive($in, $glx)) { + my @installed_types = Xconfig::glx::filter_installed_types(\@Xconfig::glx::gl_compositing_types); + any { $_->{type} ne "none" } @installed_types or return; + my $glx = Xconfig::glx::detect_may_install($in->do_pkgs); + if ($glx->{supported} && Xconfig::glx::choose_interactive($in, $glx, 'installed_only')) { Xconfig::glx::write($glx); } } @@ -175,6 +239,7 @@ sub encrypt_home { s/^volume $user->{name}.*//; $_ .= "volume $user->{name} crypt - $device $home - - -\n" if eof; } $::prefix . '/etc/security/pam_mount.conf'; + authentication::set_pam_authentication('mount'); run_program::raw({ root => $::prefix, sensitive_arguments => 1 }, @@ -206,6 +271,7 @@ sub encrypt_home { run_program::rooted($::prefix, 'umount', $home); run_program::rooted($::prefix, 'cryptsetup', 'luksClose', $user->{name}); + undef $wait; } sub call { @@ -225,8 +291,9 @@ call('language'); call('license'); # "Previous" button isn't functiunnal and acts like "next" (#25349) $::Wizard_no_previous = 1; -call('keyboard'); call('timezone'); +call('country'); +call('keyboard'); call('network'); if (defined $::WizardWindow) { $::WizardWindow->destroy; |