]> git.proxmox.com Git - pve-installer.git/commitdiff
low-level, tui: count down auto-reboot timeout
authorChristoph Heiss <c.heiss@proxmox.com>
Fri, 10 Nov 2023 14:17:26 +0000 (15:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 11 Nov 2023 13:08:41 +0000 (14:08 +0100)
The GUI installer already has the same functionality, with this the TUI
installer gains the same. It is a nice touch anyway, primarily to
indicate to the user that the installer is not frozen or similar.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-low-level-installer
proxmox-tui-installer/src/views/install_progress.rs

index b8269d7bd195e24434b90720b9e3a402258c10bb..9b4b773b6626982fbfc6907636c84fef4060731e 100755 (executable)
@@ -69,6 +69,19 @@ sub read_and_merge_config {
     log_info("got installation config: ". to_json(Proxmox::Install::Config::get(), { utf8 => 1, canonical => 1 }) ."\n");
 }
 
+sub send_reboot_ui_message {
+    if (Proxmox::Install::Config::get_autoreboot()) {
+       my $secs = 5;
+       while ($secs > 0) {
+           Proxmox::UI::finished(1, "Installation finished - auto-rebooting in $secs seconds ..");
+           sleep 1;
+           $secs -= 1;
+       }
+    } else {
+       Proxmox::UI::finished(1, "Installation complete - reboot now?");
+    }
+}
+
 my $cmd = shift;
 if (!$cmd || $cmd eq 'help' || !exists($commands->{$cmd})) {
     usage($cmd // '');
@@ -115,11 +128,7 @@ if ($cmd eq 'dump-env') {
            Proxmox::UI::finished(0, $err);
        }
     } else {
-       if (Proxmox::Install::Config::get_autoreboot()) {
-           Proxmox::UI::finished(1, "Installation finished - auto-rebooting in ~ 5 seconds");
-       } else {
-           Proxmox::UI::finished(1, "Installation complete - reboot now?");
-       }
+       send_reboot_ui_message();
     }
 } elsif ($cmd eq 'start-session-test') {
     Proxmox::UI::init_stdio({}, $env);
@@ -137,11 +146,7 @@ if ($cmd eq 'dump-env') {
        }
     }
 
-    if (Proxmox::Install::Config::get_autoreboot()) {
-       Proxmox::UI::finished(1, "Installation finished - auto-rebooting in ~ 5 seconds");
-    } else {
-       Proxmox::UI::finished(1, "Installation complete - reboot now?");
-    }
+    send_reboot_ui_message();
 }
 
 exit(0);
index 96e62f83eb0ff418f425a369b350204d2ffba4a5..76dd518502a283f4d0e4c2b84764843a6afc7548 100644 (file)
@@ -8,7 +8,7 @@ use std::{
 
 use cursive::{
     utils::Counter,
-    view::{Resizable, ViewWrapper},
+    view::{Nameable, Resizable, ViewWrapper},
     views::{Dialog, DummyView, LinearLayout, PaddedView, ProgressBar, TextContent, TextView},
     CbSink, Cursive,
 };
@@ -153,14 +153,22 @@ impl InstallProgressView {
     }
 
     fn prepare_for_reboot(siv: &mut Cursive, success: bool, msg: &str) {
+        const DIALOG_ID: &str = "autoreboot-dialog";
         let title = if success { "Success" } else { "Failure" };
 
+        // If the dialog was previously created, just update its content and we're done.
+        if let Some(mut dialog) = siv.find_name::<Dialog>(DIALOG_ID) {
+            dialog.set_content(TextView::new(msg));
+            return;
+        }
+
         // For rebooting, we just need to quit the installer,
         // our caller does the actual reboot.
         siv.add_layer(
             Dialog::text(msg)
                 .title(title)
-                .button("Reboot now", Cursive::quit),
+                .button("Reboot now", Cursive::quit)
+                .with_name(DIALOG_ID),
         );
 
         let autoreboot = siv