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)

9
misc/spawndpkg.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
expect <<EOF
set timeout 10
spawn dpkg -i --force-all ${2}
expect {
"y/n" { send "${1}\n";exp_continue }
}
EOF

View File

@@ -123,6 +123,7 @@ type YamlConfig struct {
LicenseDir string `yaml:"licensedir"`
EtcListIMS string `yaml:"etcListIMS"`
EtcListDefault string `yaml:"etcListDefault"`
DpkgOverwrite bool `yaml:"dpkgOverwrite"`
} `yaml:"ne"`
Auth struct {

View File

@@ -87,6 +87,8 @@ ne:
# backup etc list of IMS,no space
etcListIMS: '{*.yaml,mmtel,vars.cfg}'
etcListDefault: '{*.yaml,*.conf,*.cfg}'
# true/false to overwrite config file when dpkg ne software
dpkgOverwrite: true
# chk2ne: true/false, if put OmcNeConfig parameters to NE
omc: