Shell-automatically deploy the war package to tomcat

Source: Internet
Author: User

Shell-automatically deploy the war package to tomcat
#! /Bin/sh


CURL = $1
CRootDir =/data/tomcat-usercenter
ShRootDir =/data/tomcat/dll


# Delete old version
Rm-rf $ shRootDir/usercenter-web.war *


# The default war package address is the last successfully packaged url of jenkins.
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 $2 }')
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 $2 }')
Kill-9 $ cpid
Cd $ cRootDir/webapps/usercenter-web/WEB-INF/classes/spring
Sed-I "s/production/test/g" diamond. properties

# Modify the jar package file. decompress the package with unzip and replace the file with zip.
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

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.