add skip to initialize api

This commit is contained in:
medcl 2022-10-24 19:52:09 +08:00
parent e607254cc4
commit 9a91ca7b70
1 changed files with 77 additions and 75 deletions

View File

@ -80,6 +80,7 @@ type SetupRequest struct {
Password string `json:"password"` Password string `json:"password"`
} `json:"cluster"` } `json:"cluster"`
Skip bool `json:"skip"`
BootstrapUsername string `json:"bootstrap_username"` BootstrapUsername string `json:"bootstrap_username"`
BootstrapPassword string `json:"bootstrap_password"` BootstrapPassword string `json:"bootstrap_password"`
} }
@ -336,6 +337,7 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
handler := elastic2.ElasticORM{Client: client, Config:cfg1 } handler := elastic2.ElasticORM{Client: client, Config:cfg1 }
orm.Register("elastic_setup_"+util.GetUUID(), handler) orm.Register("elastic_setup_"+util.GetUUID(), handler)
if !request.Skip{
//处理模版 //处理模版
elastic2.InitTemplate(true) elastic2.InitTemplate(true)
@ -388,7 +390,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
} }
} }
//处理索引 //处理索引
elastic2.InitSchema() elastic2.InitSchema()
//init security //init security
@ -426,6 +427,15 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
} }
//disable builtin auth
err=api.DisableBuiltinUserAdmin()
if err!=nil{
panic(err)
}
}
//save to local file //save to local file
file:=path.Join(global.Env().GetConfigDir(),"system_config.yml") file:=path.Join(global.Env().GetConfigDir(),"system_config.yml")
_,err=util.FilePutContent(file,fmt.Sprintf("configs.template:\n - name: \"system\"\n path: ./config/system_config.tpl\n variable:\n " + _,err=util.FilePutContent(file,fmt.Sprintf("configs.template:\n - name: \"system\"\n path: ./config/system_config.tpl\n variable:\n " +
@ -436,17 +446,9 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
panic(err) panic(err)
} }
//处理 ILM
//callback //callback
InvokeSetupCallback() InvokeSetupCallback()
//disable builtin auth
err=api.DisableBuiltinUserAdmin()
if err!=nil{
panic(err)
}
//place setup lock file //place setup lock file
setupLock:=path.Join(global.Env().GetDataDir(),".setup_lock") setupLock:=path.Join(global.Env().GetDataDir(),".setup_lock")
_,err=util.FilePutContent(setupLock,time.Now().String()) _,err=util.FilePutContent(setupLock,time.Now().String())