tomcat版本一键升级脚本

脚本没有较完整的通用性,但升级的思路基本是一致的。

#!/bin/bash
#
. /etc/profile
workpath=/cache1/web
version="apache-tomcat-6.0.41"
time=`date "+%Y%m%d%H%M"`
cd $workpath
mkdir -p $workpath/appbak
/etc/init.d/tomcat-xxx-service stop
sleep 2
portal=(xxx ex xas zms)
for portal in ${portal[@]}
do
sleep 1
tar -zxf "$version".tar.gz 2>&1 > /dev/null
mv "$version" new-xxx-$portal
rm -rf new-xxx-$portal/webapps/* 2>&1 > /dev/null
\cp -a zms-$portal/bin/catalina.sh new-xxx-$portal/bin/
\cp -a zms-$portal/conf/{server.xml,web.xml} new-xxx-$portal/conf/
\cp -a zms-$portal/webapps/* new-xxx-$portal/webapps/
\cp -a zms-$portal/conf/.keystore new-xxx-$portal/conf/ 2>&1 > /dev/null
chown tomcat:tomcat -R new-xxx-$portal && chmod +x new-xxx-$portal/bin/*.sh
chmod 750 new-xxx-$portal/webapps/$portal
mv -f zms-$portal appbak/zms-$portal-$time && mv new-xxx-$portal zms-$portal
echo "update $portal success"
sh $workpath/zms-$portal/bin/version.sh
done
/etc/init.d/tomcat-xxx-service start
weinxin
聂扬帆博客
一个分享IT运维相关工作经验和实战技巧的个人博客

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: