本地tomcat启动war包_「shell脚本」懒人运维之自动升级tomcat应用(war包)
生活随笔
收集整理的這篇文章主要介紹了
本地tomcat启动war包_「shell脚本」懒人运维之自动升级tomcat应用(war包)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
準備:
腳本:
#!/bin/bash# Program:#This script is used for update tomcat.# History:# 2019/12/05YosonFirst releaseexport tomcat1="/opt/run/tomcat1"export tomcat2="/opt/run/tomcat2"txt="tomcat1|tomcat2 warFile"update() { echo "Update..." #file=${2##*/} #echo file=$file dir=${file%.*}#echo $dir tomcat=$(eval echo $$1)#echo tomcat=$tomcat sourceDir=$tomcat/webapps/$dir#echo sourceDir=$sourceDir destinationDir=`dirname $2`#echo destinationDir=$destinationDir sourceFile=${sourceDir}.war#echo sourceFile=$sourceFile /etc/init.d/${1}Tomcat stop 2>/dev/null [ -d $sourceDir ] && mv $sourceDir $destinationDir/${dir}.`date -I` [ -f $sourceFile ] && rm -f $sourceFile cp -f $2 $tomcat/webapps/ /etc/init.d/${1}Tomcat start}# 如果參數(shù)有兩個,則往下執(zhí)行,否則提示使用說明if [ $# = '2' ];then export file=${2##*/} #echo file=$file #echo ${file#*.} # 如果參數(shù)2存在且為正常的war文件,則往下執(zhí)行,否則提示文件不存在或不合法 if [ -f $2 -a "${file#*.}" = "war" ];thencase "$1" in tomcat1|tomcat2)update $1 $2;; *)echo "Usage: $0 $txt"exit 1esac else echo "$0: cannot stat ‘$2’: No such file or the file is not a war file" fielse echo "Usage: $0 $txt"fi總結
以上是生活随笔為你收集整理的本地tomcat启动war包_「shell脚本」懒人运维之自动升级tomcat应用(war包)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux文本运行层次,Linux基础知
- 下一篇: php curl_error源码,PHP