MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / handleCheckSystemdService

Method handleCheckSystemdService

internal/nodes/api_stream.go:341–366  ·  view source on GitHub ↗

检查Systemd服务

(message *pb.NodeStreamMessage)

Source from the content-addressed store, hash-verified

339
340// 检查Systemd服务
341func (this *APIStream) handleCheckSystemdService(message *pb.NodeStreamMessage) error {
342 systemctl, err := executils.LookPath("systemctl")
343 if err != nil {
344 this.replyFail(message.RequestId, "'systemctl' not found")
345 return nil
346 }
347 if len(systemctl) == 0 {
348 this.replyFail(message.RequestId, "'systemctl' not found")
349 return nil
350 }
351
352 var shortName = teaconst.SystemdServiceName
353 var cmd = executils.NewTimeoutCmd(10*time.Second, systemctl, "is-enabled", shortName)
354 cmd.WithStdout()
355 err = cmd.Run()
356 if err != nil {
357 this.replyFail(message.RequestId, "'systemctl' command error: "+err.Error())
358 return nil
359 }
360 if cmd.Stdout() == "enabled" {
361 this.replyOk(message.RequestId, "ok")
362 } else {
363 this.replyFail(message.RequestId, "not installed")
364 }
365 return nil
366}
367
368// 检查本地防火墙
369func (this *APIStream) handleCheckLocalFirewall(message *pb.NodeStreamMessage) error {

Callers 1

loopMethod · 0.95

Calls 6

replyFailMethod · 0.95
replyOkMethod · 0.95
WithStdoutMethod · 0.80
StdoutMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected