Linux server batch deployment application system shell script (Tomcat/jetty)

Linux server batch deployment application system shell script:

1. Please replace the server address in the code (Tomcat or jetty server)

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

2. Please change the name of the configuration file to which the project belongs

/WEB-INF/classes/install.properties

3. Please upload the war package to the directory at the same level of this command and execute it. xxxxx is the project name.

./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


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324101560&siteId=291194637