tomcat 回滾腳本
#!/bin/bash
#
# Artems rollback Script.
# Author: Rui.Xu
# Time: 07/2018
#
rm -fr /app/tmp/artemis.war
dir1=/app/tmp/backup-package/
dir2=`ls -l $dir1 | tail -n1 |awk '{print $NF}'`
yes | cp $dir1$dir2/artemis-* /app/tmp/artemis.war
#/etc/init.d/artemis stop
ps -aux | grep /app/apps/artemis/tomcat | grep -v grep | awk '{print $2}' | while read pid
do
echo "tomcat is running, to kill bootstrap pid=$pid"
kill -9 $pid
echo "kill result:[ $? ] 0=ok"
done
sleep 3s
rm -rf /app/apps/artemis/tomcat/webapps/*
rm -rf /app/apps/artemis/tomcat/work
rm -rf /app/apps/artemis/tomcat/temp/*
mkdir /app/apps/artemis/tomcat/webapps/artemis
cp /app/tmp/artemis.war /app/apps/artemis/tomcat/webapps/artemis
cd /app/apps/artemis/tomcat/webapps/artemis
unzip artemis.war &> /dev/null
cd /
rm -rf /app/apps/artemis/tomcat/webapps/artemis/artemis.war
rm -rf /app/apps/artemis/tomcat/webapps/artemis/WEB-INF/lib/mysql-connector-java-5.1.37.jar
yes | cp -f /app/tmp/logback-spring.xml /app/apps/artemis/tomcat/webapps/artemis/WEB-INF/classes/
yes | cp -f /app/tmp/logback-spring.xml /app/apps/artemis/tomcat/webapps/artemis/WEB-INF/classes/config/log/logback-didiprod.xml
yes | cp -f /app/tmp/font/simsun.ttc /app/apps/artemis/tomcat/webapps/artemis/WEB-INF/classes/font
sleep 1
/etc/init.d/artemis start &> /dev/null
sleep 5
ID=`ps -aux | grep /app/apps/artemis/tomcat | grep -v grep | awk '{print $2}'`
if [ ! "$ID" = "" ]
then
echo -e "\033[33m Artemis is already running, and his pid is: [ $ID ] \033[0m"
else
echo -e "\033[5;33m Artemis run [ Failed ] \033[0m"
fi
sleep 2
echo '======================================================================='
echo "+ Real-time logging is coming /home/mnt/app/logs/artemis/artemis.log +"
echo '======================================================================='
sleep 2
tail -f /home/mnt/app/logs/artemis/artemis.log
#END
tomcat 回滾腳本