|
@@ -34,8 +34,8 @@ import (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
- // INSTALL page template
|
|
|
|
|
- INSTALL = "install"
|
|
|
|
|
|
|
+ // InstallTPL page template
|
|
|
|
|
+ InstallTPL = "install"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// checkRunMode check if it is runned or not in production
|
|
// checkRunMode check if it is runned or not in production
|
|
@@ -182,7 +182,7 @@ func Install(c *context.Context) {
|
|
|
f.RequireSignInView = setting.Service.RequireSignInView
|
|
f.RequireSignInView = setting.Service.RequireSignInView
|
|
|
|
|
|
|
|
form.Assign(f, c.Data)
|
|
form.Assign(f, c.Data)
|
|
|
- c.Success(INSTALL)
|
|
|
|
|
|
|
+ c.Success(InstallTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// InstallPost install gitote
|
|
// InstallPost install gitote
|
|
@@ -199,12 +199,12 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
c.FormErr("Admin")
|
|
c.FormErr("Admin")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- c.Success(INSTALL)
|
|
|
|
|
|
|
+ c.Success(InstallTPL)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if _, err := exec.LookPath("git"); err != nil {
|
|
if _, err := exec.LookPath("git"); err != nil {
|
|
|
- c.RenderWithErr(c.Tr("install.test_git_failed", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.test_git_failed", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -221,7 +221,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
|
|
|
|
|
if models.DbCfg.Type == "sqlite3" && len(models.DbCfg.Path) == 0 {
|
|
if models.DbCfg.Type == "sqlite3" && len(models.DbCfg.Path) == 0 {
|
|
|
c.FormErr("DbPath")
|
|
c.FormErr("DbPath")
|
|
|
- c.RenderWithErr(c.Tr("install.err_empty_db_path"), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.err_empty_db_path"), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -230,10 +230,10 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
if err := models.NewTestEngine(x); err != nil {
|
|
if err := models.NewTestEngine(x); err != nil {
|
|
|
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
|
|
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
|
|
|
c.FormErr("DbType")
|
|
c.FormErr("DbType")
|
|
|
- c.RenderWithErr(c.Tr("install.sqlite3_not_available", "https://gitote/docs/installation/install_from_binary.html"), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.sqlite3_not_available", "https://docs.gitote.in/docs/installation/install_from_binary.html"), InstallTPL, &f)
|
|
|
} else {
|
|
} else {
|
|
|
c.FormErr("DbSetting")
|
|
c.FormErr("DbSetting")
|
|
|
- c.RenderWithErr(c.Tr("install.invalid_db_setting", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.invalid_db_setting", err), InstallTPL, &f)
|
|
|
}
|
|
}
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -242,7 +242,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
f.RepoRootPath = strings.Replace(f.RepoRootPath, "\\", "/", -1)
|
|
f.RepoRootPath = strings.Replace(f.RepoRootPath, "\\", "/", -1)
|
|
|
if err := os.MkdirAll(f.RepoRootPath, os.ModePerm); err != nil {
|
|
if err := os.MkdirAll(f.RepoRootPath, os.ModePerm); err != nil {
|
|
|
c.FormErr("RepoRootPath")
|
|
c.FormErr("RepoRootPath")
|
|
|
- c.RenderWithErr(c.Tr("install.invalid_repo_path", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.invalid_repo_path", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -250,21 +250,21 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
f.LogRootPath = strings.Replace(f.LogRootPath, "\\", "/", -1)
|
|
f.LogRootPath = strings.Replace(f.LogRootPath, "\\", "/", -1)
|
|
|
if err := os.MkdirAll(f.LogRootPath, os.ModePerm); err != nil {
|
|
if err := os.MkdirAll(f.LogRootPath, os.ModePerm); err != nil {
|
|
|
c.FormErr("LogRootPath")
|
|
c.FormErr("LogRootPath")
|
|
|
- c.RenderWithErr(c.Tr("install.invalid_log_root_path", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.invalid_log_root_path", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
currentUser, match := setting.IsRunUserMatchCurrentUser(f.RunUser)
|
|
currentUser, match := setting.IsRunUserMatchCurrentUser(f.RunUser)
|
|
|
if !match {
|
|
if !match {
|
|
|
c.FormErr("RunUser")
|
|
c.FormErr("RunUser")
|
|
|
- c.RenderWithErr(c.Tr("install.run_user_not_match", f.RunUser, currentUser), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.run_user_not_match", f.RunUser, currentUser), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check host address and port
|
|
// Check host address and port
|
|
|
if len(f.SMTPHost) > 0 && !strings.Contains(f.SMTPHost, ":") {
|
|
if len(f.SMTPHost) > 0 && !strings.Contains(f.SMTPHost, ":") {
|
|
|
c.FormErr("SMTP", "SMTPHost")
|
|
c.FormErr("SMTP", "SMTPHost")
|
|
|
- c.RenderWithErr(c.Tr("install.smtp_host_missing_port"), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.smtp_host_missing_port"), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -273,7 +273,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
_, err := mail.ParseAddress(f.SMTPFrom)
|
|
_, err := mail.ParseAddress(f.SMTPFrom)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
c.FormErr("SMTP", "SMTPFrom")
|
|
c.FormErr("SMTP", "SMTPFrom")
|
|
|
- c.RenderWithErr(c.Tr("install.invalid_smtp_from", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.invalid_smtp_from", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -281,19 +281,19 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
// Check logic loophole between disable self-registration and no admin account.
|
|
// Check logic loophole between disable self-registration and no admin account.
|
|
|
if f.DisableRegistration && len(f.AdminName) == 0 {
|
|
if f.DisableRegistration && len(f.AdminName) == 0 {
|
|
|
c.FormErr("Services", "Admin")
|
|
c.FormErr("Services", "Admin")
|
|
|
- c.RenderWithErr(c.Tr("install.no_admin_and_disable_registration"), INSTALL, f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.no_admin_and_disable_registration"), InstallTPL, f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check admin password.
|
|
// Check admin password.
|
|
|
if len(f.AdminName) > 0 && len(f.AdminPasswd) == 0 {
|
|
if len(f.AdminName) > 0 && len(f.AdminPasswd) == 0 {
|
|
|
c.FormErr("Admin", "AdminPasswd")
|
|
c.FormErr("Admin", "AdminPasswd")
|
|
|
- c.RenderWithErr(c.Tr("install.err_empty_admin_password"), INSTALL, f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.err_empty_admin_password"), InstallTPL, f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if f.AdminPasswd != f.AdminConfirmPasswd {
|
|
if f.AdminPasswd != f.AdminConfirmPasswd {
|
|
|
c.FormErr("Admin", "AdminPasswd")
|
|
c.FormErr("Admin", "AdminPasswd")
|
|
|
- c.RenderWithErr(c.Tr("form.password_not_match"), INSTALL, f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("form.password_not_match"), InstallTPL, f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -366,14 +366,14 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
|
|
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
|
|
|
secretKey, err := tool.RandomString(15)
|
|
secretKey, err := tool.RandomString(15)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- c.RenderWithErr(c.Tr("install.secret_key_failed", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.secret_key_failed", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
cfg.Section("security").Key("SECRET_KEY").SetValue(secretKey)
|
|
cfg.Section("security").Key("SECRET_KEY").SetValue(secretKey)
|
|
|
|
|
|
|
|
os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
|
|
os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
|
|
|
if err := cfg.SaveTo(setting.CustomConf); err != nil {
|
|
if err := cfg.SaveTo(setting.CustomConf); err != nil {
|
|
|
- c.RenderWithErr(c.Tr("install.save_config_failed", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.save_config_failed", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -392,7 +392,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
|
|
if !models.IsErrUserAlreadyExist(err) {
|
|
if !models.IsErrUserAlreadyExist(err) {
|
|
|
setting.InstallLock = false
|
|
setting.InstallLock = false
|
|
|
c.FormErr("AdminName", "AdminEmail")
|
|
c.FormErr("AdminName", "AdminEmail")
|
|
|
- c.RenderWithErr(c.Tr("install.invalid_admin_setting", err), INSTALL, &f)
|
|
|
|
|
|
|
+ c.RenderWithErr(c.Tr("install.invalid_admin_setting", err), InstallTPL, &f)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
log.Info("Admin account already exist")
|
|
log.Info("Admin account already exist")
|