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"`
} `json:"cluster"`
Skip bool `json:"skip"`
BootstrapUsername string `json:"bootstrap_username"`
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 }
orm.Register("elastic_setup_"+util.GetUUID(), handler)
if !request.Skip{
//处理模版
elastic2.InitTemplate(true)
@ -388,7 +390,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
}
}
//处理索引
elastic2.InitSchema()
//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
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 " +
@ -436,17 +446,9 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
panic(err)
}
//处理 ILM
//callback
InvokeSetupCallback()
//disable builtin auth
err=api.DisableBuiltinUserAdmin()
if err!=nil{
panic(err)
}
//place setup lock file
setupLock:=path.Join(global.Env().GetDataDir(),".setup_lock")
_,err=util.FilePutContent(setupLock,time.Now().String())