mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: add env to skip installation #357
This commit is contained in:
parent
cb0fb47e1c
commit
13c4eb04a3
5 changed files with 22 additions and 1 deletions
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func installLockStatus() bool {
|
func installLockStatus() bool {
|
||||||
return "" != settings.ServerSettings.JwtSecret
|
return settings.ServerSettings.SkipInstallation || "" != settings.ServerSettings.JwtSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
func InstallLockCheck(c *gin.Context) {
|
func InstallLockCheck(c *gin.Context) {
|
||||||
|
|
|
@ -60,6 +60,16 @@ func recovery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitDatabase() {
|
func InitDatabase() {
|
||||||
|
|
||||||
|
// Skip installation
|
||||||
|
if settings.ServerSettings.SkipInstallation && settings.ServerSettings.JwtSecret == "" {
|
||||||
|
settings.ServerSettings.JwtSecret = uuid.New().String()
|
||||||
|
err := settings.Save()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if "" != settings.ServerSettings.JwtSecret {
|
if "" != settings.ServerSettings.JwtSecret {
|
||||||
db := model.Init()
|
db := model.Init()
|
||||||
query.Init(db)
|
query.Init(db)
|
||||||
|
|
|
@ -20,6 +20,7 @@ type Server struct {
|
||||||
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
||||||
CertRenewalInterval int `json:"cert_renewal_interval" binding:"min=7,max=21"`
|
CertRenewalInterval int `json:"cert_renewal_interval" binding:"min=7,max=21"`
|
||||||
RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
|
RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
|
||||||
|
SkipInstallation bool `json:"skip_installation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetCADir() string {
|
func (s *Server) GetCADir() string {
|
||||||
|
|
|
@ -25,6 +25,7 @@ func TestSetup(t *testing.T) {
|
||||||
_ = os.Setenv("NGINX_UI_SERVER_HTTP_HOST", "127.0.0.1")
|
_ = os.Setenv("NGINX_UI_SERVER_HTTP_HOST", "127.0.0.1")
|
||||||
_ = os.Setenv("NGINX_UI_SERVER_CERT_RENEWAL_INTERVAL", "14")
|
_ = os.Setenv("NGINX_UI_SERVER_CERT_RENEWAL_INTERVAL", "14")
|
||||||
_ = os.Setenv("NGINX_UI_SERVER_RECURSIVE_NAMESERVERS", "8.8.8.8")
|
_ = os.Setenv("NGINX_UI_SERVER_RECURSIVE_NAMESERVERS", "8.8.8.8")
|
||||||
|
_ = os.Setenv("NGINX_UI_SERVER_SKIP_INSTALLATION", "true")
|
||||||
|
|
||||||
_ = os.Setenv("NGINX_UI_NGINX_ACCESS_LOG_PATH", "/tmp/nginx/access.log")
|
_ = os.Setenv("NGINX_UI_NGINX_ACCESS_LOG_PATH", "/tmp/nginx/access.log")
|
||||||
_ = os.Setenv("NGINX_UI_NGINX_ERROR_LOG_PATH", "/tmp/nginx/error.log")
|
_ = os.Setenv("NGINX_UI_NGINX_ERROR_LOG_PATH", "/tmp/nginx/error.log")
|
||||||
|
@ -67,6 +68,7 @@ func TestSetup(t *testing.T) {
|
||||||
assert.Equal(t, "127.0.0.1", ServerSettings.HttpHost)
|
assert.Equal(t, "127.0.0.1", ServerSettings.HttpHost)
|
||||||
assert.Equal(t, 14, ServerSettings.CertRenewalInterval)
|
assert.Equal(t, 14, ServerSettings.CertRenewalInterval)
|
||||||
assert.Equal(t, []string{"8.8.8.8"}, ServerSettings.RecursiveNameservers)
|
assert.Equal(t, []string{"8.8.8.8"}, ServerSettings.RecursiveNameservers)
|
||||||
|
assert.Equal(t, true, ServerSettings.SkipInstallation)
|
||||||
|
|
||||||
assert.Equal(t, "/tmp/nginx/access.log", NginxSettings.AccessLogPath)
|
assert.Equal(t, "/tmp/nginx/access.log", NginxSettings.AccessLogPath)
|
||||||
assert.Equal(t, "/tmp/nginx/error.log", NginxSettings.ErrorLogPath)
|
assert.Equal(t, "/tmp/nginx/error.log", NginxSettings.ErrorLogPath)
|
||||||
|
|
8
settings/user.go
Normal file
8
settings/user.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package settings
|
||||||
|
|
||||||
|
type PredefinedUser struct {
|
||||||
|
User string `json:"user"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var PredefinedUserSettings = &PredefinedUser{}
|
Loading…
Add table
Add a link
Reference in a new issue