# !bin/bash log_time=`date +%Y%m%d%H%M%S` tomcat_home=/usr/local/zmqsd/apache-tomcat-7.0.54 tomcat_port=7777 check_tomcat_status(){ netstat -ant|grep ${tomcat_port} > /dev/null t=$? if [ $t -eq 0 ];then echo "tomcat is running...... port is ${tomcat_port}" echo ">>>>>>>>>>>>shutdown tomcat begin<<<<<<<<<<<<<<<<" ${tomcat_home}/bin/shutdown.sh echo ">>>>>>>>>>>>shtudown tomcat end <<<<<<<<<<<<<<<<<" sleep 10 elif [ $t -ne 0 ]; then echo "tomcat is poweroff" ${tomcat_home}/bin/shutdown.sh sleep 10 fi } check_tomcat_status deploy_loaction=${tomcat_home}/webapps/ROOT/ war_dir=/usr/war/ war_dir_ls=`ls ${war_dir}` war_name=mysteel-article-mgt-1.0-SNAPSHOT.war deploy_tomcat(){ if [ -z $war_dir_ls ];then echo "Folder ${war_dir} is empty.please check war package in this folder!" exit 1 else echo "-------------- begin transfer war package to tomcat webapps -------------------" echo "Find ${war_dir} exist war package ${war_name}" echo "deleteing old package ${war_name} in ${deploy_loaction}" rm ${deploy_loaction}${war_name} echo "start transfer ${war_name} to ${deploy_loaction}" cp ${war_dir}${war_name} ${deploy_loaction} unzip ${war_dir}${war_name} -d ${deploy_loaction} sleep 3 echo "-------------- transfer war package to tomcat webapps end -------------------" fi #reboot tomcat echo " >>>>>>> rebooting tomcat begin <<<<<<<<" ${tomcat_home}/bin/startup.sh echo " >>>>>>> rebooting tomcat end <<<<<<<<" echo "the log you can read in canalina.out" echo "************************ deploy war package into container Successlly **********************************" } deploy_tomcat