#-------------------------delete old war------------- cd /opt/tomcat/ rm -f whitelist*.war
#----------------------------get war---------------- wget http://xxx.xxx/whitelist.war filesize=`ls -l "whitelist.war" | awk '{ print $5 }'` maxsize=$((1024*10)) if [ $filesize -lt $maxsize ] then echo "filesize wrong.end." exit fi
#-------------------------update war------------------- tomcat_array=("/opt/tomcat/tomcat1_query" "/opt/tomcat/tomcat2_query" "/opt/tomcat/tomcat3_query") for tomcatOne in ${tomcat_array[*]} do THIS_TC_INSTANCE=${tomcatOne} THIS_APP_MODULE='whitelist'
echo '-------------' echo ${tomcatOne} echo '-------------' pid=`ps -ef|grep ${THIS_TC_INSTANCE}|grep -v 'grep'|grep 'java'|awk '{print $2}'` if [ -z $pid ] ; then echo 'Tomcat '${THIS_TC_INSTANCE}' is not running' else echo 'Shutting down Tomcat at '${THIS_TC_INSTANCE} ${THIS_TC_INSTANCE}/bin/shutdown.sh sleep 5 fi
pid=`ps -ef|grep ${THIS_TC_INSTANCE}|grep -v 'grep'|grep 'java'|awk '{print $2}'` if [ -z $pid ] ; then echo 'Tomcat '${THIS_TC_INSTANCE}' has been shut down' else echo 'Tomcat '${THIS_TC_INSTANCE}' didnot exit normally, now killing the PID:'${pid} ps -ef|grep ${THIS_TC_INSTANCE}|grep -v 'grep'|grep 'java'|awk '{print $2}'|xargs kill -s 9 fi
echo '' echo 'Removing old deployments' rm -f ${THIS_TC_INSTANCE}/webapps/${THIS_APP_MODULE}.war rm -rf ${THIS_TC_INSTANCE}/webapps/${THIS_APP_MODULE} rm -rf ${THIS_TC_INSTANCE}/work/Catalina echo 'Copying new deployments' echo '' cp -f /opt/tomcat/${THIS_APP_MODULE}.war ${THIS_TC_INSTANCE}/webapps/ echo 'Startup tomcat' ${THIS_TC_INSTANCE}/bin/startup.sh done echo '-----------done----------------'
|