| | |
| | | return false,errors.New("获取升级压缩包md5失败") |
| | | } |
| | | if strMd5 == identifier { |
| | | if util.ZipCheck(zipFilePath + ext) { |
| | | if util.ZipCheck(zipFilePath) { |
| | | if !updatePatch(identifier, ext) { |
| | | return false,errors.New("执行升级过程异常") |
| | | } |
| | | return true,nil |
| | | } else { |
| | | logger.Debug("not a valid zip file,path:",zipFilePath+ext) |
| | | logger.Debug("not a valid zip file,path:",zipFilePath) |
| | | return false,errors.New("升级程序解压失败,请确定上传的补丁是zip格式") |
| | | } |
| | | } else { |
| | |
| | | return false |
| | | } |
| | | } |
| | | err := util.UnZip(configPatchPath+"/"+identifier+ext, unZipPath) |
| | | zipFilePath := configPatchPath+"/"+identifier+ext |
| | | err := util.UnZip(zipFilePath, unZipPath) |
| | | if err !=nil { |
| | | logger.Debug("UnZip err:",err,"zipFile:",configPatchPath+"/"+identifier+ext) |
| | | logger.Debug("UnZip err:",err,"zipFile:",zipFilePath) |
| | | return false |
| | | } |
| | | //2.更新系统 |
| | | var cmd *exec.Cmd |
| | | updateCmd := fmt.Sprintf("setsid ./updatePatch.sh %s %s %s",unZipPath,configPatchPath+"/"+identifier+ext,configPatchPath+"/"+identifier) |
| | | updateCmd := fmt.Sprintf("setsid ./updatePatch.sh %s %s %s",unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | cmd = exec.Command("/bin/sh","-c", updateCmd) |
| | | if b, err := cmd.Output(); err != nil { |
| | | logger.Debug("updatePatch err:",err,"result:",string(b)) |