fix: dpkg ims software

This commit is contained in:
2024-01-16 19:07:46 +08:00
parent 931249312b
commit ca21e901fd
4 changed files with 27 additions and 2 deletions

View File

@@ -698,8 +698,21 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return
}
} else if fileType == 2 {
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
err := RunSSHCmd(sshHost, dpkgCmd)
srcFile := fmt.Sprintf("%s/spawndpkg.sh", config.GetYamlConfig().OMC.BinDir)
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
cmd := exec.Command("scp", "-r", srcFile, scpDir)
out, err := cmd.CombinedOutput()
log.Debugf("Exec output: %v", string(out))
if err != nil {
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
dpkgCmd := fmt.Sprintf("sudo %s/spawdpkg.sh -i --force-all '%s'",
config.GetYamlConfig().NE.ScpDir, filePath)
err = RunSSHCmd(sshHost, dpkgCmd)
if err != nil {
log.Error("Faile to execute dpkg command:", err)
services.ResponseInternalServerError500ProcessError(w, err)