[ Agent ] [ Executor ] - 优化基础脚本内容
This commit is contained in:
@@ -4,14 +4,15 @@ import "strings"
|
||||
|
||||
func BuildAgentOsOperator(osInfo string, ossOfflinePrefix string) *AgentOsOperator {
|
||||
|
||||
// todo build from env
|
||||
AgentOsOperatorCache = &AgentOsOperator{
|
||||
InstallCommandPrefix: []string{
|
||||
"apt-get", "install", "-y",
|
||||
"apt-get", "install", "--allow-downgrades", "-y",
|
||||
},
|
||||
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
|
||||
CanAccessInternet: true,
|
||||
IsOsTypeUbuntu: true,
|
||||
IsAgentInnerWall: true,
|
||||
IsAgentInnerWall: false,
|
||||
AgentArch: "amd64",
|
||||
AgentOSReleaseCode: "focal",
|
||||
AgentServerInfo: nil,
|
||||
@@ -66,16 +67,41 @@ func detectByOsType(os *AgentOsOperator, osInfo string) {
|
||||
os.IsOsTypeUbuntu = true
|
||||
os.RemoveCommandPrefix = []string{"apt", "remove", "-y"}
|
||||
os.InstallCommandPrefix = []string{
|
||||
"apt-get", "install", "-y",
|
||||
"apt-get", "install", "--allow-downgrades", "-y",
|
||||
}
|
||||
|
||||
// os release code
|
||||
osRealseResult, _ := PipeLineCommandExecutor(ubuntuSsRealseCode)
|
||||
os.AgentOSReleaseCode = osRealseResult[0]
|
||||
osReleaseResult, _ := PipeLineCommandExecutor(ubuntuSsRealseCode)
|
||||
os.AgentOSReleaseCode = osReleaseResult[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func detectByInternet(os *AgentOsOperator) {
|
||||
|
||||
log.Info("开始检测Agent的网络连通情况!")
|
||||
|
||||
outsideTestUrl := "www.google.com"
|
||||
innerTestUrl := "www.baidu.com"
|
||||
|
||||
testInternetCommand := []string{
|
||||
"curl",
|
||||
"-o",
|
||||
"/dev/null",
|
||||
"-m",
|
||||
"5",
|
||||
"-s",
|
||||
}
|
||||
|
||||
if PureResultSingleExecute(append(testInternetCommand, outsideTestUrl)) {
|
||||
os.CanAccessInternet = true
|
||||
os.IsAgentInnerWall = false
|
||||
} else if PureResultSingleExecute(append(testInternetCommand, innerTestUrl)) {
|
||||
os.CanAccessInternet = true
|
||||
os.IsAgentInnerWall = true
|
||||
} else {
|
||||
os.CanAccessInternet = false
|
||||
os.IsAgentInnerWall = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user