Java 企業(yè)應(yīng)用
          不要溫柔的走入那個(gè)良夜

               首先將需要升級(jí)的文件放到一個(gè)路徑下面。

               然后指定升級(jí)命令,將參數(shù)指定到補(bǔ)丁文件的位置和配置文件。

               假設(shè)升級(jí)文件經(jīng)過上傳,到了 /opt/package1 中,在package1中,或許是一個(gè)單一的解壓后的ifix包,或許是多個(gè)zip格式的ifix壓縮包。或許是若干 rpm包。也可能是zip包和rpm包的混合。

               每個(gè)ifix文件是zip格式,每個(gè)zip文件的根目錄下都有一個(gè)配置文件:repository.xml

               而rpm包,則是linux系統(tǒng)上 使用 rpm –Uvh 進(jìn)行安裝。

               其中,ifix包使用 IBM InstallationManager的指令 imcl進(jìn)行安裝。

               一個(gè)合理的思路就是:

               1.檢測(cè)package1下面有無rpm文件,有則將其整理成一個(gè)list,交給 rpm –Uvh

               2.檢測(cè)package1下面有無 zip文件且zip中必須含有repository.xml文件

               3.如果2中檢測(cè)到有符合要求的zip文件,則將其解壓到/opt/package2中,將ifix 路徑傳給 imcl.如果沒有符合要求的zip文件,則檢測(cè)當(dāng)前目錄下,有無repository.xml 有則將package1復(fù)制到opt/package2/package1中,交給imcl處理。

          install sh

          #!  /bin/sh
           
          ZIPPATH=/opt/zip
          IFIXTOOL=/home/hailiang/script/ifixtool.sh
          # List Zips 
          listZips() {
            for file in `find $ZIPPATH -type f -name '*.zip'`;do
                    (unzip -t "${file}"|grep repository.xml) &> /dev/null && echo $file
                            done
          }
          # Update IM
          updateIM(){
          zipList=`listZips`
                  echo "Applying iFixs:"$zipList
          ${IFIXTOOL} $zipList
          }
          # Update RPM
          {
           filename=$1
           echo "Apply rpm fix file(s)"         
                   
          rpm -Uvh $filename
          }
           
          # Main
          echo ">> start to install ifix files "
           
          # check if there is any .rpm file under /opt/zip
          rpmCount=`expr $(ls $ZIPPATH/*.rpm 2>/dev/null|wc -l)`
           
          if [ $rpmCount -ne 0 ]; then 
              fixList=`ls $ZIPPATH`
              echo "installing rpm(s):"$fixList
              rpmList=""
              for file in $ZIPPATH/*.rpm;do 
                rpmList=$rpmList" "$file 
              done
              echo "Apply rpm(s):"$rpmList
              rpm -Uvh $rpmList
          fi
           
          # installing ifix and ignore some times.
            echo "ensure permissions are suitable for update"
            chown -hR $username:users /tmp/update
           
           echo "installing ifix" 
           installed=0
           
          #Check whether there is any zip file 
          zipCount=`expr $(listZips|wc -l)`
          if [ $zipCount -eq 0 ]; then
             # Treat is as a single ifix IM repo 
             cd $ZIPPATH
             zip -r fix,zip `find -type f -name repository.xml -exec dirname{} \;`
             cd -
             zipCount=1
          fi   
          fixtotal=$zipCount
          echo $fixtotal needs to be applyed . 
          updateIM
           
          else
            echo " nothing happened."
          fi  
           
          # Remove files 
          rm -rf $ZIPPATH
           
          echo "<< exit"
            
           

              

          tool shell

          #! /bin/sh
           
          # set -x
           
          zipfilelist=""
          for zipfile;do
             if [ -f "$zipfile" ];then 
                 zipfiledir=$(cd `dirname "${zipfile}"`;pwd)
                 zipfilename=$(basename "${zipfile}")
                 zipfilelist="${zipfiledir}/${zipfilename} ${zipfilelist}"
                 fi
                 done
          echo $zipfilelist    
          #unzip ifix
          rm -rf /tmp/im
          mkdir /tmp/im
          cd /tmp/im
           
          for file  in ${zipfilelist};do
              if [ -f "$file" ]; then 
                  filename=$(basename "${file}")
                  unzip -d ${filename%.*} "$file"
                  fi
          done
           
          posted on 2012-07-17 15:29 cpegtop 閱讀(192) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 新郑市| 宁乡县| 曲麻莱县| 阿巴嘎旗| 浦北县| 伊金霍洛旗| 宣威市| 丹东市| 麻城市| 商洛市| 莫力| 乌鲁木齐县| 兰考县| 沙坪坝区| 都兰县| 三穗县| 舟曲县| 桐梓县| 西平县| 武功县| 榆林市| 乐业县| 桓台县| 武夷山市| 安远县| 垣曲县| 增城市| 阿鲁科尔沁旗| 河津市| 乌什县| 渝北区| 张家口市| 纳雍县| 清徐县| 淮滨县| 金川县| 保定市| 迁安市| 丹东市| 朝阳市| 抚顺市|