首页 > 代码库 > linux自动化创建补丁

linux自动化创建补丁

BUS

 1 #!/bin/sh
 2 
 3 #判断H5_BD_${BD_data}目录是否存在
 4 BD_data=http://www.mamicode.com/$(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=http://www.mamicode.com/$(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=http://www.mamicode.com/$(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=http://www.mamicode.com/$(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=http://www.mamicode.com/$(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

 

linux自动化创建补丁