mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-09 20:05:54 +08:00
fix: Fix the problem of abnormal script execution (#8496)
This commit is contained in:
parent
39502b355f
commit
937ab76183
2 changed files with 6 additions and 5 deletions
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
|
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/core/app/dto"
|
"github.com/1Panel-dev/1Panel/core/app/dto"
|
||||||
|
|
@ -14,6 +13,7 @@ import (
|
||||||
"github.com/1Panel-dev/1Panel/core/utils/terminal"
|
"github.com/1Panel-dev/1Panel/core/utils/terminal"
|
||||||
"github.com/1Panel-dev/1Panel/core/utils/xpack"
|
"github.com/1Panel-dev/1Panel/core/utils/xpack"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -159,7 +159,6 @@ func (b *BaseApi) RunScript(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := strings.ReplaceAll(scriptItem.Name, " ", "_")
|
|
||||||
quitChan := make(chan bool, 3)
|
quitChan := make(chan bool, 3)
|
||||||
if currentNode == "local" {
|
if currentNode == "local" {
|
||||||
slave, err := terminal.NewCommand(scriptItem.Script)
|
slave, err := terminal.NewCommand(scriptItem.Script)
|
||||||
|
|
@ -181,8 +180,10 @@ func (b *BaseApi) RunScript(c *gin.Context) {
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
|
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tmpFile := path.Join(installDir, "1panel/tmp/script")
|
|
||||||
initCmd := fmt.Sprintf("d=%s && mkdir -p $d && echo %s > $d/%s && clear && bash $d/%s", tmpFile, scriptItem.Script, fileName, fileName)
|
fileDir := path.Join(installDir, "1panel/tmp/script")
|
||||||
|
fileName := path.Join(fileDir, uuid.NewString())
|
||||||
|
initCmd := fmt.Sprintf("mkdir -p %s && cat > %s <<'EOF'\n%s\nEOF\n bash %s", fileDir, fileName, scriptItem.Script, fileName)
|
||||||
client, err := ssh.NewClient(*connInfo)
|
client, err := ssh.NewClient(*connInfo)
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "failed to set up the connection. Please check the host information")) {
|
if wshandleError(wsConn, errors.WithMessage(err, "failed to set up the connection. Please check the host information")) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||||
formEl.validate(async (valid) => {
|
formEl.validate(async (valid) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if (dialogData.value.rowData.groupList.length !== 0) {
|
if (dialogData.value.rowData.groupList?.length !== 0) {
|
||||||
dialogData.value.rowData.groups = dialogData.value.rowData.groupList?.join(',');
|
dialogData.value.rowData.groups = dialogData.value.rowData.groupList?.join(',');
|
||||||
}
|
}
|
||||||
if (dialogData.value.title === 'create' || dialogData.value.title === 'clone') {
|
if (dialogData.value.title === 'create' || dialogData.value.title === 'clone') {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue