Shell-automatically deploy war packages to tomcat and shell-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
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.