检查Systemd服务
(message *pb.NodeStreamMessage)
| 339 | |
| 340 | // 检查Systemd服务 |
| 341 | func (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 | // 检查本地防火墙 |
| 369 | func (this *APIStream) handleCheckLocalFirewall(message *pb.NodeStreamMessage) error { |