From 5878dc4ae6d8dec9cb60f7afea28de5494bded2b Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Mon, 22 Apr 2024 14:11:07 +0200 Subject: [PATCH] auto-installer: handle auto-reboot info messages directly Signed-off-by: Christoph Heiss Signed-off-by: Thomas Lamprecht --- .../src/bin/proxmox-auto-installer.rs | 10 +++++++++- proxmox-auto-installer/src/utils.rs | 7 ++++++- .../tests/resources/parse_answer/disk_match.json | 2 +- .../tests/resources/parse_answer/disk_match_all.json | 2 +- .../tests/resources/parse_answer/disk_match_any.json | 2 +- .../tests/resources/parse_answer/minimal.json | 2 +- .../tests/resources/parse_answer/nic_matching.json | 2 +- .../tests/resources/parse_answer/specific_nic.json | 2 +- .../tests/resources/parse_answer/zfs.json | 2 +- 9 files changed, 22 insertions(+), 9 deletions(-) diff --git a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs index 6e4848c..f961a80 100644 --- a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs +++ b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs @@ -5,6 +5,8 @@ use std::{ io::{BufRead, BufReader, Write}, path::PathBuf, process::ExitCode, + thread, + time::Duration, }; use proxmox_installer_common::setup::{ @@ -94,6 +96,11 @@ fn main() -> ExitCode { // TODO: (optionally) do a HTTP post with basic system info, like host SSH public key(s) here + for secs in (0..=5).rev() { + info!("Installation finished - auto-rebooting in {secs} seconds .."); + thread::sleep(Duration::from_secs(1)); + } + ExitCode::SUCCESS } @@ -170,7 +177,8 @@ fn run_installation( if state == "err" { bail!("{message}"); } - info!("Finished: '{state}' {message}"); + // Do not print anything if the installation was successful, + // as we handle that here ourselves } }; } diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs index b1d60cb..168e5cb 100644 --- a/proxmox-auto-installer/src/utils.rs +++ b/proxmox-auto-installer/src/utils.rs @@ -368,7 +368,7 @@ pub fn parse_answer( verify_locale_settings(answer, locales)?; let mut config = InstallConfig { - autoreboot: 1_usize, + autoreboot: 0, filesys: filesystem, hdsize: 0., swapsize: None, @@ -426,6 +426,11 @@ pub fn parse_answer( .unwrap_or(runtime_info.disks[first_selected_disk].size); } } + + // never print the auto reboot text after finishing to avoid the delay, as this is handled by + // the auto-installer itself anyway. The auto-installer might still perform some post-install + // steps after running the low-level installer. + config.autoreboot = 0; Ok(config) } diff --git a/proxmox-auto-installer/tests/resources/parse_answer/disk_match.json b/proxmox-auto-installer/tests/resources/parse_answer/disk_match.json index f228b1e..bc19d88 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/disk_match.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/disk_match.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "192.168.1.114/24", "country": "at", "dns": "192.168.1.254", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/disk_match_all.json b/proxmox-auto-installer/tests/resources/parse_answer/disk_match_all.json index 2990922..ce2071e 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/disk_match_all.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/disk_match_all.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "192.168.1.114/24", "country": "at", "dns": "192.168.1.254", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/disk_match_any.json b/proxmox-auto-installer/tests/resources/parse_answer/disk_match_any.json index 8c22300..ae4debe 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/disk_match_any.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/disk_match_any.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "192.168.1.114/24", "country": "at", "dns": "192.168.1.254", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/minimal.json b/proxmox-auto-installer/tests/resources/parse_answer/minimal.json index 9021377..4312ccd 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/minimal.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/minimal.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "192.168.1.114/24", "country": "at", "dns": "192.168.1.254", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/nic_matching.json b/proxmox-auto-installer/tests/resources/parse_answer/nic_matching.json index 6f31079..6d16a3a 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/nic_matching.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/nic_matching.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "10.10.10.10/24", "country": "at", "dns": "10.10.10.1", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/specific_nic.json b/proxmox-auto-installer/tests/resources/parse_answer/specific_nic.json index 515cc89..51ab029 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/specific_nic.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/specific_nic.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "10.10.10.10/24", "country": "at", "dns": "10.10.10.1", diff --git a/proxmox-auto-installer/tests/resources/parse_answer/zfs.json b/proxmox-auto-installer/tests/resources/parse_answer/zfs.json index c29a303..0580482 100644 --- a/proxmox-auto-installer/tests/resources/parse_answer/zfs.json +++ b/proxmox-auto-installer/tests/resources/parse_answer/zfs.json @@ -1,5 +1,5 @@ { - "autoreboot": 1, + "autoreboot": 0, "cidr": "192.168.1.114/24", "country": "at", "dns": "192.168.1.254", -- 2.39.5