| | |
| | | return false,errors.New("获取升级压缩包md5失败") |
| | | } |
| | | if strMd5 == identifier { |
| | | if util.ZipCheck(zipFilePath) { |
| | | if util.TarGzCheck(zipFilePath) { |
| | | if !updatePatch(identifier, ext) { |
| | | return false,errors.New("执行升级过程异常") |
| | | } |
| | |
| | | configPatchPath = "/opt/vasystem/patch" |
| | | } |
| | | //1.解压缩更新包 |
| | | unZipPath := configPatchPath+"/"+identifier+"_basic/" |
| | | if util.Exists(unZipPath) { |
| | | unPackPath := configPatchPath+"/"+identifier+"_basic/" |
| | | if util.Exists(unPackPath) { |
| | | //此版本已经更新过 |
| | | rmErr := os.RemoveAll(unZipPath) |
| | | rmErr := os.RemoveAll(unPackPath) |
| | | if rmErr !=nil { |
| | | return false |
| | | } |
| | | } |
| | | if !util.CreateDirectory(unZipPath) { |
| | | if !util.CreateDirectory(unPackPath) { |
| | | return false |
| | | } |
| | | |
| | | zipFilePath := configPatchPath+"/"+identifier+ext |
| | | err := util.UnZip(zipFilePath, unZipPath) |
| | | err := util.DeCompress(zipFilePath, unPackPath) |
| | | if err !=nil { |
| | | logger.Debug("UnZip err:",err,"zipFile:",zipFilePath) |
| | | return false |
| | | } |
| | | |
| | | //如果通用脚本有更新,则更新通用脚本 |
| | | if util.Exists(unZipPath+"updatePatch.sh") { |
| | | cpStr := fmt.Sprintf("cp %s /opt/vasystem/bin",unZipPath+"updatePatch.sh") |
| | | if util.Exists(unPackPath+"updatePatch.sh") { |
| | | cpStr := fmt.Sprintf("cp %s /opt/vasystem/bin",unPackPath+"updatePatch.sh") |
| | | b, err := ExecCmd(cpStr) |
| | | if err != nil { |
| | | logger.Debug("cp updatePatch.sh to bin err:",err,"result:",string(b)) |
| | |
| | | } |
| | | |
| | | //判断更新包里是否有补丁脚本,如果有则执行,否则执行updatePatch.sh |
| | | updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | if util.Exists(unZipPath+"upgrade.sh") { |
| | | updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s",unZipPath,unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unPackPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | if util.Exists(unPackPath+"upgrade.sh") { |
| | | updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s",unPackPath,unPackPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | } |
| | | //2.更新系统 |
| | | b,err := ExecCmd(updateCmd) |