| | |
| | | logger.Debug("read chunkData err:",err,"n:",n) |
| | | return false |
| | | } |
| | | logger.Debug("read currentChunkData len:",n,"header data len:",arg.Header.Size,"data:",string(chunkData)) |
| | | nn, err2 := writer.Write(chunkData) |
| | | if nn ==0 || err2 !=nil { |
| | | logger.Debug("write chunkData err:",err2,"nn:",nn) |
| | | return false |
| | | } |
| | | logger.Debug("write chunkData len:",nn) |
| | | isComplete := false |
| | | dirFiles, _ := ioutil.ReadDir(fileTmpPath) |
| | | if dirFiles != nil && len(dirFiles) == arg.TotalChunks { |
| | |
| | | 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") |
| | | b, err := ExecCmd(cpStr) |
| | | if err != nil { |
| | | logger.Debug("cp updatePatch.sh to bin err:",err,"result:",string(b)) |
| | | return false |
| | | } |
| | | } |
| | | |
| | | //判断更新包里是否有补丁脚本,如果有则执行,否则执行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) |
| | | } |
| | | //2.更新系统 |
| | | var cmd *exec.Cmd |
| | | cmd = exec.Command("/bin/sh","-c", updateCmd) |
| | | if b, err := cmd.Output(); err != nil { |
| | | b,err := ExecCmd(updateCmd) |
| | | if err != nil { |
| | | logger.Debug("upgrade err:",err,"result:",string(b),"cmd:",updateCmd) |
| | | return false |
| | | } else { |