systemctl
Small rust crate to interact with systemd units
Environment
SYSTEMCTL_PATH
custom env. variable describes the absolute
location path of systemctl
binary, by default this crate uses /usr/bin/systemctl
,
but that can be customized:
SYSTEMCTL_PATH=/home/$me/bin/systemctl cargo build
Unit / service operation
Nominal service operations:
.unwrap;
restart
.unwrap;
if let Ok = exists
stop
Service enumeration
use systemctl;
// list all units
list_units;
// list all services
// by adding a --type filter
list_units;
// list all services currently `enabled`
// by adding a --state filter
list_units;
// list all services starting with cron
list_units;
Unit structure
Use the unit structure for more information
let unit = from_systemctl
.unwrap;
unit.restart.unwrap;
println!;
println!;
if let Some = unit.docs
println!;
println!;
println!;
println!;
println!;
TODO
- parse all known attributes in
from_systemctl