[Excution] - base function start - 3
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"agent-go/g"
|
||||
"agent-go/register"
|
||||
"strings"
|
||||
)
|
||||
@@ -52,6 +53,9 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) string
|
||||
case "removeDocker":
|
||||
multiLineCommand = op.removeDocker()
|
||||
break
|
||||
case "removeDockerCompose":
|
||||
multiLineCommand = op.removeDockerCompose()
|
||||
break
|
||||
case "installDockerCompose":
|
||||
multiLineCommand = op.installDockerCompose()
|
||||
break
|
||||
@@ -329,11 +333,52 @@ func (op *AgentOsOperator) installDockerCompose() [][]string {
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) installHelm() [][]string {
|
||||
var installHelmFunc [][]string
|
||||
installHelmFunc := [][]string{
|
||||
{
|
||||
"mkdir",
|
||||
"-p",
|
||||
"/root/wdd/",
|
||||
},
|
||||
{
|
||||
"rm",
|
||||
"-rf",
|
||||
"/root/wdd/helm-v*",
|
||||
},
|
||||
{
|
||||
"rm",
|
||||
"-rf",
|
||||
"/root/wdd/linux-amd64",
|
||||
},
|
||||
{
|
||||
"wget",
|
||||
"--no-check-certificate",
|
||||
g.BaseFuncOssUrlPrefix + "helm-v3.12.1-linux-amd64.tar.gz",
|
||||
"-O",
|
||||
"/root/wdd/helm-v3.12.1-linux-amd64.tar.gz",
|
||||
},
|
||||
{
|
||||
"tar",
|
||||
"-zvxf",
|
||||
"/root/wdd/helm-v3.12.1-linux-amd64.tar.gz",
|
||||
},
|
||||
{
|
||||
"chmod",
|
||||
"+x",
|
||||
"/root/wdd/linux-amd64/helm",
|
||||
},
|
||||
{
|
||||
"mv",
|
||||
"/root/wdd/linux-amd64/helm",
|
||||
"/usr/local/bin/helm",
|
||||
},
|
||||
{
|
||||
"helm",
|
||||
"version",
|
||||
},
|
||||
}
|
||||
|
||||
if op.IsOsTypeUbuntu {
|
||||
/*if op.IsOsTypeUbuntu {
|
||||
installHelmFunc = [][]string{
|
||||
|
||||
{
|
||||
"curl",
|
||||
"-o",
|
||||
@@ -357,7 +402,7 @@ func (op *AgentOsOperator) installHelm() [][]string {
|
||||
}
|
||||
} else {
|
||||
log.ErrorF("Operation OS is CentOS, Helm not installed!")
|
||||
}
|
||||
}*/
|
||||
|
||||
return installHelmFunc
|
||||
}
|
||||
@@ -374,7 +419,7 @@ func (op *AgentOsOperator) modifyDockerConfig(args []string) [][]string {
|
||||
},
|
||||
{
|
||||
"wget",
|
||||
"https://oss2.demo.uavcmlc.com:18000/wangdada/daemon-config.json",
|
||||
g.BaseFuncOssUrlPrefix + "daemon-config.json",
|
||||
"-O",
|
||||
"/etc/docker/daemon.json",
|
||||
},
|
||||
@@ -397,50 +442,62 @@ func (op *AgentOsOperator) modifyDockerConfig(args []string) [][]string {
|
||||
func (op *AgentOsOperator) installHarbor(args []string) [][]string {
|
||||
|
||||
installHarborFunc := [][]string{
|
||||
{
|
||||
"wget",
|
||||
"--no-check-certificate",
|
||||
"https://oss2.demo.uavcmlc.com:18000/wangdada/harbor-offline-installer-v2.1.0.tgz",
|
||||
"-O",
|
||||
"harbor-offline-installer-v2.1.0.tgz",
|
||||
},
|
||||
//{
|
||||
// "mkdir",
|
||||
// "-p",
|
||||
// "/root/wdd/",
|
||||
//},
|
||||
//{
|
||||
// "rm",
|
||||
// "-rf",
|
||||
// "/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
//},
|
||||
//{
|
||||
// "wget",
|
||||
// "--no-check-certificate",
|
||||
// g.BaseFuncOssUrlPrefix + "harbor-offline-installer-v2.1.0.tgz",
|
||||
// "-O",
|
||||
// "/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
//},
|
||||
{
|
||||
"tar",
|
||||
"-zvxf",
|
||||
"harbor-offline-installer-v2.1.0.tgz",
|
||||
"/root/wdd/harbor-offline-installer-v2.1.0.tgz",
|
||||
"-C",
|
||||
"/root/wdd/",
|
||||
},
|
||||
{
|
||||
"rm",
|
||||
"-rf",
|
||||
"./harbor/harbor.yml",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"wget",
|
||||
"--no-check-certificate",
|
||||
"https://oss2.demo.uavcmlc.com:18000/wangdada/harbor.yml",
|
||||
g.BaseFuncOssUrlPrefix + "harbor-config-template.yml",
|
||||
"-O",
|
||||
"./harbor/harbor.yml",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"./harbor/harbor.yml",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborHostPort/8033/g",
|
||||
"./harbor/harbor.yml",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/$HarborHostPort/V2ryStr@ngPss/g",
|
||||
"./harbor/harbor.yml",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"./harbor/install.sh",
|
||||
"/root/wdd/harbor/install.sh",
|
||||
"--with-chartmuseum",
|
||||
},
|
||||
}
|
||||
@@ -488,7 +545,7 @@ func (op *AgentOsOperator) chronyToPublicNTP() [][]string {
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/server 0.centos.pool.ntp.org iburst/server ntp2.aliyun.com iburst/g",
|
||||
"s/pool ntp.ubuntu.com iburst/server ntp2.aliyun.com iburst/g",
|
||||
chronyFile,
|
||||
},
|
||||
{
|
||||
@@ -505,6 +562,8 @@ func (op *AgentOsOperator) chronyToPublicNTP() [][]string {
|
||||
"-n",
|
||||
"sources",
|
||||
"-v",
|
||||
},
|
||||
{
|
||||
"chronyc",
|
||||
"tracking",
|
||||
},
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package executor
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"agent-go/register"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var agentOP = AgentOsOperator{
|
||||
InstallCommandPrefix: []string{
|
||||
@@ -12,6 +15,30 @@ var agentOP = AgentOsOperator{
|
||||
IsAgentInnerWall: true,
|
||||
AgentArch: "amd64",
|
||||
AgentOSReleaseCode: "focal",
|
||||
AgentServerInfo: register.AgentServerInfo{
|
||||
ServerName: "",
|
||||
ServerIPPbV4: "",
|
||||
ServerIPInV4: "192.168.0.8",
|
||||
ServerIPPbV6: "",
|
||||
ServerIPInV6: "",
|
||||
Location: "",
|
||||
Provider: "",
|
||||
ManagePort: "",
|
||||
CPUCore: "",
|
||||
CPUBrand: "",
|
||||
OSInfo: "",
|
||||
OSKernelInfo: "",
|
||||
TCPControl: "",
|
||||
Virtualization: "",
|
||||
IoSpeed: "",
|
||||
MemoryTotal: "",
|
||||
DiskTotal: "",
|
||||
DiskUsage: "",
|
||||
Comment: "",
|
||||
MachineID: "",
|
||||
AgentVersion: "",
|
||||
TopicName: "",
|
||||
},
|
||||
}
|
||||
|
||||
func TestBaseFunc(t *testing.T) {
|
||||
@@ -22,11 +49,12 @@ func TestBaseFunc(t *testing.T) {
|
||||
//agentOP.Exec("enableSwap")
|
||||
//agentOP.Exec("removeDocker")
|
||||
//agentOP.Exec("installDocker", "20")
|
||||
agentOP.Exec("installDockerCompose")
|
||||
agentOP.Exec("installHelm")
|
||||
agentOP.Exec("installHarbor")
|
||||
agentOP.Exec("chronyToPublicNTP")
|
||||
agentOP.Exec("chronyToMaster", "192.168.0.8")
|
||||
//agentOP.Exec("removeDockerCompose")
|
||||
//agentOP.Exec("installDockerCompose")
|
||||
//agentOP.Exec("installHelm")
|
||||
//agentOP.Exec("installHarbor")
|
||||
//agentOP.Exec("chronyToPublicNTP")
|
||||
//agentOP.Exec("chronyToMaster", "192.168.0.8")
|
||||
agentOP.Exec("installZSH")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user