linux服务器批量部署应用系统shell脚本(Tomcat/jetty)

时间:2022-08-17 20:02:59

linux服务器批量部署应用系统shell脚本:

1.请更换代码内的服务器地址(Tomcat或jetty服务器)

serverRoot=/home/undoner/java_tool/apache-tomcat-7.0.61
serverDir=/home/undoner/java_tool/apache-tomcat-7.0.61/webapps

2.请更换工程所属配置文件名称

/WEB-INF/classes/install.properties

3.请将war包上传至本命令同级的目录,执行即可,xxxxx为工程名字。

./install.sh xxxxx

#!/bin/bash
#Please replace 'serverRoot' and 'serverDir' in your tomcat workspace
#The batch installation script By undoner 2013.01.01 if [ ! -z $1 ];then
ss=$1
else
ss=''
fi
serverDate=$(date +%Y%m%d)
serverRoot=/home/undoner/java_tool/apache-tomcat-7.0.61
serverDir=/home/undoner/java_tool/apache-tomcat-7.0.61/webapps
for i in $ss;do
serverBackup=$serverRoot"/backup/"$i"_"$serverDate
echo "install $i at $serverDate"
echo "serverRoot:$serverRoot"
echo "serverDir:$serverDir"
echo "serverBackup:$serverBackup"
cp -r $serverDir/$i $serverBackup
cp $serverDir/$i/WEB-INF/classes/install.properties ./install.properties
rm -rf $serverDir/$i/*
mv ./$i.war $serverDir/$i/
cd $serverDir/$i/
jar xf $i.war
cd $OLDPWD
mv ./install.properties $serverDir/$i/WEB-INF/classes/
echo "install/update $i success at $serverDate."
done