d
This commit is contained in:
@@ -674,11 +674,7 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
if !config.GetYamlConfig().OMC.TestMode {
|
if !config.GetYamlConfig().OMC.TestMode {
|
||||||
filePath := (*neVersion)[0]["file_path"]
|
filePath := (*neVersion)[0]["file_path"]
|
||||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||||
fileType, err := global.IsRpmOrDebPackage(filePath)
|
fileType := global.IsRpmOrDebPackage(filePath)
|
||||||
if err != nil {
|
|
||||||
log.Error("Failed to JudgeRpmOrDebPackage:", err)
|
|
||||||
services.ResponseInternalServerError500ProcessError(w, err)
|
|
||||||
}
|
|
||||||
if fileType == 1 {
|
if fileType == 1 {
|
||||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh '%s'", filePath)
|
rpmCmd := fmt.Sprintf("sudo rpm -Uvh '%s'", filePath)
|
||||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ func isDebPackage(file *os.File) bool {
|
|||||||
return string(buffer) == string(magic)
|
return string(buffer) == string(magic)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsRpmOrDebPackage(filePath string) (int, error) {
|
func CheckRpmOrDebPackage(filePath string) (int, error) {
|
||||||
var fileType int = 0
|
var fileType int = 0
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -661,3 +661,17 @@ func IsRpmOrDebPackage(filePath string) (int, error) {
|
|||||||
|
|
||||||
return fileType, nil
|
return fileType, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsRpmOrDebPackage(filePath string) int {
|
||||||
|
var fileType int = 0
|
||||||
|
|
||||||
|
if strings.Contains(filePath, ".rpm") {
|
||||||
|
fileType = 1
|
||||||
|
} else if strings.Contains(filePath, ".deb") {
|
||||||
|
fileType = 2
|
||||||
|
} else {
|
||||||
|
fileType = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileType
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user