fix: Fix the problem of abnormal operation of the script library (#8517)

This commit is contained in:
ssongliu 2025-04-29 22:45:57 +08:00 committed by GitHub
parent b0a7efe9c3
commit a3f6dc334f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -147,7 +147,7 @@ func (b *BaseApi) RunScript(c *gin.Context) {
return
}
scriptID := c.Query("script_id")
currentNode := c.Query("current_node")
currentNode := c.Query("operateNode")
intNum, _ := strconv.Atoi(scriptID)
if intNum == 0 {
if wshandleError(wsConn, fmt.Errorf(" no such script %v in library, please check and try again!", scriptID)) {
@ -183,7 +183,7 @@ func (b *BaseApi) RunScript(c *gin.Context) {
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)
initCmd := fmt.Sprintf("mkdir -p %s && cat > %s <<'MYMARKER'\n%s\nMYMARKER\n bash %s", fileDir, fileName, scriptItem.Script, fileName)
client, err := ssh.NewClient(*connInfo)
if wshandleError(wsConn, errors.WithMessage(err, "failed to set up the connection. Please check the host information")) {
return