fix: stand down when started after boot finished
This commit is contained in:
1 parent
63d76d9630
commit
74af283d57
2 files changed
+16
-1
No files matched your search
@@ -44,5 +44,12 @@
|
|||||||
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
|
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
|
||||||
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
|
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
|
||||||
machine.screenshot("handed-over")
|
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
@@ -27,7 +27,7 @@ use crate::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
feed::Feed,
|
feed::Feed,
|
||||||
sysroot::INITRD_RELEASE,
|
sysroot::INITRD_RELEASE,
|
||||||
systemd::Scope,
|
systemd::{Scope, Session},
|
||||||
};
|
};
|
||||||
|
|
||||||
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
|
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
|
||||||
@@ -43,6 +43,14 @@ pub struct Options {
|
|||||||
pub fn run(options: &Options) -> Result<(), Error> {
|
pub fn run(options: &Options) -> Result<(), Error> {
|
||||||
let terminate = Arc::new(AtomicBool::new(false));
|
let terminate = Arc::new(AtomicBool::new(false));
|
||||||
flag::register(SIGTERM, Arc::clone(&terminate))?;
|
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 {
|
let phase = match options.scope {
|
||||||
Scope::User => Phase::User,
|
Scope::User => Phase::User,
|
||||||
Scope::System if Path::new(INITRD_RELEASE).exists() => Phase::Initrd,
|
Scope::System if Path::new(INITRD_RELEASE).exists() => Phase::Initrd,
|
||||||
|
|||||||
Reference in new issue
Block a user