Add prefix/suffix support, short ID fallback, unit docs
- config: add Prefix/Suffix fields to Config struct - systemd: ServiceName/Generate/UnitPath/Install/Uninstall/Enable/Disable/Status all accept prefix+suffix - runtime: fall back to short container ID (12 chars) when container has no name - cmd: active, status, install all thread prefix/suffix from config - systemd/generator_test.go: updated all calls + added TestGenerate_WithPrefixSuffix - docs/generated-units.md: full examples of every unit type + ordering + naming - README: updated config docs, prefix/suffix section, link to docs/
This commit is contained in:
@@ -27,6 +27,8 @@ func runActive(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
prefix, suffix := cfg.Prefix, cfg.Suffix
|
||||
|
||||
// Sort by order then name for deterministic startup sequence
|
||||
units := make([]config.Unit, len(cfg.Units))
|
||||
copy(units, cfg.Units)
|
||||
@@ -44,12 +46,12 @@ func runActive(cmd *cobra.Command, args []string) error {
|
||||
if !u.Enabled {
|
||||
continue
|
||||
}
|
||||
if !systemd.IsInstalled(u) {
|
||||
if !systemd.IsInstalled(u, prefix, suffix) {
|
||||
fmt.Printf(" ! %s: not installed — run 'unitdore install' first\n", u.Name)
|
||||
continue
|
||||
}
|
||||
fmt.Printf(" ▶ enabling: %s...\n", systemd.ServiceName(u))
|
||||
if err := systemd.Enable(u); err != nil {
|
||||
fmt.Printf(" ▶ enabling: %s...\n", systemd.ServiceName(u, prefix, suffix))
|
||||
if err := systemd.Enable(u, prefix, suffix); err != nil {
|
||||
fmt.Printf(" ✗ failed: %s: %v\n", u.Name, err)
|
||||
failed++
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user