Browse Source

Add install option for log path

Josh Frye 4 years ago
parent
commit
a3e8c32a30
5 changed files with 708 additions and 905 deletions
  1. 2 0
      conf/locale/locale_en-US.ini
  2. 1 0
      modules/auth/user_form.go
  3. 690 905
      modules/bindata/bindata.go
  4. 10 0
      routers/install.go
  5. 5 0
      templates/install.tmpl

+ 2 - 0
conf/locale/locale_en-US.ini

@@ -86,6 +86,7 @@ http_port = HTTP Port
86 86
 http_port_helper = Port number which application will listen on.
87 87
 app_url = Application URL
88 88
 app_url_helper = This affects HTTP/HTTPS clone URL and somewhere in email.
89
+log_root_path = Log Path
89 90
 
90 91
 optional_title = Optional Settings
91 92
 email_title = Email Service Settings
@@ -122,6 +123,7 @@ run_user_not_match = Run user isn't the current user: %s -> %s
122 123
 save_config_failed = Fail to save configuration: %v
123 124
 invalid_admin_setting = Admin account setting is invalid: %v
124 125
 install_success = Welcome! We're glad that you chose Gogs, have fun and take care.
126
+invalid_log_root_path = Log root path is invalid: %v
125 127
 
126 128
 [home]
127 129
 uname_holder = Username or email

+ 1 - 0
modules/auth/user_form.go

@@ -27,6 +27,7 @@ type InstallForm struct {
27 27
 	SSHPort      int
28 28
 	HTTPPort     string `binding:"Required"`
29 29
 	AppUrl       string `binding:"Required"`
30
+	LogRootPath  string
30 31
 
31 32
 	SMTPHost        string
32 33
 	SMTPFrom        string

File diff suppressed because it is too large
+ 690 - 905
modules/bindata/bindata.go


+ 10 - 0
routers/install.go

@@ -154,6 +154,7 @@ func Install(ctx *middleware.Context) {
154 154
 	form.SSHPort = setting.SSHPort
155 155
 	form.HTTPPort = setting.HttpPort
156 156
 	form.AppUrl = setting.AppUrl
157
+	form.LogRootPath = setting.LogRootPath
157 158
 
158 159
 	// E-mail service settings
159 160
 	if setting.MailService != nil {
@@ -241,6 +242,14 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
241 242
 		return
242 243
 	}
243 244
 
245
+	// Test log root path.
246
+	form.LogRootPath = strings.Replace(form.LogRootPath, "\\", "/", -1)
247
+	if err := os.MkdirAll(form.LogRootPath, os.ModePerm); err != nil {
248
+		ctx.Data["Err_LogRootPath"] = true
249
+		ctx.RenderWithErr(ctx.Tr("install.invalid_log_root_path", err), INSTALL, &form)
250
+		return
251
+	}
252
+
244 253
 	// Check run user.
245 254
 	curUser := user.CurrentUsername()
246 255
 	if form.RunUser != curUser {
@@ -329,6 +338,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
329 338
 
330 339
 	cfg.Section("log").Key("MODE").SetValue("file")
331 340
 	cfg.Section("log").Key("LEVEL").SetValue("Info")
341
+	cfg.Section("log").Key("ROOT_PATH").SetValue(form.LogRootPath)
332 342
 
333 343
 	cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
334 344
 	cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))

+ 5 - 0
templates/install.tmpl

@@ -109,6 +109,11 @@
109 109
 						<input id="app_url" name="app_url" value="{{.app_url}}" placeholder="e.g. https://try.gogs.io" required>
110 110
 						<span class="help">{{.i18n.Tr "install.app_url_helper"}}</span>
111 111
 					</div>
112
+					<div class="inline required field">
113
+						<label for="log_root_path">{{.i18n.Tr "install.log_root_path"}}</label>
114
+						<input id="log_root_path" name="log_root_path" value="{{.log_root_path}}" placeholder="log" required>
115
+					</div>
116
+
112 117
 
113 118
 					<!-- Optional Settings -->
114 119
 					<h4 class="ui dividing header">{{.i18n.Tr "install.optional_title"}}</h4>