shell 自动部署替换版本和备份

#!/bin/sh
tm=`date "+%Y%m%d-%H:%M"`
home_path=/home/tool_file
web_source=/opt/server/tomcat/webapps
his_version_path=/data/client/his_version/$tm
if [ -f "$home_path/version/client_web.war" ];then
        unzip $home_path/version/pics_client_web.war -d $home_path/version/client_web
else
        echo 'Package does not exist'
fi
if [ -f "$home_path/version/pics_client_web/WEB-INF/classes/spring-context.xml" ];then
        \cp $home_path/config/spring-context.xml $home_path/version/client_web/WEB-INF/classes/spring-context.xml
fi
if [ -f "$home_path/version/jsapi/Config.js" ];then
        \cp $home_path/config/Config.js $home_path/version/jsapi/Config.js
fi
for i in {1..5}
        do
                #count$i=`ps -ef|grep tomcat|grep -v grep|wc -l`
                if [ `ps -ef|grep tomcat|grep -v grep|wc -l` -eq 0 ];then
                        echo 'the process 8080 is not exit'
                        break
                else
                        ps -ef|grep tomcat|grep -v grep|awk '{print $2}'|xargs kill -9
                        echo 'Kill the process'
                fi
        done
mkdir  $his_version_path
if [ -d "$his_version_path" ];then
        echo 'Backup the last deployed version'
        mv $web_source/client_web $his_version_path/
        echo 'Deploying a new version'
        mv $home_path/version/client_web $web_source
        echo 'Start server'
        sh $web_source/../bin/startup.sh
        rm -rf $home_path/version/*
fi

转载于:https://www.cnblogs.com/colin2012/p/8610522.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值