tomcat war包自动化部署脚本

 1 #/bin/bash
 2 
 3 #带发布build的war包名称
 4 war_name="weiFeng.war"
 5 war_dir="/home/deploy/wei_feng_targets/dev"
 6 code_dir="/home/deploy/wei_feng_targets/dev/deploy_files"
 7 tomcat_dir="/home/deploy/tomcat/tomcat-7.0.75-wei-feng-8081-8082"
 8 current_env="wei-feng-dev"
 9 
10 
11 # kill tomcat进程
12 tomcat_pid=`cat $tomcat_dir/bin/tomcat_pid`
13 
14       kill -9 $tomcat_pid
15       if [ $? -ne 0 ];then 
16                echo -e "\033[31m\033[01m [   old tomcat kill failed  ]\033[0m"
17       else 
18              echo -e "\033[32m[  kill old tomcat success with pid: $tomcat_pid ]\033[0m"
19       fi
20 
21 rm -rf $code_dir/*
22 echo "delete last $war_name  project files $code_dir"
23 
24 
25  #解压war包到 代码执行地方
26 cd $war_dir
27 echo "unzip $war_name to $code_dir"
28 unzip -oq $war_name -d $code_dir/
29 
30 
31 #重启tomcat
32 cd $tomcat_dir/bin
33 sh startup.sh
34 
35 sleep 5
36 tomcatport=`sudo netstat -lntp|grep "8081"|awk '{print $4}'|awk -F":" '{print $2}'`
37 echo $tomcatport
38 
39 if [ "$tomcatport" ];then
40           echo -e "\033[32m[ tomcat started success on $current_env !  ]\033[0m"
41 fi

猜你喜欢

转载自www.cnblogs.com/weifeng1463/p/9200861.html