linux自動化建立補丁

YatHo發表於2017-03-02

BUS

 1 #!/bin/sh
 2 
 3 #判斷H5_BD_${BD_data}目錄是否存在
 4 BD_data=$(date +"%F")
 5 
 6 #當日打包多次的情況下,初始化補丁目錄
 7 if [ -d "BD_${BD_data}" ]; then
 8     echo "今日補丁目錄已存在,進行補丁目錄初始化"
 9     
10     # 補丁目錄初始化
11     rm -rf ./BD_${BD_data}/TBAServer/lib/*
12     rm -rf ./BD_${BD_data}/TBAServer_conf/*
13     rm -rf ./BD_${BD_data}/TBAServer_classes/*
14         
15 else
16 
17     #建立補丁目錄
18     mkdir -p ./BD_${BD_data}/TBAServer/lib
19     mkdir -p ./BD_${BD_data}/TBAServer_conf
20     mkdir -p ./BD_${BD_data}/TBAServer_classes
21     
22 fi
 1 #!/bin/sh
 2 
 3 #臨時改變BUILD_ID值,使得Jenkins不會找到並結束掉run.sh啟動的後臺程式
 4 OLD_BUILD_ID=$BUILD_ID
 5 echo $OLD_BUILD_ID
 6 BUILD_ID=dontKillMe
 7 #獲取BD_data
 8 BD_data=$(date +"%F")
 9 
10 #移動bus部署公共jar包
11 rm -rf ./ISMP_1_BUS/bus/lib/${Delete_jar}
12 cp -rf ./ISMP_1_BUS/bus/lib/*.jar ./BD_${BD_data}/TBAServer/lib
13 
14 
15 #移動BUS相關配置檔案
16 
17 cp -rf ./ISMP_1_BUS/src/config/${Env}/* ./BD_${BD_data}/TBAServer_conf
18 
19 #移動BUS相關classes檔案
20 
21 cp -rf ./ISMP_1_BUS/target/classes/* ./BD_${BD_data}/TBAServer_classes
22 
23 
24 #清空patches目錄下,相關檔案
25 echo ${BD_name}
26 mkdir -p /mnt/patches/BD_${BD_data}/${BD_name}_classes
27 rm -rf /mnt/patches/BD_${BD_data}/${BD_name}_classes/*
28 cp -rf ./BD_${BD_data}/TBAServer_classes/* /mnt/patches/BD_${BD_data}/${BD_name}_classes
29 
30 mkdir -p /mnt/patches/BD_${BD_data}/${BD_name}_conf
31 rm -rf /mnt/patches/BD_${BD_data}/${BD_name}_conf/*
32 cp -rf ./BD_${BD_data}/TBAServer_conf/* /mnt/patches/BD_${BD_data}/${BD_name}_conf
33 
34 mkdir -p /mnt/patches/BD_${BD_data}/${BD_name}_lib
35 rm -rf /mnt/patches/BD_${BD_data}/${BD_name}_lib/*
36 cp -rf ./BD_${BD_data}/TBAServer/* /mnt/patches/BD_${BD_data}/${BD_name}_lib

H5

 1 #!/bin/bash
 2 #find ./www0/m/trade -name ".svn" -exec rm -rf {} \;
 3 # rm svn file  
 4   
 5 echo ${WORKSPACE}
 6 
 7 
 8 if [[ ! -d ${WORKSPACE} ]]; then
 9     echo "not dir"
10     return
11 fi
12 
13 SAVEIFS=$IFS;
14 IFS=$'\n'
15 rmDirSvn(){
16     
17     cd ${WORKSPACE};
18     
19     countF=`ls -A | wc -l` 
20     if [[ $countF -eq 0 ]]; then
21         cd ./../
22         echo ${WORKSPACE} is null
23         return;
24     fi
25     countF=`find . -name ".svn" -mindepth 2 -maxdepth 6`
26     echo $countF
27     for fileD in $countF; do
28         s
29         if [[ -d $fileD ]]; then
30             echo $fileD
31             rm -rf $fileD
32 
33         elif [[ ! -e $fileD ]]; then
34                 echo $fileD not exist
35         fi
36         
37     done
38 }
39 
40 rmDirSvn ${WORKSPACE};
41 IFS=$SAVEIFS
 1 #判斷H5_BD_${BD_data}目錄是否存在
 2 BD_data=$(date +"%F")
 3 
 4 #當日打包多次的情況下,初始化補丁目錄
 5 if [ -d "H5_BD_${BD_data}" ]; then
 6     echo "今日補丁目錄已存在,進行補丁目錄初始化"
 7     
 8     # 補丁目錄初始化
 9     rm -rf ./H5_BD_${BD_data}/android/*
10     rm -rf ./H5_BD_${BD_data}/ios/*
11     
12 else
13 
14     #建立補丁目錄
15     mkdir -p ./H5_BD_${BD_data}/android
16     mkdir -p ./H5_BD_${BD_data}/ios
17     
18 fi
19 
20 #同步非現場開戶H5檔案
21 mv -f ./m1/* ./www/m
22 sleep 5
23 rm -rf ./m1
24 
25 #判斷zip命令伺服器是否存在
26 
27 if [ -n `which zip` ]; then
28     echo 'zip exist'
29 else
30     echo 'zip does not exist'
31     yum -y install zip*
32 fi
33 
34 
35 #進行指定環境的H5BD打包
36 if [[ "$Env" == "dev" ]]
37 then
38     echo "打包深圳測試環境,H5升級補丁包"
39     rm -rf ./www/m/mall/configuration.js
40     rm -rf ./www/m/mall/index.html
41     
42     #H5環境替換為深圳測試環境
43     cp -rf ./SZ_Conf/* ./www/m/mall/
44     
45     #壓縮補丁包
46     zip -q -r -o ${WORKSPACE}/H5_BD_${BD_data}/android/m.zip ./www
47     zip -q -r -o ${WORKSPACE}/H5_BD_${BD_data}/ios/www.zip ./www
48     
49     if [[ "$Updata" == "yes" ]]
50     then
51         echo "進行H5自動更新"
52         #移動m包至接入層download目錄
53         mkdir -p /hxspace/production/webroot/mall/mall/download
54         rm -rf /hxspace/production/webroot/mall/mall/download/*
55         cp -rf ./H5_BD_${BD_data}/* /hxspace/production/webroot/mall/mall/download/
56     else
57         echo "取消H5環境自動更新"
58         
59     fi
60     
61 else
62     echo "打包成都測試環境,H5升級補丁包"
63     
64     #H5環境替換為成都測試環境
65     rm -rf ./www/m/mall/configuration.js
66     rm -rf ./www/m/mall/index.html
67     
68     #H5環境替換為成都測試環境
69     cp -rf ./CD_Conf/* ./www/m/mall/
70     
71     #壓縮補丁包
72     zip -q -r -o ${WORKSPACE}/H5_BD_${BD_data}/android/m.zip ./www
73     zip -q -r -o ${WORKSPACE}/H5_BD_${BD_data}/ios/www.zip ./www
74     
75     if [[ "$Updata" == "yes" ]]
76     then
77         echo "進行H5自動更新"
78         #移動m包至接入層download目錄
79         mkdir -p /hxspace/production_test/webroot/mall/mall/download
80         rm -rf /hxspace/production_test/webroot/mall/mall/download/*
81         cp -rf ./H5_BD_${BD_data}/* /hxspace/production_test/webroot/mall/mall/download/
82     else
83         echo "取消H5環境自動更新"
84         
85     fi
86     
87 fi

接入層

 1 #!/bin/sh
 2 
 3 #判斷H5_BD_${BD_data}目錄是否存在
 4 BD_data=$(date +"%F")
 5 
 6 #當日打包多次的情況下,初始化補丁目錄
 7 if [ -d "BD_${BD_data}" ]; then
 8     echo "今日補丁目錄已存在,進行補丁目錄初始化"
 9     
10     # 補丁目錄初始化
11     rm -rf ./BD_${BD_data}/Webapp/*        
12 else
13 
14     #建立補丁目錄
15     mkdir -p ./BD_${BD_data}/Webapp
16     
17 fi
 1 #!/bin/bash
 2 #find ./www0/m/trade -name ".svn" -exec rm -rf {} \;
 3 # rm svn file  
 4   
 5 echo ${WORKSPACE}
 6 
 7 
 8 if [[ ! -d ${WORKSPACE} ]]; then
 9     echo "not dir"
10     return
11 fi
12 
13 SAVEIFS=$IFS;
14 IFS=$'\n'
15 rmDirSvn(){
16     
17     cd ${WORKSPACE};
18     
19     countF=`ls -A | wc -l` 
20     if [[ $countF -eq 0 ]]; then
21         cd ./../
22         echo ${WORKSPACE} is null
23         return;
24     fi
25     countF=`find . -name ".svn" -mindepth 2 -maxdepth 7`
26     echo $countF
27     for fileD in $countF; do
28         
29         if [[ -d $fileD ]]; then
30             echo $fileD
31             rm -rf $fileD
32 
33         elif [[ ! -e $fileD ]]; then
34                 echo $fileD not exist
35         fi
36         
37     done
38 }
39 
40 rmDirSvn ${WORKSPACE};
41 IFS=$SAVEIFS
 1 #!/bin/sh
 2 #臨時改變BUILD_ID值,使得Jenkins不會找到並結束掉run.sh啟動的後臺程式
 3 OLD_BUILD_ID=$BUILD_ID
 4 echo $OLD_BUILD_ID
 5 BUILD_ID=dontKillMe
 6 #獲取BD_data
 7 BD_data=$(date +"%F")
 8 
 9 sleep 5s
10 
11 #移動最新WEB目錄至工程路徑下
12 cp -rf ./Web_Source/target/huaxi_thinkmall_web-1.0.0-SNAPSHOT/* ./BD_${BD_data}/Webapp
13     
14 #移動同步檔案檔案至工程路徑下
15 #cp -rf /hxspace/production/webroot/mall/upload/* ./BD_${BD_data}/Webapp/mall/upload
16 
17 #移動自動更新檔案檔案至工程路徑下
18 mkdir -p ./BD_${BD_data}/Webapp/mall/download
19 #cp -rf /hxspace/production/webroot/mall/download/* ./BD_${BD_data}/Webapp/mall/download
20 
21 #移動覆蓋WEB部署classes下配置檔案
22 cp -rf ./Web_Source/src/config/${Env}/classes/* ./BD_${BD_data}/Webapp/WEB-INF/classes/
23 
24 #移動覆蓋WEB部署/m/mall/下配置檔案
25 cp -rf ./Web_Source/src/config/${Env}/webapp/m/mall/* ./BD_${BD_data}/Webapp/m/mall/
26 
27 #移動覆蓋WEB部署啟動index檔案
28 cp -rf ./Web_Source/src/config/${Env}/index.html ./BD_${BD_data}/Webapp
29 
30 
31 #清空patches目錄下,相關檔案
32 mkdir -p /mnt/patches/BD_${BD_data}/HX_ChenDu_LC_Mall_WEB_Linux_Test/
33 rm -rf /mnt/patches/BD_${BD_data}/HX_ChenDu_LC_Mall_WEB_Linux_Test/*
34 
35 #移動部署檔案patches目錄下
36 cp -rf ./BD_${BD_data}/Webapp/* /mnt/patches/BD_${BD_data}/HX_ChenDu_LC_Mall_WEB_Linux_Test

 

相關文章