bootc_lib/bootc_composefs/
service.rs

1use anyhow::{Context, Result};
2use fn_error_context::context;
3use std::process::Command;
4
5use crate::composefs_consts::BOOTC_FINALIZE_STAGED_SERVICE;
6
7/// Starts the finaize staged service which will "unstage" the deployment
8/// This is called before an upgrade or switch operation, as these create a staged
9/// deployment
10#[context("Starting finalize staged service")]
11pub(crate) fn start_finalize_stated_svc() -> Result<()> {
12    let cmd_status = Command::new("systemctl")
13        .args(["start", "--quiet", BOOTC_FINALIZE_STAGED_SERVICE])
14        .status()
15        .context("Starting finalize service")?;
16
17    if !cmd_status.success() {
18        anyhow::bail!("systemctl exited with status {cmd_status}")
19    }
20
21    Ok(())
22}