diff --git a/pkg/systemd/parser/unitfile.go b/pkg/systemd/parser/unitfile.go index dadd7d849d..bfa850219c 100644 --- a/pkg/systemd/parser/unitfile.go +++ b/pkg/systemd/parser/unitfile.go @@ -7,6 +7,7 @@ import ( "os" "os/user" "path" + "path/filepath" "strconv" "strings" "unicode" @@ -919,3 +920,13 @@ func (f *UnitFile) PrependComment(groupName string, comments ...string) { group.prependComment(newUnitLine("", "# "+comments[i], true)) } } + +func (f *UnitFile) GetTemplateParts() (string, string) { + ext := filepath.Ext(f.Filename) + basename := strings.TrimSuffix(f.Filename, ext) + parts := strings.SplitN(basename, "@", 2) + if len(parts) < 2 { + return "", "" + } + return parts[0] + "@" + ext, parts[1] +}