fix: dpkg software issue

This commit is contained in:
simonzhangsz committed 2024-01-17 14:40:48 +08:00
1 parent 8eb6430ae3
commit 9e54ccd886
5 files changed
+15 -6

No files matched your search

+2
View File
@@ -89,6 +89,8 @@ ne:
etcListDefault: '{*.yaml,*.conf,*.cfg}' etcListDefault: '{*.yaml,*.conf,*.cfg}'
# true/false to overwrite config file when dpkg ne software # true/false to overwrite config file when dpkg ne software
dpkgOverwrite: false dpkgOverwrite: false
# dpkg timeout (second)
dpkgTimeout: 180
# chk2ne: true/false, if put OmcNeConfig parameters to NE # chk2ne: true/false, if put OmcNeConfig parameters to NE
omc: omc:
+6 -2
View File
@@ -710,11 +710,15 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
return return
} }
var inputStr string = "n" var inputStr string = "n"
var timeout int = 180
if config.GetYamlConfig().NE.DpkgOverwrite { if config.GetYamlConfig().NE.DpkgOverwrite {
inputStr = "y" inputStr = "y"
} }
dpkgCmd := fmt.Sprintf("sudo %s/spawndpkg.sh %s '%s'", if config.GetYamlConfig().NE.DpkgTimeout != 0 {
config.GetYamlConfig().NE.ScpDir, inputStr, filePath) timeout = config.GetYamlConfig().NE.DpkgTimeout
}
dpkgCmd := fmt.Sprintf("sudo %s/spawndpkg.sh %d %s '%s'",
config.GetYamlConfig().NE.ScpDir, timeout, inputStr, filePath)
err = RunSSHCmd(sshHost, dpkgCmd) err = RunSSHCmd(sshHost, dpkgCmd)
if err != nil { if err != nil {
log.Errorf("Faile to execute dpkg command: %s, error: %v", dpkgCmd, err) log.Errorf("Faile to execute dpkg command: %s, error: %v", dpkgCmd, err)
+4 -4
View File
@@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
expect <<EOF expect <<EOF
set timeout 10 set timeout ${1}
spawn dpkg -i --force-all ${2} spawn dpkg -i --force-all ${3}
expect { expect {
"y/n" { send "${1}\n";exp_continue } "y/n" { send "${2}\n";exp_continue }
} }
EOF EOF
+1
View File
@@ -124,6 +124,7 @@ type YamlConfig struct {
EtcListIMS string `yaml:"etcListIMS"` EtcListIMS string `yaml:"etcListIMS"`
EtcListDefault string `yaml:"etcListDefault"` EtcListDefault string `yaml:"etcListDefault"`
DpkgOverwrite bool `yaml:"dpkgOverwrite"` DpkgOverwrite bool `yaml:"dpkgOverwrite"`
DpkgTimeout int `yaml:"dpkgTimeout"`
} `yaml:"ne"` } `yaml:"ne"`
Auth struct { Auth struct {
+2
View File
@@ -89,6 +89,8 @@ ne:
etcListDefault: '{*.yaml,*.conf,*.cfg}' etcListDefault: '{*.yaml,*.conf,*.cfg}'
# true/false to overwrite config file when dpkg ne software # true/false to overwrite config file when dpkg ne software
dpkgOverwrite: false dpkgOverwrite: false
# dpkg timeout (second)
dpkgTimeout: 180
# chk2ne: true/false, if put OmcNeConfig parameters to NE # chk2ne: true/false, if put OmcNeConfig parameters to NE
omc: omc: