Skip to content

Enhance nginx ui docker image #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add env to skip installation #357
  • Loading branch information
0xJacky committed May 6, 2024
commit 13c4eb04a39426ca56ec956635769d0952a0762a
2 changes: 1 addition & 1 deletion api/system/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func installLockStatus() bool {
return "" != settings.ServerSettings.JwtSecret
return settings.ServerSettings.SkipInstallation || "" != settings.ServerSettings.JwtSecret
}

func InstallLockCheck(c *gin.Context) {
Expand Down
10 changes: 10 additions & 0 deletions internal/kernal/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func recovery() {
}

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 {
db := model.Init()
query.Init(db)
Expand Down
1 change: 1 addition & 0 deletions settings/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Server struct {
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
CertRenewalInterval int `json:"cert_renewal_interval" binding:"min=7,max=21"`
RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
SkipInstallation bool `json:"skip_installation"`
}

func (s *Server) GetCADir() string {
Expand Down
2 changes: 2 additions & 0 deletions settings/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_CERT_RENEWAL_INTERVAL", "14")
_ = 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_ERROR_LOG_PATH", "/tmp/nginx/error.log")
Expand Down Expand Up @@ -67,6 +68,7 @@ func TestSetup(t *testing.T) {
assert.Equal(t, "127.0.0.1", ServerSettings.HttpHost)
assert.Equal(t, 14, ServerSettings.CertRenewalInterval)
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/error.log", NginxSettings.ErrorLogPath)
Expand Down
8 changes: 8 additions & 0 deletions settings/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package settings

type PredefinedUser struct {
User string `json:"user"`
Password string `json:"password"`
}

var PredefinedUserSettings = &PredefinedUser{}