]> git.proxmox.com Git - pve-installer.git/commitdiff
auto installer: make fetch print answer to stdout and explicitly run installer
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 19 Apr 2024 10:59:13 +0000 (12:59 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 22 Apr 2024 12:31:37 +0000 (14:31 +0200)
Instead of executing the actual installer from inside a tool named
`fetch-answer` make it print the answer file content it queried to
stdout and use the outer "unconfigured" init process to redirect this
to a file inside run, which is then piped to the actual installer in a
separate command.

This makes the execution flow a bit easier to grasp when reading
unconfigured and allows to inspect the answer file in a debug session.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-fetch-answer/src/main.rs
unconfigured.sh

index 7fe4bcc2e3ab332e943821059b167ff983e11a8c..29cd78e6546ff4e53436fd11026beb0b23c0bcfe 100644 (file)
@@ -1,5 +1,4 @@
-use std::io::Write;
-use std::process::{Command, ExitCode, Stdio};
+use std::process::ExitCode;
 use std::{fs, path::PathBuf};
 
 use anyhow::{anyhow, Error, Result};
@@ -83,35 +82,9 @@ fn main() -> ExitCode {
             return ExitCode::FAILURE;
         }
     };
+    info!("queried answer file for automatic installation successfully");
 
-    let mut child = match Command::new("proxmox-auto-installer")
-        .stdout(Stdio::inherit())
-        .stdin(Stdio::piped())
-        .stderr(Stdio::null())
-        .spawn()
-    {
-        Ok(child) => child,
-        Err(err) => panic!("Failed to start automatic installation: {err}"),
-    };
-
-    let mut stdin = child.stdin.take().expect("Failed to open stdin");
-    std::thread::spawn(move || {
-        stdin
-            .write_all(answer.as_bytes())
-            .expect("Failed to write to stdin");
-    });
+    println!("{answer}");
 
-    match child.wait() {
-        Ok(status) => {
-            if status.success() {
-                ExitCode::SUCCESS
-            } else {
-                ExitCode::FAILURE // Will be trapped
-            }
-        }
-        Err(err) => {
-            error!("Auto installer exited: {err}");
-            ExitCode::FAILURE
-        }
-    }
+    return ExitCode::SUCCESS;
 }
index dbdb0278a3ba621e7b60c8b8b9ee7fbc09274ad2..d83086d06d76199e9bde964cd555a6b8d7c7e012 100755 (executable)
@@ -238,9 +238,12 @@ if [ $proxtui -ne 0 ]; then
     echo "Starting the TUI installer"
     /usr/bin/proxmox-tui-installer 2>/dev/tty2
 elif [ $proxauto -ne 0 ]; then
+    echo "Caching device info from udev"
     /usr/bin/proxmox-low-level-installer dump-udev
+    echo "Fetching answers for automatic installation"
+    /usr/bin/proxmox-fetch-answer >/run/automatic-installer-answers
     echo "Starting automatic installation"
-    /usr/bin/proxmox-fetch-answer
+    /usr/bin/proxmox-auto-installer </run/automatic-installer-answers
 else
     echo "Starting the installer GUI - see tty2 (CTRL+ALT+F2) for any errors..."
     xinit -- -dpi "$DPI" -s 0 >/dev/tty2 2>&1