mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-28 00:17:00 +00:00
Fix install bugs
This commit is contained in:
parent
9f91dee53f
commit
3698431fc1
@ -21,6 +21,11 @@ type ToggleOptions struct {
|
|||||||
|
|
||||||
func Toggle(options *ToggleOptions) martini.Handler {
|
func Toggle(options *ToggleOptions) martini.Handler {
|
||||||
return func(ctx *Context) {
|
return func(ctx *Context) {
|
||||||
|
if !base.InstallLock {
|
||||||
|
ctx.Redirect("/install")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
||||||
ctx.Redirect("/")
|
ctx.Redirect("/")
|
||||||
return
|
return
|
||||||
|
@ -131,6 +131,17 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check run user.
|
||||||
|
curUser := os.Getenv("USERNAME")
|
||||||
|
if len(curUser) == 0 {
|
||||||
|
curUser = os.Getenv("USER")
|
||||||
|
}
|
||||||
|
// Does not check run user when the install lock is off.
|
||||||
|
if form.RunUser != curUser {
|
||||||
|
ctx.RenderWithErr("Run user isn't the current user: "+form.RunUser+" -> "+curUser, "install", &form)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Save settings.
|
// Save settings.
|
||||||
base.Cfg.SetValue("database", "DB_TYPE", models.DbCfg.Type)
|
base.Cfg.SetValue("database", "DB_TYPE", models.DbCfg.Type)
|
||||||
base.Cfg.SetValue("database", "HOST", models.DbCfg.Host)
|
base.Cfg.SetValue("database", "HOST", models.DbCfg.Host)
|
||||||
@ -155,8 +166,11 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
|
|||||||
base.Cfg.SetValue("service", "ENABLE_NOTIFY_MAIL", base.ToStr(form.MailNotify == "on"))
|
base.Cfg.SetValue("service", "ENABLE_NOTIFY_MAIL", base.ToStr(form.MailNotify == "on"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base.Cfg.SetValue("", "RUN_MODE", "prod")
|
||||||
|
|
||||||
base.Cfg.SetValue("security", "INSTALL_LOCK", "true")
|
base.Cfg.SetValue("security", "INSTALL_LOCK", "true")
|
||||||
|
|
||||||
|
os.MkdirAll("custom/conf", os.ModePerm)
|
||||||
if err := goconfig.SaveConfigFile(base.Cfg, "custom/conf/app.ini"); err != nil {
|
if err := goconfig.SaveConfigFile(base.Cfg, "custom/conf/app.ini"); err != nil {
|
||||||
ctx.RenderWithErr("Fail to save configuration: "+err.Error(), "install", &form)
|
ctx.RenderWithErr("Fail to save configuration: "+err.Error(), "install", &form)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user