|
|
@ -11,7 +11,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
"github.com/Unknwon/goconfig" |
|
|
|
"github.com/Unknwon/goconfig" |
|
|
|
"github.com/codegangsta/martini" |
|
|
|
"github.com/codegangsta/martini" |
|
|
|
// "github.com/lunny/xorm"
|
|
|
|
"github.com/lunny/xorm" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
"github.com/gogits/gogs/modules/auth" |
|
|
|
"github.com/gogits/gogs/modules/auth" |
|
|
@ -113,12 +113,10 @@ func Install(ctx *middleware.Context, form auth.InstallForm) { |
|
|
|
models.DbCfg.SslMode = form.SslMode |
|
|
|
models.DbCfg.SslMode = form.SslMode |
|
|
|
models.DbCfg.Path = form.DatabasePath |
|
|
|
models.DbCfg.Path = form.DatabasePath |
|
|
|
|
|
|
|
|
|
|
|
// ctx.RenderWithErr("Database setting is not correct: ", "install", &form)
|
|
|
|
// Set test engine.
|
|
|
|
// return
|
|
|
|
|
|
|
|
log.Trace("00000000000000000000000000000000000000000000") |
|
|
|
|
|
|
|
var x *xorm.Engine |
|
|
|
var x *xorm.Engine |
|
|
|
if err := models.NewTestEngine(x); err != nil { |
|
|
|
if err := models.NewTestEngine(x); err != nil { |
|
|
|
if strings.Contains(err.Error(), `unknown driver "sqlite3"`) { |
|
|
|
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) { |
|
|
|
ctx.RenderWithErr("Your release version does not support SQLite3, please download the official binary version "+ |
|
|
|
ctx.RenderWithErr("Your release version does not support SQLite3, please download the official binary version "+ |
|
|
|
"from https://github.com/gogits/gogs/wiki/Install-from-binary, NOT the gobuild version.", "install", &form) |
|
|
|
"from https://github.com/gogits/gogs/wiki/Install-from-binary, NOT the gobuild version.", "install", &form) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -133,15 +131,6 @@ func Install(ctx *middleware.Context, form auth.InstallForm) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Create admin account.
|
|
|
|
|
|
|
|
if _, err := models.RegisterUser(&models.User{Name: form.AdminName, Email: form.AdminEmail, Passwd: form.AdminPasswd, |
|
|
|
|
|
|
|
IsAdmin: true, IsActive: true}); err != nil { |
|
|
|
|
|
|
|
if err != models.ErrUserAlreadyExist { |
|
|
|
|
|
|
|
ctx.RenderWithErr("Admin account setting is invalid: "+err.Error(), "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) |
|
|
@ -168,13 +157,22 @@ func Install(ctx *middleware.Context, form auth.InstallForm) { |
|
|
|
|
|
|
|
|
|
|
|
base.Cfg.SetValue("security", "INSTALL_LOCK", "true") |
|
|
|
base.Cfg.SetValue("security", "INSTALL_LOCK", "true") |
|
|
|
|
|
|
|
|
|
|
|
if err := goconfig.SaveConfigFile(base.Cfg, "custom/conf/app1.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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GlobalInit() |
|
|
|
GlobalInit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create admin account.
|
|
|
|
|
|
|
|
if _, err := models.RegisterUser(&models.User{Name: form.AdminName, Email: form.AdminEmail, Passwd: form.AdminPasswd, |
|
|
|
|
|
|
|
IsAdmin: true, IsActive: true}); err != nil { |
|
|
|
|
|
|
|
if err != models.ErrUserAlreadyExist { |
|
|
|
|
|
|
|
ctx.RenderWithErr("Admin account setting is invalid: "+err.Error(), "install", &form) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.Info("First-time run install finished!") |
|
|
|
log.Info("First-time run install finished!") |
|
|
|
ctx.Redirect("/user/login") |
|
|
|
ctx.Redirect("/user/login") |
|
|
|
} |
|
|
|
} |
|
|
|