(keyword string)
| 272 | } |
| 273 | |
| 274 | func GetScriptName(keyword string) (string, error) { |
| 275 | client, err := New() |
| 276 | if err != nil { |
| 277 | return "", err |
| 278 | } |
| 279 | switch client.Name() { |
| 280 | case "systemd": |
| 281 | keyword = strings.TrimSuffix(keyword, ".service") + ".service" |
| 282 | case "openrc", "sysvinit": |
| 283 | lastDotIdx := strings.LastIndex(keyword, ".") |
| 284 | if lastDotIdx != -1 { |
| 285 | keyword = keyword[:lastDotIdx] |
| 286 | } |
| 287 | default: |
| 288 | return "", fmt.Errorf("unsupported manager: %s", client.Name()) |
| 289 | } |
| 290 | return keyword, nil |
| 291 | } |