#! /bin/bash
if [ ! $1 ]
then
echo "this command needs 1 parameters"
exit
fi
if [ -d "/usr/local/nginx/html/xxxx-$1" ]
then
echo "file exists: /usr/local/nginx/html/xxxx-$1, please check input parameters"
exit
fi
if [ ! -f "~/xxxx.zip" ]
then
echo "file not exists: ~/xxxx.zip"
exit
fi
echo "start version updating..."
echo "starting back old web static files..."
mv xxxx xxxx-back-$1
echo "unzip new web static files..."
unzip ~/xxxx.zip -d /usr/local/nginx/html
echo "version update finished!"
#! /bin/bash
if [ ! $1 ]
then
echo "this command needs 1 parameters"
exit
fi
if [ -f "/home/apache-tomcat-8.5.84/webapps/xxxx.war.$1back" ]
then
echo "file exists: /home/apache-tomcat-8.5.84/webapps/xxxx.war.$1back, please check input parameters"
exit
fi
if [ ! -f "~/xxxx.war" ]
then
echo "file not exists: ~/xxxx.war"
exit
fi
echo "start version updating..."
echo "shutting down Tomcat server..."
/home/apache-tomcat-8.5.84/bin/shutdown.sh
sleep 15s
netstat -nptl
echo "Tomcat server shut down."
echo "starting back war..."
mv /home/apache-tomcat-8.5.84/webapps/xxxx.war /home/apache-tomcat-8.5.84/webapps/xxxx.war.$1back
echo "deleting old webApp file archive..."
rm -rf /home/apache-tomcat-8.5.84/webapps/xxxx
echo "copying new version webApp to Tomcat server..."
cp ~/xxxx.war /home/apache-tomcat-8.5.84/webapps
echo "restarting Tomcat server..."
/home/apache-tomcat-8.5.84/bin/startup.sh
sleep 15s
netstat -nptl
echo "version update finished!"
参考: Shell脚本编程30分钟入门