練功房推薦書單

  • 猛虎出柙雙劍合璧版--最新 OCA / OCP Java SE 7 Programmer 專業認證 (電子書)
  • 流浪教師存零股存到3000萬(全新增修版)(書+DVD)
  • 開始在關西自助旅行(京都‧大阪‧神戶‧奈良)(全新增訂版)
  • 不敗教主的300張股票存股術

Tomcat 6版本升級自動化程式 RSS feed
Forum Index » Tomcat
Author Message
andowson

七段學員
[Avatar]

Joined: 2007/1/2
Messages: 709
Location: 台北
Online
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身份執行即可。
 Filename tomcat6-upgrade.sh [Disk] Download
 Description Tomcat 6.x auto-upgrade installer
 Filesize 2 Kbytes
 Downloaded:  26 time(s)


分享經驗 累積智慧
[WWW]
Enix

十級學員

Joined: 2009/12/30
Messages: 1
Offline
感謝分享~
但這要給ubuntu或debian用, 還得做些修改吧?
andowson

七段學員
[Avatar]

Joined: 2007/1/2
Messages: 709
Location: 台北
Online
Enix您好,我沒用過unbuntu和debian,您可以自己測試看看。

分享經驗 累積智慧
[WWW]
 
Forum Index » Tomcat
Go to:   
Mobile view