aboutsummaryrefslogtreecommitdiffstats
path: root/routers/install
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-07-10 06:43:37 +0800
committerGitHub <noreply@github.com>2023-07-09 22:43:37 +0000
commitfa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189 (patch)
tree885a32e803e934883ca047116441f56ac9435b5b /routers/install
parent61e0d1a767e1a1a509de9de4aff42bdb79cc6443 (diff)
downloadgitea-fa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189.tar.gz
gitea-fa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189.zip
Make "install page" respect environment config (#25648)
Replace #25580 Fix #19453 The problem was: when users set "GITEA__XXX__YYY" , the "install page" doesn't respect it. So, to make the result consistent and avoid surprising end users, now the "install page" also writes the environment variables to the config file. And, to make things clear, there are enough messages on the UI to tell users what will happen. There are some necessary/related changes to `environment-to-ini.go`: * The "--clear" flag is removed and it was incorrectly written there. The "clear" operation should be done if INSTALL_LOCK=true * The "--prefix" flag is removed because it's never used, never documented and it only causes inconsistent behavior. ![image](https://github.com/go-gitea/gitea/assets/2114189/12778ee4-3fb5-4664-a73a-41ebbd77cd5b)
Diffstat (limited to 'routers/install')
-rw-r--r--routers/install/install.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/routers/install/install.go b/routers/install/install.go
index f121f31376..a2e89d3dac 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -56,6 +56,7 @@ func getSupportedDbTypeNames() (dbTypeNames []map[string]string) {
func Contexter() func(next http.Handler) http.Handler {
rnd := templates.HTMLRenderer()
dbTypeNames := getSupportedDbTypeNames()
+ envConfigKeys := setting.CollectEnvConfigKeys()
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
base, baseCleanUp := context.NewBaseContext(resp, req)
@@ -70,11 +71,13 @@ func Contexter() func(next http.Handler) http.Handler {
ctx.AppendContextValue(context.WebContextKey, ctx)
ctx.Data.MergeFrom(middleware.CommonTemplateContextData())
ctx.Data.MergeFrom(middleware.ContextData{
- "locale": ctx.Locale,
- "Title": ctx.Locale.Tr("install.install"),
- "PageIsInstall": true,
- "DbTypeNames": dbTypeNames,
- "AllLangs": translation.AllLangs(),
+ "locale": ctx.Locale,
+ "Title": ctx.Locale.Tr("install.install"),
+ "PageIsInstall": true,
+ "DbTypeNames": dbTypeNames,
+ "EnvConfigKeys": envConfigKeys,
+ "CustomConfFile": setting.CustomConf,
+ "AllLangs": translation.AllLangs(),
"PasswordHashAlgorithms": hash.RecommendedHashAlgorithms,
})
@@ -218,7 +221,7 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool {
return false
}
- log.Info("User confirmed reinstallation of Gitea into a pre-existing database")
+ log.Info("User confirmed re-installation of Gitea into a pre-existing database")
}
if hasPostInstallationUser || dbMigrationVersion > 0 {
@@ -502,6 +505,8 @@ func SubmitInstall(ctx *context.Context) {
return
}
+ setting.EnvironmentToConfig(cfg, os.Environ())
+
if err = cfg.SaveTo(setting.CustomConf); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form)
return
@@ -568,6 +573,7 @@ func SubmitInstall(ctx *context.Context) {
}
}
+ setting.ClearEnvConfigKeys()
log.Info("First-time run install finished!")
InstallDone(ctx)