Explorar o código

Added setting for customizing webshell start command

0xJacky %!s(int64=2) %!d(string=hai) anos
pai
achega
acc1aabaf7
Modificáronse 5 ficheiros con 9 adicións e 3 borrados
  1. 1 0
      app.example.ini
  2. BIN=BIN
      nginx-ui
  3. 2 0
      server/settings/settings.go
  4. 4 2
      server/tool/nginx/nginx.go
  5. 2 1
      server/tool/pty/pipeline.go

+ 1 - 0
app.example.ini

@@ -4,3 +4,4 @@ RunMode = debug
 JwtSecret =
 Email =
 HTTPChallengePort = 9180
+StartCmd = login

BIN=BIN
nginx-ui


+ 2 - 0
server/settings/settings.go

@@ -23,6 +23,7 @@ type Server struct {
 	HTTPChallengePort string
 	Email             string
 	Database          string
+	StartCmd          string
 	Demo              bool
 }
 
@@ -31,6 +32,7 @@ var ServerSettings = &Server{
 	RunMode:           "debug",
 	HTTPChallengePort: "9180",
 	Database:          "database",
+	StartCmd:          "login",
 	Demo:              false,
 }
 

+ 4 - 2
server/tool/nginx/nginx.go

@@ -32,8 +32,10 @@ func ReloadNginx() string {
 
 	output := string(out)
 	log.Println(output)
-
-	return output
+	if strings.Contains(output, "failed") {
+		return output
+	}
+	return ""
 }
 
 func GetNginxConfPath(dir string) string {

+ 2 - 1
server/tool/pty/pipeline.go

@@ -2,6 +2,7 @@ package pty
 
 import (
 	"encoding/json"
+	"github.com/0xJacky/Nginx-UI/server/settings"
 	"github.com/creack/pty"
 	"github.com/gorilla/websocket"
 	"github.com/pkg/errors"
@@ -24,7 +25,7 @@ type Message struct {
 const bufferSize = 2048
 
 func NewPipeLine(conn *websocket.Conn) (p *Pipeline, err error) {
-	c := exec.Command("login")
+	c := exec.Command(settings.ServerSettings.StartCmd)
 
 	ptmx, err := pty.StartWithSize(c, &pty.Winsize{Cols: 90, Rows: 60})
 	if err != nil {