(keyword string)
| 296 | } |
| 297 | |
| 298 | func GetScriptName(keyword string) (string, error) { |
| 299 | client, err := New() |
| 300 | if err != nil { |
| 301 | return "", err |
| 302 | } |
| 303 | switch client.Name() { |
| 304 | case "systemd": |
| 305 | keyword = strings.TrimSuffix(keyword, ".service") + ".service" |
| 306 | case "openrc", "sysvinit": |
| 307 | lastDotIdx := strings.LastIndex(keyword, ".") |
| 308 | if lastDotIdx != -1 { |
| 309 | keyword = keyword[:lastDotIdx] |
| 310 | } |
| 311 | default: |
| 312 | return "", fmt.Errorf("unsupported manager: %s", client.Name()) |
| 313 | } |
| 314 | return keyword, nil |
| 315 | } |