summaryrefslogtreecommitdiff
path: root/src/manifest.rs
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 02:51:50 +0000
committerHermes Agent <hermes@localhost>2026-08-12 02:51:50 +0000
commit5384232eec4dff669cd2bb68ee93c34b6b63c78c (patch)
treede303d2741202c98ebc4b11af09ba1aab690eb6d /src/manifest.rs
parent450a5b27e101e7b40cd2d035056c4141e9477f6a (diff)
Collect services from all systemd targets
Diffstat (limited to 'src/manifest.rs')
-rw-r--r--src/manifest.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/manifest.rs b/src/manifest.rs
index b3e489d..3c34ade 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -170,15 +170,26 @@ fn collect_files(rootfs: &Path) -> Result<Vec<FileRecord>> {
}
fn collect_services(rootfs: &Path) -> Result<Vec<ServiceRecord>> {
- let wants = rootfs.join("etc/systemd/system/multi-user.target.wants");
- if !wants.exists() {
+ let system = rootfs.join("etc/systemd/system");
+ if !system.is_dir() {
return Ok(Vec::new());
}
let mut services = Vec::new();
- for entry in fs::read_dir(&wants).with_context(|| format!("read service state directory {}", wants.display()))? {
- let entry = entry?;
- let name = entry.file_name().into_string().map_err(|_| anyhow::anyhow!("non-UTF-8 service name in {}", wants.display()))?;
- if entry.file_type()?.is_symlink() && name.ends_with(".service") {
+ for entry in WalkDir::new(&system).follow_links(false).min_depth(2) {
+ let entry = entry.with_context(|| format!("walk service state directory {}", system.display()))?;
+ let parent_is_wants_directory = entry
+ .path()
+ .parent()
+ .and_then(Path::file_name)
+ .is_some_and(|name| name.to_string_lossy().ends_with(".target.wants"));
+ if !parent_is_wants_directory || !entry.file_type().is_symlink() {
+ continue;
+ }
+ let name = entry
+ .file_name()
+ .to_str()
+ .ok_or_else(|| anyhow::anyhow!("non-UTF-8 service name in {}", entry.path().display()))?;
+ if name.ends_with(".service") {
services.push(ServiceRecord::new(name, true));
}
}