systemctl
Small rust crate to interact with systemd units through systemctl
.
At the time I needed those features, I was not aware of zbus-systemd
, which is now available and should be prefered.
This crate uses systemctl
interaction directly, which is far from ideal for applications.
zbus-systemd
should therefore be prefered.
Features
- serde: Enable to make structs in this crate De-/Serializable
Limitations
Currently, systemd Version <245 are not supported as unit-file-list changed from two column to three column setup. See: systemd Changelog
Unit / service operation
Nominal service operations:
let systemctl = default;
systemctl.stop
.unwrap;
systemctl.restart
.unwrap;
if let Ok = systemctl.exists
Service enumeration
let systemctl = default;
// list all units
systemctl.list_units;
// list all services
// by adding a --type filter
systemctl.list_units;
// list all services currently `enabled`
// by adding a --state filter
systemctl.list_units;
// list all services starting with cron
systemctl.list_units;
// Check if a unit is active
systemctl.get_active_state;
// list dependencies of a service or target
systemctl.list_dependencies;
Unit structure
Use the unit structure for more information
let systemctl = default;
let unit = systemctl.create_unit
.unwrap;
systemctl.restart.unwrap;
println!;
println!;
if let Some = unit.docs
println!;
println!;
println!;
println!;
println!;
TODO
- parse all known attributes in
from_systemctl