[ Agent ] [ Executor ] - add systemc shutdown service

This commit is contained in:
zeaslity
2023-10-19 15:10:59 +08:00
parent 8bb7604169
commit 328247eeae
4 changed files with 100 additions and 0 deletions

View File

@@ -87,6 +87,46 @@ func BasicPrettyPrint(resultOk bool, resultLog []string) {
}
}
func BasicSystemdShutdown(serviceName string) (ok bool, resultLog []string) {
if !strings.HasSuffix(serviceName, ".service") {
serviceName = serviceName + ".service"
}
// 检查是否存在
execute := PureResultSingleExecute(
[]string{
"systemctl",
"status",
"-q",
serviceName,
})
if !execute {
return true, []string{
serviceName,
"该服务器不存在!",
}
}
// 关闭
var shutDownCommand = [][]string{
{
"systemctl",
"stop",
serviceName,
},
{
"systemctl",
"disable",
serviceName,
},
}
resultOK := PureResultSingleExecuteBatch(shutDownCommand)
return resultOK, resultLog
}
func BasicTransPipelineCommand(pipelineString string) (pipelineCommand [][]string) {
var pipelineCommandC [][]string