routers: save partial config when install
This commit is contained in:
parent
ac29dc93cd
commit
89ea3e1acc
2 changed files with 28 additions and 26 deletions
|
@ -77,13 +77,13 @@ func checkVersion() {
|
||||||
|
|
||||||
// Check dependency version.
|
// Check dependency version.
|
||||||
checkers := []VerChecker{
|
checkers := []VerChecker{
|
||||||
{"github.com/Unknwon/macaron", macaron.Version, "0.5.0"},
|
{"github.com/Unknwon/macaron", macaron.Version, "0.5.1"},
|
||||||
{"github.com/macaron-contrib/binding", binding.Version, "0.0.4"},
|
{"github.com/macaron-contrib/binding", binding.Version, "0.0.4"},
|
||||||
{"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
|
{"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
|
||||||
{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.1"},
|
{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.1"},
|
||||||
{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.5"},
|
{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.5"},
|
||||||
{"github.com/macaron-contrib/session", session.Version, "0.1.6"},
|
{"github.com/macaron-contrib/session", session.Version, "0.1.6"},
|
||||||
{"gopkg.in/ini.v1", ini.Version, "1.0.1"},
|
{"gopkg.in/ini.v1", ini.Version, "1.2.0"},
|
||||||
}
|
}
|
||||||
for _, c := range checkers {
|
for _, c := range checkers {
|
||||||
ver := strings.Join(strings.Split(c.Version(), ".")[:3], ".")
|
ver := strings.Join(strings.Split(c.Version(), ".")[:3], ".")
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
"github.com/Unknwon/macaron"
|
"github.com/Unknwon/macaron"
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
|
"gopkg.in/ini.v1"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
|
@ -186,41 +187,42 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save settings.
|
// Save settings.
|
||||||
setting.Cfg.Section("database").Key("DB_TYPE").SetValue(models.DbCfg.Type)
|
cfg := ini.Empty()
|
||||||
setting.Cfg.Section("database").Key("HOST").SetValue(models.DbCfg.Host)
|
cfg.Section("database").Key("DB_TYPE").SetValue(models.DbCfg.Type)
|
||||||
setting.Cfg.Section("database").Key("NAME").SetValue(models.DbCfg.Name)
|
cfg.Section("database").Key("HOST").SetValue(models.DbCfg.Host)
|
||||||
setting.Cfg.Section("database").Key("USER").SetValue(models.DbCfg.User)
|
cfg.Section("database").Key("NAME").SetValue(models.DbCfg.Name)
|
||||||
setting.Cfg.Section("database").Key("PASSWD").SetValue(models.DbCfg.Passwd)
|
cfg.Section("database").Key("USER").SetValue(models.DbCfg.User)
|
||||||
setting.Cfg.Section("database").Key("SSL_MODE").SetValue(models.DbCfg.SSLMode)
|
cfg.Section("database").Key("PASSWD").SetValue(models.DbCfg.Passwd)
|
||||||
setting.Cfg.Section("database").Key("PATH").SetValue(models.DbCfg.Path)
|
cfg.Section("database").Key("SSL_MODE").SetValue(models.DbCfg.SSLMode)
|
||||||
|
cfg.Section("database").Key("PATH").SetValue(models.DbCfg.Path)
|
||||||
|
|
||||||
setting.Cfg.Section("repository").Key("ROOT").SetValue(form.RepoRootPath)
|
cfg.Section("repository").Key("ROOT").SetValue(form.RepoRootPath)
|
||||||
setting.Cfg.Section("").Key("RUN_USER").SetValue(form.RunUser)
|
cfg.Section("").Key("RUN_USER").SetValue(form.RunUser)
|
||||||
setting.Cfg.Section("server").Key("DOMAIN").SetValue(form.Domain)
|
cfg.Section("server").Key("DOMAIN").SetValue(form.Domain)
|
||||||
setting.Cfg.Section("server").Key("HTTP_PORT").SetValue(form.HTTPPort)
|
cfg.Section("server").Key("HTTP_PORT").SetValue(form.HTTPPort)
|
||||||
setting.Cfg.Section("server").Key("ROOT_URL").SetValue(form.AppUrl)
|
cfg.Section("server").Key("ROOT_URL").SetValue(form.AppUrl)
|
||||||
|
|
||||||
if len(strings.TrimSpace(form.SMTPHost)) > 0 {
|
if len(strings.TrimSpace(form.SMTPHost)) > 0 {
|
||||||
setting.Cfg.Section("mailer").Key("ENABLED").SetValue("true")
|
cfg.Section("mailer").Key("ENABLED").SetValue("true")
|
||||||
setting.Cfg.Section("mailer").Key("HOST").SetValue(form.SMTPHost)
|
cfg.Section("mailer").Key("HOST").SetValue(form.SMTPHost)
|
||||||
setting.Cfg.Section("mailer").Key("USER").SetValue(form.SMTPEmail)
|
cfg.Section("mailer").Key("USER").SetValue(form.SMTPEmail)
|
||||||
setting.Cfg.Section("mailer").Key("PASSWD").SetValue(form.SMTPPasswd)
|
cfg.Section("mailer").Key("PASSWD").SetValue(form.SMTPPasswd)
|
||||||
|
|
||||||
setting.Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").SetValue(com.ToStr(form.RegisterConfirm == "on"))
|
cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").SetValue(com.ToStr(form.RegisterConfirm == "on"))
|
||||||
setting.Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").SetValue(com.ToStr(form.MailNotify == "on"))
|
cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").SetValue(com.ToStr(form.MailNotify == "on"))
|
||||||
}
|
}
|
||||||
|
|
||||||
setting.Cfg.Section("").Key("RUN_MODE").SetValue("prod")
|
cfg.Section("").Key("RUN_MODE").SetValue("prod")
|
||||||
|
|
||||||
setting.Cfg.Section("session").Key("PROVIDER").SetValue("file")
|
cfg.Section("session").Key("PROVIDER").SetValue("file")
|
||||||
|
|
||||||
setting.Cfg.Section("log").Key("MODE").SetValue("file")
|
cfg.Section("log").Key("MODE").SetValue("file")
|
||||||
|
|
||||||
setting.Cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
|
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
|
||||||
setting.Cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
|
cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
|
||||||
|
|
||||||
os.MkdirAll("custom/conf", os.ModePerm)
|
os.MkdirAll("custom/conf", os.ModePerm)
|
||||||
if err := setting.Cfg.SaveTo(path.Join(setting.CustomPath, "conf/app.ini")); err != nil {
|
if err := cfg.SaveTo(path.Join(setting.CustomPath, "conf/app.ini")); err != nil {
|
||||||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
|
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue