[Excution] - base function accomplish - 4
This commit is contained in:
@@ -3,11 +3,12 @@ package executor
|
||||
import (
|
||||
"agent-go/g"
|
||||
"agent-go/register"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type BaseFunc interface {
|
||||
Exec(baseFuncName string, funcArgs ...string) string
|
||||
Exec(baseFuncName string, funcArgs ...string) []string
|
||||
}
|
||||
|
||||
type AgentOsOperator struct {
|
||||
@@ -25,11 +26,11 @@ type AgentOsOperator struct {
|
||||
|
||||
AgentOSReleaseCode string `json:"agent_os_release_code",comment:"主机操作系统的发行版代号, focal之类的"`
|
||||
|
||||
AgentServerInfo register.AgentServerInfo `json:"agent_server_info"`
|
||||
AgentServerInfo *register.AgentServerInfo `json:"agent_server_info"`
|
||||
}
|
||||
|
||||
// Exec 执行基础功能函数
|
||||
func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) string {
|
||||
func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) []string {
|
||||
|
||||
var multiLineCommand [][]string
|
||||
|
||||
@@ -90,13 +91,21 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) string
|
||||
|
||||
log.DebugF("multiLineCommand are => %v", multiLineCommand)
|
||||
|
||||
var result []string
|
||||
|
||||
// exec the command here
|
||||
for _, singleLineCommand := range multiLineCommand {
|
||||
ReadTimeCommandExecutor(singleLineCommand)
|
||||
result = append(result, ReadTimeCommandExecutor(singleLineCommand)...)
|
||||
}
|
||||
|
||||
// debug usage
|
||||
//log.DebugF("exec result are => %v", result)
|
||||
for _, logLine := range result {
|
||||
fmt.Println(logLine)
|
||||
}
|
||||
|
||||
// 归一化处理
|
||||
return strings.Join([]string{}, "")
|
||||
return result
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) shutdownFirewall() [][]string {
|
||||
@@ -628,6 +637,11 @@ func (op *AgentOsOperator) chronyToMaster(args []string) [][]string {
|
||||
func (op *AgentOsOperator) installZSH() [][]string {
|
||||
|
||||
installZSHFunc := [][]string{
|
||||
{
|
||||
"mkdir",
|
||||
"-p",
|
||||
"/root/wdd/",
|
||||
},
|
||||
append(
|
||||
op.InstallCommandPrefix,
|
||||
"zsh",
|
||||
@@ -643,7 +657,7 @@ func (op *AgentOsOperator) installZSH() [][]string {
|
||||
"wget",
|
||||
"https://cdn.jsdelivr.net/gh/robbyrussell/oh-my-zsh@master/tools/install.sh",
|
||||
"-O",
|
||||
"zsh-install.sh",
|
||||
"/root/wdd/zsh-install.sh",
|
||||
},
|
||||
}...,
|
||||
)
|
||||
@@ -656,7 +670,7 @@ func (op *AgentOsOperator) installZSH() [][]string {
|
||||
"wget",
|
||||
"https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh",
|
||||
"-O",
|
||||
"zsh-install.sh",
|
||||
"/root/wdd/zsh-install.sh",
|
||||
},
|
||||
}...,
|
||||
)
|
||||
@@ -669,12 +683,12 @@ func (op *AgentOsOperator) installZSH() [][]string {
|
||||
{
|
||||
"chmod",
|
||||
"+x",
|
||||
"zsh-install.sh",
|
||||
"/root/wdd/zsh-install.sh",
|
||||
},
|
||||
{
|
||||
"sh",
|
||||
"-c",
|
||||
"./zsh-install.sh",
|
||||
"/root/wdd/zsh-install.sh",
|
||||
},
|
||||
}...,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user