fix(systemd): include service user in service file generation

* Add ServiceUser field to Config struct for user specification.
* Update Generate and Install functions to accept service user.
* Modify tests to reflect changes in service user handling.
This commit is contained in:
Hein
2026-04-08 13:30:07 +02:00
parent e4d6f3a4a2
commit d8c90e4fff
5 changed files with 31 additions and 15 deletions

View File

@@ -31,7 +31,7 @@ func runInstall(cmd *cobra.Command, args []string) error {
return err
}
prefix, suffix := cfg.Prefix, cfg.Suffix
prefix, suffix, serviceUser := cfg.Prefix, cfg.Suffix, cfg.EffectiveServiceUser()
installed := 0
skipped := 0
removed := 0
@@ -57,7 +57,7 @@ func runInstall(cmd *cobra.Command, args []string) error {
}
if dryRun {
content, err := systemd.Generate(u, prefix, suffix)
content, err := systemd.Generate(u, prefix, suffix, serviceUser)
if err != nil {
fmt.Printf(" ✗ %s: %v\n", u.Name, err)
continue
@@ -68,7 +68,7 @@ func runInstall(cmd *cobra.Command, args []string) error {
continue
}
if err := systemd.Install(u, prefix, suffix); err != nil {
if err := systemd.Install(u, prefix, suffix, serviceUser); err != nil {
fmt.Printf(" ✗ failed: %s: %v\n", u.Name, err)
} else {
path, _ := systemd.UnitPath(u, prefix, suffix)