會員註冊 / 登入  |  電腦版  |  Jump to bottom of page

Application Server » Tomcat 6版本升級自動化程式

發表人: andowson, 七段學員
2009-06-20 17:17:26
Tomcat 6沒有common這個目錄,所以我修改了一下原本的版本升級自動化程式

簡單來說,前一版的Tomcat安裝的樣子
/var/apache-tomcat-6.0.29
/var/tomcat6->/var/apache-tomcat-6.0.29
/var/webapps
新版的Tomcat要安裝成
/var/apache-tomcat-6.0.30
/var/tomcat6->/var/apache-tomcat-6.0.30
/var/webapps(不動)

tomcat6-upgrade.sh:

#!/bin/bash
# Name: Tomcat 6.x auto-upgrade installer
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.7
# Since: 2006-04-30
# Last Modified: 2011-01-31
#
# check the installed version of Tomcat 6.0
#
OLD_VERSION=`ls -l /var | grep tomcat6|awk '{print $11}'|cut -d "-" -f3`
#
# check the latest stable version of Tomcat 6.0
#
wget http://tomcat.apache.org/whichversion.html -q -t 1 -T 5 -O /tmp/tomcat.html
if [ -s /tmp/tomcat.html ]; then
TOMCAT_VERSION=`grep "6\.0\." /tmp/tomcat.html|grep -v "6\.0\.x"|cut -d">" -f2|cut -d"<" -f1`
fi
rm -rf /tmp/tomcat.html

echo "Install Tomcat ${TOMCAT_VERSION}"
if [ ! -r apache-tomcat-${TOMCAT_VERSION}.tar.gz ]; then
wget http://apache.ntu.edu.tw/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz
fi
tar zxvf apache-tomcat-${TOMCAT_VERSION}.tar.gz -C /var
cp /var/apache-tomcat-${OLD_VERSION}/bin/setenv.sh /var/apache-tomcat-${TOMCAT_VERSION}/bin

#
# find out old jar files that you put in lib yourself
#
if [ ! -r apache-tomcat-${OLD_VERSION}.tar.gz ]; then
wget http://apache.ntu.edu.tw/tomcat/tomcat-6/v${OLD_VERSION}/bin/apache-tomcat-${OLD_VERSION}.tar.gz
fi
tar zxvf apache-tomcat-${OLD_VERSION}.tar.gz -C /tmp
ls -sort /tmp/apache-tomcat-${OLD_VERSION}/lib | awk '{print $9}' > /tmp/dist.txt
ls -sort /var/apache-tomcat-${OLD_VERSION}/lib | awk '{print $9}' > /tmp/installed.txt
comm -23 /tmp/installed.txt /tmp/dist.txt > /tmp/jarlist.txt
rm -rf /tmp/apache-tomcat-${OLD_VERSION} /tmp/dist.txt /tmp/installed.txt
#
# copy old jar files into new lib directory
#
for file in `cat /tmp/jarlist.txt`
do
cp -p /var/apache-tomcat-${OLD_VERSION}/lib/${file} /var/apache-tomcat-${TOMCAT_VERSION}/lib
done
#
# copy logging jar files into new lib directory
#
wget http://apache.ntu.edu.tw/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/extras/tomcat-juli.jar -O /var/apache-tomcat-${TOMCAT_VERSION}/lib/tomcat-juli.jar
wget http://apache.ntu.edu.tw/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/extras/tomcat-juli-adapters.jar -O /var/apache-tomcat-${TOMCAT_VERSION}/lib/tomcat-juli-adapters.jar

service httpd stop
service tomcat stop
rm -rf /var/tomcat6
ln -s /var/apache-tomcat-${TOMCAT_VERSION} /var/tomcat6
service tomcat start
service httpd start


附檔是Linux上自動化更新的程式,下載附檔儲存到/root/setup/web下,並修改權限為755可執行,然後以root身份執行即可。

檔案名稱 tomcat6-upgrade.sh
描述 Tomcat 6.x auto-upgrade installer
檔案大小 2 Kbytes
下載次數 26 次
[Disk] 下載


發表人: Enix, 十級學員
2009-12-31 09:47:56
感謝分享~
但這要給ubuntu或debian用, 還得做些修改吧?

發表人: andowson, 七段學員
2009-12-31 12:08:30
Enix您好,我沒用過unbuntu和debian,您可以自己測試看看。




會員註冊 / 登入  |  電腦版  |  Jump to top of page