From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CF1D5A120A for ; Fri, 10 Nov 2023 15:17:33 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9B6F91D07 for ; Fri, 10 Nov 2023 15:17:33 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 10 Nov 2023 15:17:32 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 505EC47B47 for ; Fri, 10 Nov 2023 15:17:32 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Fri, 10 Nov 2023 15:17:26 +0100 Message-ID: <20231110141727.597039-9-c.heiss@proxmox.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231110141727.597039-1-c.heiss@proxmox.com> References: <20231110141727.597039-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.014 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer v2 8/8] low-level, tui: count down auto-reboot timeout X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2023 14:17:33 -0000 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 --- Changes v1 -> v2: * no changes proxmox-low-level-installer | 25 +++++++++++-------- .../src/views/install_progress.rs | 12 +++++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/proxmox-low-level-installer b/proxmox-low-level-installer index b8269d7..9b4b773 100755 --- a/proxmox-low-level-installer +++ b/proxmox-low-level-installer @@ -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); diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs index 96e62f8..76dd518 100644 --- a/proxmox-tui-installer/src/views/install_progress.rs +++ b/proxmox-tui-installer/src/views/install_progress.rs @@ -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_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 -- 2.42.0