[agent][deploy] - jxejpt;; fix srs part

This commit is contained in:
zeaslity
2024-09-27 14:34:09 +08:00
parent 25ce18638b
commit 327d12f789
24 changed files with 13727 additions and 339 deletions

View File

@@ -211,14 +211,12 @@ func (op *AgentOsOperator) shutdownFirewall() [][]string {
}
if !op.IsOsTypeUbuntu {
shutdownFunc = append(shutdownFunc,
[]string{
"sed",
"-i",
"s/SELINUX=enforcing/SELINUX=disabled/g",
"/etc/selinux/config",
},
)
shutdownFunc = append(shutdownFunc, []string{
"sed",
"-i",
"s/SELINUX=enforcing/SELINUX=disabled/g",
"/etc/selinux/config",
})
}
return shutdownFunc
@@ -255,12 +253,11 @@ func (op *AgentOsOperator) modifyHostname(args []string) [][]string {
func (op *AgentOsOperator) modifyHostnameExec(args []string) (bool, []string) {
ok, resultLog := AllCommandExecutor(
[]string{
"hostnamectl",
"set-hostname",
args[0],
})
ok, resultLog := AllCommandExecutor([]string{
"hostnamectl",
"set-hostname",
args[0],
})
return ok, resultLog
}
@@ -349,19 +346,18 @@ func (op *AgentOsOperator) disableSwapExec() (bool, []string) {
})
}
// 执行关闭操作
AllCompleteExecutor(
[][]string{
{
"swapoff",
"-a",
},
{
"sed",
"-i",
"/swap/d",
"/etc/fstab",
},
})
AllCompleteExecutor([][]string{
{
"swapoff",
"-a",
},
{
"sed",
"-i",
"/swap/d",
"/etc/fstab",
},
})
return true, nil
}
@@ -507,8 +503,7 @@ func (op *AgentOsOperator) removeDocker() [][]string {
removeDockerLine := append(op.RemoveCommandPrefix, []string{
"docker-ce",
"docker.io",
"docker-ce-cli",
//"docker",
"docker-ce-cli", //"docker",
//"docker-common",
//"docker-latest",
//"docker-latest-logrotate",
@@ -672,24 +667,14 @@ func (op *AgentOsOperator) installDocker(args []string) [][]string {
specificDockerVersion = "5:20.10.10~3-0~ubuntu-" + op.AgentOSReleaseCode
}
installDockerFunc = append(installDockerFunc,
append(
op.InstallCommandPrefix,
"docker-ce="+specificDockerVersion,
"docker-ce-cli="+specificDockerVersion,
"containerd.io",
"docker-compose-plugin",
),
)
installDockerFunc = append(installDockerFunc, append(op.InstallCommandPrefix, "docker-ce="+specificDockerVersion, "docker-ce-cli="+specificDockerVersion, "containerd.io", "docker-compose-plugin"))
} else {
installFirstLine := append(op.InstallCommandPrefix,
[]string{
"yum-utils",
"device-mapper-persistent-data",
"lvm2",
}...,
)
installFirstLine := append(op.InstallCommandPrefix, []string{
"yum-utils",
"device-mapper-persistent-data",
"lvm2",
}...)
if op.IsAgentInnerWall {
// inner gfw
@@ -810,8 +795,7 @@ func (op *AgentOsOperator) installDockerExec(args []string) (bool, []string) {
"chmod",
"a+r",
dockerGPGFilePath,
},
//{
}, //{
// "add-apt-repository",
// "deb [arch=" + op.AgentArch + " signed-by=" + dockerGPGFilePath + " ] " + dockerAPTSource + " " + op.AgentOSReleaseCode + " stable",
//},
@@ -868,8 +852,7 @@ func (op *AgentOsOperator) installDockerExec(args []string) (bool, []string) {
}
for _, s := range dockerStaffList {
resultOk, log2 = AllCommandExecutor(
append(op.InstallCommandPrefix, s))
resultOk, log2 = AllCommandExecutor(append(op.InstallCommandPrefix, s))
if !resultOk {
return false, append(log2, s, "安装失败!")
}
@@ -917,13 +900,11 @@ func (op *AgentOsOperator) installDockerExec(args []string) (bool, []string) {
AllCommandExecutor(append(op.InstallCommandPrefix, "yum-utils"))
ok, resultLog := AllCommandExecutor(
[]string{
"yum-config-manager",
"--add-repo",
dockerRepo,
},
)
ok, resultLog := AllCommandExecutor([]string{
"yum-config-manager",
"--add-repo",
dockerRepo,
})
if !ok {
return false, resultLog
}
@@ -963,6 +944,13 @@ func (op *AgentOsOperator) InstallDockerBastion() (bool, []string) {
BasicRemoveFolderComplete("/root/wdd/docker")
dockerLocalFile := OctopusAgentInstallPrefix + dockerOfflineFileName
// 下载
if op.CanAccessInternet {
log.Info("[InstallDockerBastion] - start to download docker offline file!")
BasicDownloadFile(op.OssOfflinePrefix+dockerOfflineFileName, "", "", "", dockerLocalFile)
}
if !BasicFileExistAndNotNull(dockerLocalFile) {
sprintf := fmt.Sprintf("docker offline file not exists ! => %s", dockerLocalFile)
log.Error(sprintf)
@@ -1079,10 +1067,7 @@ func (op *AgentOsOperator) InstallDockerBastion() (bool, []string) {
func (op *AgentOsOperator) removeDockerCompose() [][]string {
installDockerComposeFunc := [][]string{
append(
op.RemoveCommandPrefix,
"docker-compose",
),
append(op.RemoveCommandPrefix, "docker-compose"),
}
return installDockerComposeFunc
@@ -1114,10 +1099,7 @@ func (op *AgentOsOperator) removeDockerComposeExec() (bool, []string) {
func (op *AgentOsOperator) installDockerCompose() [][]string {
installDockerComposeFunc := [][]string{
append(
op.InstallCommandPrefix,
"docker-compose",
),
append(op.InstallCommandPrefix, "docker-compose"),
}
return installDockerComposeFunc
@@ -1411,8 +1393,7 @@ func (op *AgentOsOperator) installNfsOnlineExec() (bool, []string) {
if op.IsOsTypeUbuntu {
// ubuntu
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, false,
"nfs-common", "nfs-client", "nfs")
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, false, "nfs-common", "nfs-client", "nfs")
if !installOk {
return false, installLog
}
@@ -1424,8 +1405,7 @@ func (op *AgentOsOperator) installNfsOnlineExec() (bool, []string) {
} else if op.IsOsTypeCentOS {
// centos
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, false,
"nfs-utils")
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, false, "nfs-utils")
if !installOk {
return false, installLog
}
@@ -1520,8 +1500,7 @@ func (op *AgentOsOperator) installNfsServerOnlineExec() (bool, []string) {
// os
if op.IsOsTypeUbuntu {
// ubuntu
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, true, "nfs-kernel-server",
"nfs-common")
installOk, installLog := BasicInstallSoftware(op.InstallCommandPrefix, true, "nfs-kernel-server", "nfs-common")
if !installOk {
return false, installLog
}
@@ -1559,9 +1538,7 @@ func (op *AgentOsOperator) installNfsServerOnlineExec() (bool, []string) {
ok, i := HardCodeCommandExecutor("rpcinfo -p localhost")
if !ok {
return false, append(i,
"installNfsServerOnlineExec] - rpc info error !",
"please check nfs server installation")
return false, append(i, "installNfsServerOnlineExec] - rpc info error !", "please check nfs server installation")
}
return true, nil
@@ -1625,9 +1602,7 @@ func (op *AgentOsOperator) installNFSServerOfflineExec() (bool, []string) {
// install
if op.IsOsTypeUbuntu {
BasicPrettyPrint(HardCodeCommandExecutor(
"dpkg -i /root/wdd/tmp/nfs-server/*.deb",
))
BasicPrettyPrint(HardCodeCommandExecutor("dpkg -i /root/wdd/tmp/nfs-server/*.deb"))
up, resultLog := BasicSystemdUp("nfs-kernel-server")
if !up {
@@ -1637,9 +1612,7 @@ func (op *AgentOsOperator) installNFSServerOfflineExec() (bool, []string) {
}
} else if op.IsOsTypeCentOS {
BasicPrettyPrint(HardCodeCommandExecutor(
"rpm -ivh /root/wdd/tmp/nfs-server/*.rpm",
))
BasicPrettyPrint(HardCodeCommandExecutor("rpm -ivh /root/wdd/tmp/nfs-server/*.rpm"))
// restart nfs-server
up, resultLog := BasicSystemdUp("rpcbind")
@@ -1658,9 +1631,7 @@ func (op *AgentOsOperator) installNFSServerOfflineExec() (bool, []string) {
rpcinfoOK, i := HardCodeCommandExecutor("rpcinfo -p localhost")
if !rpcinfoOK {
return false, append(i,
"[installNFSServerOfflineExec] - rpc info error !",
"please check nfs server installation")
return false, append(i, "[installNFSServerOfflineExec] - rpc info error !", "please check nfs server installation")
}
return true, []string{
@@ -1867,8 +1838,7 @@ func (op *AgentOsOperator) installHarborAndConfig() (bool, []string) {
executor := ReadTimeCommandExecutor([]string{
"bash",
"/root/wdd/harbor/install.sh",
},
)
})
if !executor {
return false, []string{
"[install harbor] - harbor start FAILED !",
@@ -2033,10 +2003,7 @@ func (op *AgentOsOperator) chronyToPublicNTP() [][]string {
internalIPCIDR := strings.Join(strings.Split(serverIPInV4, ".")[:2], ".") + ".0.0/16"
chronyToPublicNTPFunc := [][]string{
append(
op.InstallCommandPrefix,
"chrony",
),
append(op.InstallCommandPrefix, "chrony"),
{
"systemctl",
"enable",
@@ -2056,56 +2023,54 @@ func (op *AgentOsOperator) chronyToPublicNTP() [][]string {
chronyFile = "/etc/chrony.conf"
}
chronyToPublicNTPFunc = append(chronyToPublicNTPFunc,
[][]string{
{
"sed",
"-i",
"$ a allow " + internalIPCIDR,
chronyFile,
},
{
"sed",
"-i",
"s/pool ntp.ubuntu.com iburst/server ntp2.aliyun.com iburst/g",
chronyFile,
},
{
"systemctl",
"restart",
"chronyd",
},
{
"sleep",
"2",
},
{
"chronyc",
"-n",
"sources",
"-v",
},
{
"chronyc",
"tracking",
},
{
"timedatectl",
"set-timezone",
"Asia/Shanghai",
},
{
"timedatectl",
"set-ntp",
"true",
},
{
"systemctl",
"restart",
"rsyslog",
},
}...,
)
chronyToPublicNTPFunc = append(chronyToPublicNTPFunc, [][]string{
{
"sed",
"-i",
"$ a allow " + internalIPCIDR,
chronyFile,
},
{
"sed",
"-i",
"s/pool ntp.ubuntu.com iburst/server ntp2.aliyun.com iburst/g",
chronyFile,
},
{
"systemctl",
"restart",
"chronyd",
},
{
"sleep",
"2",
},
{
"chronyc",
"-n",
"sources",
"-v",
},
{
"chronyc",
"tracking",
},
{
"timedatectl",
"set-timezone",
"Asia/Shanghai",
},
{
"timedatectl",
"set-ntp",
"true",
},
{
"systemctl",
"restart",
"rsyslog",
},
}...)
return chronyToPublicNTPFunc
}
@@ -2182,12 +2147,7 @@ func (op *AgentOsOperator) installChronyExec() (bool, []string) {
}
// install chrony
resultOk, l := AllCommandExecutor(
append(
op.InstallCommandPrefix,
"chrony",
),
)
resultOk, l := AllCommandExecutor(append(op.InstallCommandPrefix, "chrony"))
if !resultOk {
return false, l
}
@@ -2428,120 +2388,104 @@ func (op *AgentOsOperator) installZSH() [][]string {
"-p",
OctopusAgentInstallPrefix,
},
append(
op.InstallCommandPrefix,
"zsh",
"git",
),
append(op.InstallCommandPrefix, "zsh", "git"),
}
if op.IsAgentInnerWall {
installZSHFunc = append(
installZSHFunc,
[][]string{
{
"wget",
"https://cdn.jsdelivr.net/gh/robbyrussell/oh-my-zsh@master/tools/install.sh",
"-O",
"/root/wdd/zsh-install.sh",
},
}...,
)
installZSHFunc = append(installZSHFunc, [][]string{
{
"wget",
"https://cdn.jsdelivr.net/gh/robbyrussell/oh-my-zsh@master/tools/install.sh",
"-O",
"/root/wdd/zsh-install.sh",
},
}...)
} else {
installZSHFunc = append(
installZSHFunc,
[][]string{
{
"wget",
"https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh",
"-O",
"/root/wdd/zsh-install.sh",
},
}...,
)
installZSHFunc = append(installZSHFunc, [][]string{
{
"wget",
"https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh",
"-O",
"/root/wdd/zsh-install.sh",
},
}...)
}
// install
installZSHFunc = append(
installZSHFunc,
[][]string{
{
"chmod",
"+x",
"/root/wdd/zsh-install.sh",
},
{
"sh",
"-c",
"/root/wdd/zsh-install.sh",
},
}...,
)
installZSHFunc = append(installZSHFunc, [][]string{
{
"chmod",
"+x",
"/root/wdd/zsh-install.sh",
},
{
"sh",
"-c",
"/root/wdd/zsh-install.sh",
},
}...)
// modify ZSH
if !op.IsAgentInnerWall {
installZSHFunc = append(
installZSHFunc,
[][]string{
{
"git",
"clone",
"https://github.com/zsh-users/zsh-autosuggestions",
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
},
{
"git",
"clone",
"https://github.com/zsh-users/zsh-syntax-highlighting.git",
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
},
{
"wget",
"https://b2.107421.xyz/oh-my-zsh-plugins-list.txt",
"-O",
"oh-my-zsh-plugins-list.txt",
},
{
"wget",
"-c",
"-i",
"./oh-my-zsh-plugins-list.txt",
"-P",
"/root/.oh-my-zsh/plugins/",
},
{
"sed",
"-i",
"s/robbyrussell/agnoster/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/^# DISABLE_AUTO_UPDATE=\"true\"/DISABLE_AUTO_UPDATE=\"true\"/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting command-not-found z themes)/g",
"/root/.zshrc",
},
{
"source",
"/root/.zshrc",
},
{
"chsh",
"-s",
"/bin/zsh",
},
{
"zsh",
},
}...,
)
installZSHFunc = append(installZSHFunc, [][]string{
{
"git",
"clone",
"https://github.com/zsh-users/zsh-autosuggestions",
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
},
{
"git",
"clone",
"https://github.com/zsh-users/zsh-syntax-highlighting.git",
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
},
{
"wget",
"https://b2.107421.xyz/oh-my-zsh-plugins-list.txt",
"-O",
"oh-my-zsh-plugins-list.txt",
},
{
"wget",
"-c",
"-i",
"./oh-my-zsh-plugins-list.txt",
"-P",
"/root/.oh-my-zsh/plugins/",
},
{
"sed",
"-i",
"s/robbyrussell/agnoster/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/^# DISABLE_AUTO_UPDATE=\"true\"/DISABLE_AUTO_UPDATE=\"true\"/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting command-not-found z themes)/g",
"/root/.zshrc",
},
{
"source",
"/root/.zshrc",
},
{
"chsh",
"-s",
"/bin/zsh",
},
{
"zsh",
},
}...)
}
return installZSHFunc
@@ -2562,8 +2506,7 @@ func (op *AgentOsOperator) installZSHExec() (bool, []string) {
BasicRemoveFolderComplete("/root/wdd/oh-my-zsh-plugins-list.txt")
BasicCreateFolder(OctopusAgentInstallPrefix)
ok, resultLog := AllCommandExecutor(
append(op.InstallCommandPrefix, "zsh", "git"))
ok, resultLog := AllCommandExecutor(append(op.InstallCommandPrefix, "zsh", "git"))
if !ok {
return false, resultLog
}
@@ -2594,8 +2537,7 @@ func (op *AgentOsOperator) installZSHExec() (bool, []string) {
"/root/wdd/zsh-install.sh",
"REMOTE=https://gitee.com/mirrors/oh-my-zsh.git",
},
},
)
})
if !executor {
return false, log2
}
@@ -2608,61 +2550,60 @@ func (op *AgentOsOperator) installZSHExec() (bool, []string) {
zshHighLightingSourcePath = "https://gitee.com/xiaoqqya/zsh-syntax-highlighting.git"
}
modifyZSHOK, log3 := AllCompleteExecutor(
[][]string{
{
"git",
"clone",
zshAutoSourcePath,
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
},
{
"git",
"clone",
zshHighLightingSourcePath,
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
},
{
"wget",
op.OssOfflinePrefix + "oh-my-zsh-plugins-list.txt",
"-O",
"/root/wdd/oh-my-zsh-plugins-list.txt",
},
{
"wget",
"-c",
"-i",
"/root/wdd/oh-my-zsh-plugins-list.txt",
"-P",
"/root/.oh-my-zsh/plugins/",
},
{
"sed",
"-i",
"s/robbyrussell/agnoster/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/^# DISABLE_AUTO_UPDATE=\"true\"/DISABLE_AUTO_UPDATE=\"true\"/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting command-not-found z themes)/g",
"/root/.zshrc",
},
{
"chsh",
"-s",
"/bin/zsh",
},
{
"zsh",
},
})
modifyZSHOK, log3 := AllCompleteExecutor([][]string{
{
"git",
"clone",
zshAutoSourcePath,
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
},
{
"git",
"clone",
zshHighLightingSourcePath,
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
},
{
"wget",
op.OssOfflinePrefix + "oh-my-zsh-plugins-list.txt",
"-O",
"/root/wdd/oh-my-zsh-plugins-list.txt",
},
{
"wget",
"-c",
"-i",
"/root/wdd/oh-my-zsh-plugins-list.txt",
"-P",
"/root/.oh-my-zsh/plugins/",
},
{
"sed",
"-i",
"s/robbyrussell/agnoster/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/^# DISABLE_AUTO_UPDATE=\"true\"/DISABLE_AUTO_UPDATE=\"true\"/g",
"/root/.zshrc",
},
{
"sed",
"-i",
"s/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting command-not-found z themes)/g",
"/root/.zshrc",
},
{
"chsh",
"-s",
"/bin/zsh",
},
{
"zsh",
},
})
if !modifyZSHOK {
log.Warn("ZSH 安装成功,但是配置修改失败!")
return true, log3