mirror of
https://github.com/beclab/Olares
synced 2026-05-24 09:18:23 +00:00
fix(cli): create symlink to sysconf if none exists (#1679)
This commit is contained in:
parent
beed97f704
commit
83e070761c
2 changed files with 39 additions and 0 deletions
|
|
@ -166,6 +166,15 @@ func (c *ConfigureOSModule) Init() {
|
|||
Parallel: true,
|
||||
}
|
||||
|
||||
symlinkSysconf := &task.RemoteTask{
|
||||
Name: "SymlinkSysconf",
|
||||
Desc: "Create symbolic link to sysconf if non-existing",
|
||||
Hosts: c.Runtime.GetAllHosts(),
|
||||
Prepare: &kubernetes.NodeInCluster{Not: true},
|
||||
Action: new(SymLinkSysconf),
|
||||
Parallel: true,
|
||||
}
|
||||
|
||||
ConfigureNtpServer := &task.RemoteTask{
|
||||
Name: "ConfigureNtpServer",
|
||||
Desc: "configure the ntp server for each node",
|
||||
|
|
@ -191,6 +200,7 @@ func (c *ConfigureOSModule) Init() {
|
|||
initOS,
|
||||
GenerateScript,
|
||||
ExecScript,
|
||||
symlinkSysconf,
|
||||
ConfigureNtpServer,
|
||||
configureSwap,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,6 +371,35 @@ func (n *NodeExecScript) Execute(runtime connector.Runtime) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type SymLinkSysconf struct {
|
||||
common.KubeAction
|
||||
}
|
||||
|
||||
func (a *SymLinkSysconf) Execute(runtime connector.Runtime) error {
|
||||
sysconfPath := "/etc/sysctl.conf"
|
||||
sysconfSymLinkPath := "/etc/sysctl.d/99-sysctl.conf"
|
||||
linkExists, err := runtime.GetRunner().FileExist(sysconfSymLinkPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if %s exists", sysconfSymLinkPath)
|
||||
}
|
||||
if linkExists {
|
||||
return nil
|
||||
}
|
||||
sysconfDir := filepath.Dir(sysconfSymLinkPath)
|
||||
dirExists, err := runtime.GetRunner().DirExist(sysconfDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check if %s exists", sysconfDir)
|
||||
}
|
||||
if !dirExists {
|
||||
err = runtime.GetRunner().MkDir(sysconfDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = runtime.GetRunner().SudoCmd(fmt.Sprintf("ln -s %s %s", sysconfPath, sysconfSymLinkPath), true, false)
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
etcdFiles = []string{
|
||||
"/usr/local/bin/etcd",
|
||||
|
|
|
|||
Loading…
Reference in a new issue