shell-automatically deploy the war package to Tomcat

Source: Internet
Author: User

#!/bin/sh


Curl=$1
Crootdir=/data/tomcat/tomcat-usercenter
Shrootdir=/data/tomcat/dll


#delete old version
RM-RF $shRootDir/usercenter-web.war*


#默认war包地址为jenkins上最后一次打包成功的url
if [$cURL = 0]
Then
curl=http://192.168.2.239:9000/view/development/job/dev-usercenter-branches/lastsuccessfulbuild/artifact/ Usercenter-web/target/usercenter-web.war
Fi


echo "--------------get War and deploy------------"
cpid=$ (ps-ef |grep Tomcat-[user]|awk ' {print $} ')
Kill-9 $cpid
CD $shRootDir
wget $cURL
Sleep 10
CD $cRootDir
RM-RF webapps/* work/* logs/*
CP $shRootDir/usercenter-web.war $cRootDir/webapps/
$cRootDir/bin/startup.sh >>/dev/temp
Sleep 10


echo "--------------change Dimaond.property------------"
cpid=$ (ps-ef |grep Tomcat-[user]|awk ' {print $} ')
Kill-9 $cpid
CD $cRootDir/webapps/usercenter-web/web-inf/classes/spring
Sed-i "S/production/test/g" diamond.properties

#修改jar包的文件, first unzip with unzip, then replace the file with zip separately
echo "---------------Change Memcached.xml--------------"
CD $cRootDir/webapps/usercenter-web/web-inf/lib
Unzip usercenter-biz-service-impl-1.0.0.jar-d Usercenter
Sleep 2
Sed-i "s/192.168.59.69:5005/192.168.2.200:11211/g"./usercenter/memcached.xml
CP./usercenter/memcached.xml./memcached.xml
Zip-m Usercenter-biz-service-impl-1.0.0.jar./memcached.xml
RM-RF Usercenter


echo "--------------start tomcat------------"
$cRootDir/bin/startup.sh
TAILF $cRootDir/logs/catalina.out

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Shell-automatically deploy the war package to Tomcat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.