Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ where
fn check_previous_rollback() -> Result<bool> {
log::debug!("Checking journalctl for previous rollback attempts...");

// Use systemd's first-boot detection to skip the rollback check on first boot.
// This is more reliable than journalctl --list-boots, which would also skip
// on systems with non-persistent journald storage.
let first_boot_check = Command::new("systemd-analyze")
.arg("condition")
.arg("ConditionFirstBoot=yes")
.output()
.context("Failed to execute 'systemd-analyze condition ConditionFirstBoot=yes'")?;

if first_boot_check.status.success() {
log::debug!("First boot detected, skipping rollback check");
return Ok(false);
}

let output = Command::new("journalctl")
.arg("-b")
.arg("-1")
Expand All @@ -186,8 +200,7 @@ fn check_previous_rollback() -> Result<bool> {
return Ok(false);
}

let journal_output =
String::from_utf8(output.stdout).context("Failed to parse journalctl output as UTF-8")?;
let journal_output = String::from_utf8_lossy(&output.stdout);

if journal_output.trim().is_empty() {
log::debug!("No rollback service logs found in previous boot");
Expand Down
Loading