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

Function SelectInitScript

agent/utils/controller/controller.go:252–272  ·  view source on GitHub ↗
(keyword string)

Source from the content-addressed store, hash-verified

250}
251
252func SelectInitScript(keyword string) (string, error) {
253 client, err := New()
254 if err != nil {
255 return "", err
256 }
257 switch client.Name() {
258 case "systemd":
259 keyword = strings.TrimSuffix(keyword, ".service") + ".service"
260 case "openrc":
261 keyword = strings.TrimSuffix(keyword, ".service") + ".openrc"
262 case "sysvinit":
263 if _, err := os.Stat("/etc/rc.common"); err == nil {
264 keyword = strings.TrimSuffix(keyword, ".service") + ".procd"
265 } else {
266 keyword = strings.TrimSuffix(keyword, ".service") + ".init"
267 }
268 default:
269 return "", fmt.Errorf("unsupported manager: %s", client.Name())
270 }
271 return keyword, nil
272}
273
274func GetScriptName(keyword string) (string, error) {
275 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