[Agent] [Executor] 重写BaseFunction

This commit is contained in:
zeaslity
2023-10-16 15:34:06 +08:00
parent 020fc76e05
commit db58a7a6f6
3 changed files with 192 additions and 6 deletions

View File

@@ -30,10 +30,15 @@ func BasicCommandExistsBatch(commandNameList []string) (bool, string) {
// BasicReplace 基础替换命令
func BasicReplace(filename string, origin string, replace string) bool {
// 暂不添加
//if !BasicFileExistAndNotNull(filename) {
// log.DebugF("文件替换")
//}
cmd := exec.Command("sed", "-i", "s/"+origin+"/"+replace+"/g", filename)
err := cmd.Run()
if err != nil {
log.DebugF("文件 %s [%s] => [%s] 错误!", filename, origin, replace)
log.DebugF("替换文件 %s ,从 [%s] => [%s] 错误!", filename, origin, replace)
return false
} else {
return true