Skip to content

Commit

Permalink
isactive() correction
Browse files Browse the repository at this point in the history
  • Loading branch information
gwbres committed May 30, 2022
1 parent c9b9f7e commit c73aa99
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn status (unit: &str) -> std::io::Result<String> { systemctl_capture(vec!["
/// Returns `true` if given `unit` is actively running
pub fn is_active (unit: &str) -> std::io::Result<bool> {
let status = systemctl_capture(vec!["is-active", unit])?;
Ok(status.contains("active"))
Ok(!status.contains("inactive"))
}

/// Returns list of units extracted from systemctl listing.
Expand Down Expand Up @@ -363,7 +363,8 @@ mod test {
fn test_is_active() {
let active = is_active("sshd");
assert_eq!(active.is_ok(), true);
println!("sshd active: {:#?}", active)
let active = is_active("dropbear");
assert_eq!(active.is_ok(), true);
}
#[test]
fn test_disabled_services() {
Expand Down

0 comments on commit c73aa99

Please sign in to comment.