fix: stand down when started after boot finished

This commit is contained in:
Willem Vanhulle committed 2026-10-11 16:21:21 +02:00
1 parent 63d76d9630
commit 74af283d57
2 files changed
+16 -1

No files matched your search

+7
View File
@@ -44,5 +44,12 @@
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
machine.screenshot("handed-over")
foreground = machine.succeed("cat /sys/class/tty/tty0/active").strip()
machine.succeed("systemctl restart bootvine")
machine.wait_until_succeeds("systemctl show -p ActiveState --value bootvine | grep -qx inactive", timeout=10)
assert "boot already finished" in machine.succeed("journalctl -u bootvine -o cat"), "a restart after boot did not stand down"
still_foreground = machine.succeed("cat /sys/class/tty/tty0/active").strip()
assert still_foreground == foreground, f"a restart after boot took the console: {foreground} -> {still_foreground}"
'';
}
+9 -1
View File
@@ -27,7 +27,7 @@ use crate::{
error::Error,
feed::Feed,
sysroot::INITRD_RELEASE,
systemd::Scope,
systemd::{Scope, Session},
};
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
@@ -43,6 +43,14 @@ pub struct Options {
pub fn run(options: &Options) -> Result<(), Error> {
let terminate = Arc::new(AtomicBool::new(false));
flag::register(SIGTERM, Arc::clone(&terminate))?;
if options.scope == Scope::System
&& Session::open(Scope::System)
.and_then(|session| session.boot_in_progress())
.is_ok_and(|booting| !booting)
{
eprintln!("bootvine: boot already finished, leaving the console alone");
return Ok(());
}
let phase = match options.scope {
Scope::User => Phase::User,
Scope::System if Path::new(INITRD_RELEASE).exists() => Phase::Initrd,