liuxiaolong
2019-12-19 a789f7bd273fb5659c0583c45b2e9cdb7102f1d3
service/SysService.go
@@ -171,13 +171,13 @@
         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 {
@@ -201,20 +201,24 @@
   unZipPath := configPatchPath+"/"+identifier+"_basic/"
   if util.Exists(unZipPath) {
      //此版本已经更新过
      return true
   } else {
      if !util.CreateDirectory(unZipPath) {
      rmErr := os.RemoveAll(unZipPath)
      if rmErr !=nil {
         return false
      }
   }
   err := util.UnZip(configPatchPath+"/"+identifier+ext, unZipPath)
   if !util.CreateDirectory(unZipPath) {
      return false
   }
   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("./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))