MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / SelectInitScript

Function SelectInitScript

core/utils/controller/controller.go:276–296  ·  view source on GitHub ↗
(keyword string)

Source from the content-addressed store, hash-verified

274}
275
276func SelectInitScript(keyword string) (string, error) {
277 client, err := New()
278 if err != nil {
279 return "", err
280 }
281 switch client.Name() {
282 case "systemd":
283 keyword = strings.TrimSuffix(keyword, ".service") + ".service"
284 case "openrc":
285 keyword = strings.TrimSuffix(keyword, ".service") + ".openrc"
286 case "sysvinit":
287 if _, err := os.Stat("/etc/rc.common"); err == nil {
288 keyword = strings.TrimSuffix(keyword, ".service") + ".procd"
289 } else {
290 keyword = strings.TrimSuffix(keyword, ".service") + ".init"
291 }
292 default:
293 return "", fmt.Errorf("unsupported manager: %s", client.Name())
294 }
295 return keyword, nil
296}
297
298func GetScriptName(keyword string) (string, error) {
299 client, err := New()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
NameMethod · 0.65
StatMethod · 0.45

Tested by

no test coverage detected