Browse Source

install: able to enable builtin SSH server (#3773)

pull/4150/merge
Unknwon 8 years ago
parent
commit
21d538a738
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 9
      conf/locale/locale_en-US.ini
  2. 2
      gogs.go
  3. 17
      modules/auth/user_form.go
  4. 4
      modules/bindata/bindata.go
  5. 5
      public/css/gogs.css
  6. 7
      public/js/gogs.js
  7. 5
      public/less/_install.less
  8. 11
      routers/install.go
  9. 2
      templates/.VERSION
  10. 6
      templates/install.tmpl

9
conf/locale/locale_en-US.ini

@ -48,7 +48,7 @@ cancel = Cancel
install = Installation
title = Install Steps For First-time Run
docker_helper = If you're running Gogs inside Docker, please read <a target="_blank" href="%s">Guidelines</a> carefully before you change anything in this page!
requite_db_desc = Gogs requires MySQL, PostgreSQL, SQLite3 or TiDB.
requite_db_desc = Gogs requires MySQL, PostgreSQL, SQLite3, MSSQL or TiDB.
db_title = Database Settings
db_type = Database Type
host = Host
@ -58,9 +58,8 @@ db_name = Database Name
db_helper = Please use INNODB engine with utf8_general_ci charset for MySQL.
ssl_mode = SSL Mode
path = Path
sqlite_helper = The file path of SQLite3 or TiDB database. <br>Please use absolute path when you start as service.
err_empty_db_path = SQLite3 or TiDB database path cannot be empty.
err_invalid_tidb_name = TiDB database name does not allow characters "." and "-".
sqlite_helper = The file path of SQLite3 database. <br>Please use absolute path when you start as service.
err_empty_db_path = SQLite3 database path cannot be empty.
no_admin_and_disable_registration = You cannot disable registration without creating an admin account.
err_empty_admin_password = Admin password cannot be empty.
@ -75,6 +74,8 @@ domain = Domain
domain_helper = This affects SSH clone URLs.
ssh_port = SSH Port
ssh_port_helper = Port number which your SSH server is using, leave it empty to disable SSH feature.
use_builtin_ssh_server = Use Builtin SSH Server
use_builtin_ssh_server_popup = Start builtin SSH server for Git operations to distinguish from system SSH daemon.
http_port = HTTP Port
http_port_helper = Port number which application will listen on.
app_url = Application URL

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.157.0218"
const APP_VER = "0.9.158.0218"
func init() {
setting.AppVer = APP_VER

17
modules/auth/user_form.go

@ -20,14 +20,15 @@ type InstallForm struct {
SSLMode string
DbPath string
AppName string `binding:"Required" locale:"install.app_name"`
RepoRootPath string `binding:"Required"`
RunUser string `binding:"Required"`
Domain string `binding:"Required"`
SSHPort int
HTTPPort string `binding:"Required"`
AppUrl string `binding:"Required"`
LogRootPath string `binding:"Required"`
AppName string `binding:"Required" locale:"install.app_name"`
RepoRootPath string `binding:"Required"`
RunUser string `binding:"Required"`
Domain string `binding:"Required"`
SSHPort int
UseBuiltinSSHServer bool
HTTPPort string `binding:"Required"`
AppUrl string `binding:"Required"`
LogRootPath string `binding:"Required"`
SMTPHost string
SMTPFrom string

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

5
public/css/gogs.css

@ -900,6 +900,11 @@ footer .ui.language .menu {
.install .ui .checkbox label {
width: auto !important;
}
.install #use-builtin-ssh-server {
margin-top: -1em;
margin-left: -15px !important;
margin-bottom: 2em;
}
.form .help {
color: #999999;
padding-top: .6em;

7
public/js/gogs.js

@ -212,18 +212,15 @@ function initInstall() {
// Database type change detection.
$("#db_type").change(function () {
var sqliteDefault = 'data/gogs.db';
var tidbDefault = 'data/gogs_tidb';
var dbType = $(this).val();
if (dbType === "SQLite3" || dbType === "TiDB") {
if (dbType === "SQLite3") {
$('#sql_settings').hide();
$('#pgsql_settings').hide();
$('#sqlite_settings').show();
if (dbType === "SQLite3" && $('#db_path').val() == tidbDefault) {
if (dbType === "SQLite3") {
$('#db_path').val(sqliteDefault);
} else if (dbType === "TiDB" && $('#db_path').val() == sqliteDefault) {
$('#db_path').val(tidbDefault);
}
return;
}

5
public/less/_install.less

@ -28,4 +28,9 @@
}
}
}
#use-builtin-ssh-server {
margin-top: -1em;
margin-left: -15px !important;
margin-bottom: 2em;
}
}

11
routers/install.go

@ -9,7 +9,6 @@ import (
"net/mail"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
@ -144,6 +143,7 @@ func Install(ctx *context.Context) {
form.Domain = setting.Domain
form.SSHPort = setting.SSH.Port
form.UseBuiltinSSHServer = setting.SSH.StartBuiltinServer
form.HTTPPort = setting.HTTPPort
form.AppUrl = setting.AppUrl
form.LogRootPath = setting.LogRootPath
@ -202,16 +202,10 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
models.DbCfg.SSLMode = form.SSLMode
models.DbCfg.Path = form.DbPath
if (models.DbCfg.Type == "sqlite3" || models.DbCfg.Type == "tidb") &&
len(models.DbCfg.Path) == 0 {
if models.DbCfg.Type == "sqlite3" && len(models.DbCfg.Path) == 0 {
ctx.Data["Err_DbPath"] = true
ctx.RenderWithErr(ctx.Tr("install.err_empty_db_path"), INSTALL, &form)
return
} else if models.DbCfg.Type == "tidb" &&
strings.ContainsAny(path.Base(models.DbCfg.Path), ".-") {
ctx.Data["Err_DbPath"] = true
ctx.RenderWithErr(ctx.Tr("install.err_invalid_tidb_name"), INSTALL, &form)
return
}
// Set test engine.
@ -315,6 +309,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
} else {
cfg.Section("server").Key("DISABLE_SSH").SetValue("false")
cfg.Section("server").Key("SSH_PORT").SetValue(com.ToStr(form.SSHPort))
cfg.Section("server").Key("START_SSH_SERVER").SetValue(com.ToStr(form.UseBuiltinSSHServer))
}
if len(strings.TrimSpace(form.SMTPHost)) > 0 {

2
templates/.VERSION

@ -1 +1 @@
0.9.157.0218
0.9.158.0218

6
templates/install.tmpl

@ -99,6 +99,12 @@
<input id="ssh_port" name="ssh_port" value="{{.ssh_port}}">
<span class="help">{{.i18n.Tr "install.ssh_port_helper"}}</span>
</div>
<div class="inline field" id="use-builtin-ssh-server">
<div class="ui checkbox">
<label class="poping up" data-content="{{.i18n.Tr "install.use_builtin_ssh_server_popup"}}"><strong>{{.i18n.Tr "install.use_builtin_ssh_server"}}</strong></label>
<input name="use_builtin_ssh_server" type="checkbox" {{if .use_builtin_ssh_server}}checked{{end}}>
</div>
</div>
<div class="inline required field">
<label for="http_port">{{.i18n.Tr "install.http_port"}}</label>
<input id="http_port" name="http_port" value="{{.http_port}}" required>

Loading…
Cancel
Save