[ Agent ] [ Base ] - nfs-server nfs

This commit is contained in:
zeaslity
2023-11-21 17:13:31 +08:00
parent 48e8a6c951
commit 55d0772d50
5 changed files with 191 additions and 6 deletions

View File

@@ -77,6 +77,12 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) (bool,
case "installHelm":
resultOk, errorLog = op.installHelmExec()
break
case "installNfsOnline":
resultOk, errorLog = op.installNfsOnlineExec()
break
case "installNfsServerOnline":
resultOk, errorLog = op.installNfsServerOnlineExec()
break
case "installHarbor":
resultOk, errorLog = op.installHarborExec()
break
@@ -989,6 +995,80 @@ func (op *AgentOsOperator) modifyDockerConfigExec(args []string) (bool, []string
return true, nil
}
func (op *AgentOsOperator) installNfsOnlineExec() (bool, []string) {
if op.IsOsTypeUbuntu {
// ubuntu
installOk, installLog := BasicInstallSoftwares(op.InstallCommandPrefix, false,
"nfs-common", "nfs-client", "nfs")
if !installOk {
return false, installLog
}
ok, resultLog := BasicSystemdUp("nfs")
if !ok {
return false, append(resultLog, "[installNfsOnlineExec] - start nfs-common.service failed !")
}
}
return true, nil
}
func (op *AgentOsOperator) installNfsServerOnlineExec() (bool, []string) {
// os
if op.IsOsTypeUbuntu {
// ubuntu
installOk, installLog := BasicInstallSoftwares(op.InstallCommandPrefix, true, "nfs-kernel-server",
"nfs-common")
if !installOk {
return false, installLog
}
if !PureResultSingleExecuteBatch([][]string{
{"mkdir", "-p", nfsDataPath},
{"chmod", "777", nfsDataPath},
}) {
return false, []string{
"[installNfsServerOnlineExec]- create nfs data folder failed !",
}
}
if !BasicGrepItemInFile(nfsDataPath, "/etc/exports") {
log.DebugF("[installNfsServerOnlineExec]- add nfs path to /etc/exports !")
nfsExport := nfsDataPath + " *(rw,no_root_squash,no_all_squash,sync)"
if !BasicAppendContentToFile(nfsExport, "/etc/exports") {
return false, []string{
"[installNfsServerOnlineExec]- add nfs path to /etc/exports failed !",
}
}
}
// restart nfs-server
AllCompleteExecutor([][]string{
{
"systemctl",
"restart",
"nfs-server",
},
{
"systemctl",
"restart",
"nf",
},
})
ok, i := HardCodeCommandExecutor("rpcinfo -p localhost")
if !ok {
return false, append(i,
"installNfsServerOnlineExec] - rpc info error !",
"please check nfs server installation")
}
}
return true, nil
}
func (op *AgentOsOperator) installHarbor() [][]string {
installHarborFunc := [][]string{