#!/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.java
# allow job control
set -mweb
application_dir="server-name"tomcat
# current directory that is tomcat home directory
cur_dir=$(pwd)
echo $cur_dirbash
#
cd $cur_dir
mkdir -p webapps/$application_dirapp
# set backup dir
backup="backup"webapp
# set the war backup
cur_time=$(date +%F-%H-%M-%S) maven
# war backup
#/bin/mv -f *.war $backup/$(cur_time).warthis
# stop the tomcat server
ps aux | grep java | grep $cur_dir | awk '{print $2}' | xargs kill -9server
# webapps backup
mv webapps/$application_dir/ ./$backup/webapp.`date +%F-%H-%M-%S`ip
#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`