#!/bin/bash
# Description: # We should enter into tomcat home directory and sz a war, then we can execute this script. # Use "mvn clean package -Dmaven.test.skip=true -Dskiptests=true -P env-prod" command to get the war.# allow job control
set -mapplication_dir="server-name"
# current directory that is tomcat home directory
cur_dir=$(pwd) echo $cur_dir#
cd $cur_dir mkdir -p webapps/$application_dir# set backup dir
backup="backup"# set the war backup
cur_time=$(date +%F-%H-%M-%S)# war backup
#/bin/mv -f *.war $backup/$(cur_time).war# stop the tomcat server
ps aux | grep java | grep $cur_dir | awk '{print $2}' | xargs kill -9# webapps backup
mv webapps/$application_dir/ ./$backup/webapp.`date +%F-%H-%M-%S`#delete work directory
/bin/rm -rf $cur_dir/work/# unzip
unzip -d $cur_dir/webapps/$application_dir *.war#start the tomcat server
$cur_dir/bin/catalina.sh start#
#tail -f $cur_dir/logs/catalina.out tail -f $cur_dir/logs/catalina.out.`date +%Y-%m-%d`