forked from lix-project/lix-installer
Make systemd unit start detect already running unit (#240)
* Make systemd unit start detect already running unit * Prod CI * Fixup messaging * Reflect comments
This commit is contained in:
parent
ab4c528595
commit
fc13c1d250
|
@ -21,12 +21,27 @@ impl StartSystemdUnit {
|
|||
unit: impl AsRef<str>,
|
||||
enable: bool,
|
||||
) -> Result<StatefulAction<Self>, ActionError> {
|
||||
let unit = unit.as_ref();
|
||||
let output = Command::new("systemctl")
|
||||
.arg("is-active")
|
||||
.arg(unit)
|
||||
.output()
|
||||
.await
|
||||
.map_err(ActionError::Command)?;
|
||||
|
||||
let state = if output.status.success() {
|
||||
tracing::debug!("Starting systemd unit `{}` already complete", unit);
|
||||
ActionState::Skipped
|
||||
} else {
|
||||
ActionState::Uncompleted
|
||||
};
|
||||
|
||||
Ok(StatefulAction {
|
||||
action: Self {
|
||||
unit: unit.as_ref().to_string(),
|
||||
unit: unit.to_string(),
|
||||
enable,
|
||||
},
|
||||
state: ActionState::Uncompleted,
|
||||
state,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue