[ Agent ] [ Executor ] - 优化基础脚本内容
This commit is contained in:
@@ -52,6 +52,7 @@ func BasicReplace(filename string, origin string, replace string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// BasicFileExists 检测文件是否存在
|
||||
func BasicFileExists(filename string) bool {
|
||||
|
||||
cmd := exec.Command("test", "-f", filename)
|
||||
@@ -77,6 +78,7 @@ func BasicFileExistAndNotNull(filename string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// BasicPrettyPrint 打印执行结果
|
||||
func BasicPrettyPrint(resultOk bool, resultLog []string) {
|
||||
fmt.Printf("resultOK is => %#v\n", resultOk)
|
||||
if resultLog == nil || len(resultLog) == 0 {
|
||||
@@ -87,6 +89,7 @@ func BasicPrettyPrint(resultOk bool, resultLog []string) {
|
||||
}
|
||||
}
|
||||
|
||||
// BasicSystemdShutdown 使用Systemd关闭服务,会判定服务器是否存在
|
||||
func BasicSystemdShutdown(serviceName string) (ok bool, resultLog []string) {
|
||||
|
||||
if !strings.HasSuffix(serviceName, ".service") {
|
||||
@@ -104,7 +107,8 @@ func BasicSystemdShutdown(serviceName string) (ok bool, resultLog []string) {
|
||||
for _, s := range systemdFilePath {
|
||||
resultOk, _ := PipelineCommandExecutor(
|
||||
[][]string{
|
||||
{"ls",
|
||||
{
|
||||
"ls",
|
||||
s,
|
||||
},
|
||||
{
|
||||
@@ -146,6 +150,7 @@ func BasicSystemdShutdown(serviceName string) (ok bool, resultLog []string) {
|
||||
return resultOK, resultLog
|
||||
}
|
||||
|
||||
// BasicSystemdUp 使用Systemd启动服务,会判定服务器是否存在
|
||||
func BasicSystemdUp(serviceName string) (ok bool, resultLog []string) {
|
||||
|
||||
if !strings.HasSuffix(serviceName, ".service") {
|
||||
@@ -205,6 +210,7 @@ func BasicSystemdUp(serviceName string) (ok bool, resultLog []string) {
|
||||
return resultOK, resultLog
|
||||
}
|
||||
|
||||
// BasicTransPipelineCommand 转换手写的管道命令为可执行的形式
|
||||
func BasicTransPipelineCommand(pipelineString string) (pipelineCommand [][]string) {
|
||||
|
||||
var pipelineCommandC [][]string
|
||||
|
||||
Reference in New Issue
Block a user