[ Agent ] [ App ] - offline installation chrony
This commit is contained in:
@@ -30,6 +30,9 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
var result []string
|
||||
|
||||
switch appFuncName {
|
||||
case "DEPLOY_CHRONY_SERVER":
|
||||
resultOK, result = op.installChronyByDockerExec(funcArgs)
|
||||
break
|
||||
case "DEPLOY_RKE":
|
||||
resultOK, result = op.deployRke(funcArgs)
|
||||
break
|
||||
|
||||
@@ -86,12 +86,6 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) (bool,
|
||||
case "installHarbor":
|
||||
resultOk, errorLog = op.installHarborExec()
|
||||
break
|
||||
case "installChrony":
|
||||
resultOk, errorLog = op.installChronyExec()
|
||||
break
|
||||
case "chronyToPublicNTP":
|
||||
resultOk, errorLog = op.chronyToPublicNTPExec()
|
||||
break
|
||||
case "chronyToMaster":
|
||||
resultOk, errorLog = op.chronyToMasterExec(funcArgs)
|
||||
break
|
||||
@@ -1752,10 +1746,6 @@ func (op *AgentOsOperator) installChronyExec() (bool, []string) {
|
||||
return false, resultLog
|
||||
}
|
||||
|
||||
if !op.IsOsTypeUbuntu || !op.CanAccessInternet {
|
||||
return op.installChronyByDockerExec()
|
||||
}
|
||||
|
||||
// install chrony
|
||||
resultOk, l := AllCommandExecutor(
|
||||
append(
|
||||
@@ -1784,7 +1774,7 @@ func (op *AgentOsOperator) installChronyExec() (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) installChronyByDockerExec() (bool, []string) {
|
||||
func (op *AgentOsOperator) installChronyByDockerExec(funcArgs []string) (bool, []string) {
|
||||
|
||||
// check docker
|
||||
if !BasicCommandExistByPath("docker") {
|
||||
@@ -1816,29 +1806,29 @@ func (op *AgentOsOperator) installChronyByDockerExec() (bool, []string) {
|
||||
return false, append(resultLog, "[installChronyByDockerExec] - docker chrony run error !")
|
||||
}
|
||||
|
||||
AllCommandExecutor([]string{
|
||||
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||
"docker",
|
||||
"exec",
|
||||
"chrony",
|
||||
"chronyc",
|
||||
"tracking",
|
||||
})
|
||||
}))
|
||||
|
||||
AllCommandExecutor([]string{
|
||||
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||
"docker",
|
||||
"exec",
|
||||
"chrony",
|
||||
"chronyc",
|
||||
"sources",
|
||||
})
|
||||
}))
|
||||
|
||||
AllCommandExecutor([]string{
|
||||
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||
"docker",
|
||||
"exec",
|
||||
"chrony",
|
||||
"chronyc",
|
||||
"sourcestats",
|
||||
})
|
||||
}))
|
||||
|
||||
return true, []string{
|
||||
"[installChronyByDockerExec] - install success !",
|
||||
@@ -1891,6 +1881,44 @@ func (op *AgentOsOperator) chronyToMasterExec(args []string) (bool, []string) {
|
||||
}
|
||||
}
|
||||
|
||||
parseIP := net.ParseIP(args[0])
|
||||
if parseIP == nil {
|
||||
return false, []string{
|
||||
"[chronyToMasterExec] - ip args error !",
|
||||
}
|
||||
}
|
||||
|
||||
// modify the systemd-timesync.service
|
||||
ntpFile := "/etc/systemd/timesyncd.conf"
|
||||
AllCommandExecutor([]string{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/#NTP=/NTP=" + args[0] + "/g",
|
||||
ntpFile,
|
||||
})
|
||||
|
||||
// todo restart
|
||||
BasicPrettyPrint(AllCompleteExecutor([][]string{
|
||||
{
|
||||
"systemctl",
|
||||
"restart",
|
||||
"systemd-timesyncd.service",
|
||||
},
|
||||
{
|
||||
"sleep",
|
||||
"2",
|
||||
},
|
||||
{
|
||||
"timedatectl",
|
||||
"show-timesync",
|
||||
"--all",
|
||||
},
|
||||
{
|
||||
"timedatectl",
|
||||
"status",
|
||||
},
|
||||
}))
|
||||
|
||||
return true, []string{
|
||||
"[chronyToMasterExec] - install success !",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user