Added setting for customizing webshell start command

This commit is contained in:
0xJacky 2022-07-24 20:43:51 +08:00
parent 70e3f2d372
commit acc1aabaf7
5 changed files with 9 additions and 3 deletions

View file

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

BIN
nginx-ui

Binary file not shown.

View file

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

View file

@ -32,9 +32,11 @@ func ReloadNginx() string {
output := string(out) output := string(out)
log.Println(output) log.Println(output)
if strings.Contains(output, "failed") {
return output return output
} }
return ""
}
func GetNginxConfPath(dir string) string { func GetNginxConfPath(dir string) string {
out, err := exec.Command("nginx", "-V").CombinedOutput() out, err := exec.Command("nginx", "-V").CombinedOutput()

View file

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