跳板机上的发布脚本:
$ cat copy_h5mall.sh #!/bin/sh #只做SAAS copy h5 mall nginx_static_ip=10.10.80.22 time_stamp=`date +"%Y-%m-%d-%H-%M-%S"` h5_mall_zip_name=$1 war_md5=`md5sum ../static/${h5_mall_zip_name} | awk ‘{print $1}‘` md5_file=`cat ../static/${h5_mall_zip_name}.md5 | awk ‘{print $1}‘` if [ "${war_md5}" = "${md5_file}" ];then ssh ${nginx_static_ip} "cp -r /data/static/all/h5_mall /data/static/all/h5_mall-${time_stamp}" ssh ${nginx_static_ip} "cd /data/static/all/h5_mall && /bin/rm -rf *" scp ../static/${h5_mall_zip_name} ${nginx_static_ip}:/data/static/all/h5_mall/ ssh ${nginx_static_ip} "cd /data/static/all/h5_mall && unzip ${h5_mall_zip_name}" fi ip_list=`cat ../env.sh | grep "frontier-cms-web" | cut -d "=" -f1 | cut -d "#" -f2 | uniq` scp ../static/${h5_mall_zip_name} ${ip_list}:/tmp sleep 5; #调用frontier-cms-web 服务器上的另一个脚本 ssh ${ip_list} "cd /data/static && sh deploy_h5_mall.sh ${h5_mall_zip_name}"
#脚本拆开运行,frontier-cms-web 服务器地址:
$ cat ../env.sh | grep "frontier-cms-web" | cut -d "=" -f1 | cut -d "#" -f2 | uniq 10.10.80.16
#frontier-cms-web服务器上的静态资源目录每个conmand Id目录都需要发布:
[vm10-10-80-16 static]$ ls 1 1002 1003 1006 1007 1008 11009 11010 11011 6 deploy_h5_mall.sh deploy_pc_mall.sh [ody@vm10-10-80-16 static]$ ls 1002 1003 1002: h5_mall h5_mall1108 h5_mall12071548 h5_mall.bak pc_mall1110 pc_mall1116 pc_mall12062009 pc_mall12211923 h5_mall1107 h5_mall1207 h5_mall1221 pc_mall pc_mall1115 pc_mall1130 pc_mall1207 1003: h5_mall h5_mall1108 h5_mall1207 pc_mall pc_mall1130 pc_mall1207 h5_mall1107 h5_mall11301833 h5_mall1221 pc_mall1110 pc_mall1206 pc_mall12211923
#frontier-cms-web 服务器上之前写的一个的发布脚本,不够自动化还需要登录这台机器运行:
[vm10-10-80-16 static]$ cat deploy_h5_mall.sh #!/bin/sh war=$1 Time=`date "+%Y-%m-%d-%H-%M"` for dir in `ls /data/static | egrep -v deploy_"(pc|h5)"_mall.sh`;do echo ${dir} cd /data/static/${dir} && cp -r h5_mall h5_mall_"${Time}" cd /data/static/${dir}/h5_mall/ && rm -rf * cp /tmp/${war} /data/static/${dir}/h5_mall/ cd /data/static/${dir}/h5_mall && unzip "${war}" done
本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1900877
原文:http://215687833.blog.51cto.com/6724358/1900877