1
0

fix: 补充缺失代码

This commit is contained in:
TsMask
2024-01-12 16:13:52 +08:00
parent 7edad64f93
commit 269b578d77
10 changed files with 264 additions and 35 deletions

View File

@@ -699,14 +699,32 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
}
} else if fileType == 2 {
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
cmd := exec.Command("ssh", sshHost, dpkgCmd)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
err := RunSSHCmd(sshHost, dpkgCmd)
if err != nil {
log.Error("Faile to execute dpkg command:", err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
// timeout := time.Duration(config.GetYamlConfig().OMC.CmdTimeout) * time.Second
// ctx, cancel := context.WithTimeout(context.Background(), timeout) // 设置超时
// defer cancel()
// cmd := exec.CommandContext(ctx, "ssh", sshHost, dpkgCmd)
// var stdout, stderr bytes.Buffer
// cmd.Stdout = &stdout
// cmd.Stderr = &stderr
// err := cmd.Start()
// if err != nil {
// log.Error("Faile to execute dpkg command: %v, err: %s", err, stderr.String())
// services.ResponseInternalServerError500ProcessError(w, err)
// return
// }
// out, err := cmd.CombinedOutput()
// log.Debugf("Exec output: %v", string(out))
// if err != nil {
// log.Error("Faile to execute dpkg command:", err)
// services.ResponseInternalServerError500ProcessError(w, err)
// return
// }
} else {
err := global.ErrCMUnknownSoftwareFormat
log.Error(err)