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_pid15 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 fi20 21 rm -rf $code_dir/*22 echo "delete last $war_name project files $code_dir"23 24 25 #解压war包到 代码执行地方26 cd $war_dir27 echo "unzip $war_name to $code_dir"28 unzip -oq $war_name -d $code_dir/29 30 31 #重启tomcat32 cd $tomcat_dir/bin33 sh startup.sh34 35 sleep 536 tomcatport=`sudo netstat -lntp|grep "8081"|awk '{print $4}'|awk -F":" '{print $2}'`37 echo $tomcatport38 39 if [ "$tomcatport" ];then40 echo -e "\033[32m[ tomcat started success on $current_env ! ]\033[0m"41 fi