Skip to content

Commit

Permalink
add reload and reload-or-restart commands (#22)
Browse files Browse the repository at this point in the history
* add reload and reload-or-restart

* bump version
  • Loading branch information
Patrick Gray authored Oct 5, 2023
1 parent b81ebaf commit 035ca00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "systemctl"
version = "0.3.0"
version = "0.3.1"
license = "MIT OR Apache-2.0"
authors = ["Guillaume W. Bres <[email protected]>"]
description = "Small crate to interact with systemd units"
Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ pub fn stop(unit: &str) -> std::io::Result<ExitStatus> {
systemctl(vec!["stop", unit])
}

/// Triggers reload for given `unit`
pub fn reload(unit: &str) -> std::io::Result<ExitStatus> {
systemctl(vec!["reload", unit])
}

/// Triggers reload or restarts given `unit`
pub fn reload_or_restart(unit: &str) -> std::io::Result<ExitStatus> {
systemctl(vec!["reload-or-restart", unit])
}

/// Enable given `unit` to start at boot
pub fn enable(unit: &str) -> std::io::Result<ExitStatus> {
systemctl(vec!["enable", unit])
Expand Down Expand Up @@ -578,6 +588,16 @@ impl Unit {
stop(&self.name)
}

/// Reloads Self by invoking systemctl
pub fn reload(&self) -> std::io::Result<ExitStatus> {
reload(&self.name)
}

/// Reloads or restarts Self by invoking systemctl
pub fn reload_or_restart(&self) -> std::io::Result<ExitStatus> {
reload_or_restart(&self.name)
}

/// Enable Self to start at boot
pub fn enable(&self) -> std::io::Result<ExitStatus> {
enable(&self.name)
Expand Down

0 comments on commit 035ca00

Please sign in to comment.