<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Tomcat及Tomcat JK Connector版本升級自動化程式"]]></title>
		<link>https://forum.andowson.com/posts/list/20.page</link>
		<description><![CDATA[Latest messages posted in the topic "Tomcat及Tomcat JK Connector版本升級自動化程式"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Tomcat及Tomcat JK Connector版本升級自動化程式</title>
				<description><![CDATA[ Tomcat最近發佈的[url=http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0774]安全漏洞[/url]屬於critical，故如果有使用Tomcat 5.5.20和JK Connector 1.2.19或1.2.20的網站便需要更新。 
<br>
<br>
 :arrow:[b]升級Tomcat[/b] 
<br>
如果您跟我一樣是把不同版本的Tomcat 安裝在不同目錄下，然後再設定一個符號連結至執行用版本，並把webapps放在獨立於Tomcat安裝目錄外的統一的目錄下，則升級的動作很單純，就是安裝好新版的Tomcat，然後把舊版中的common/lib下的一些jar檔，common/classes下的一些properties檔或class檔，bin下的setenv.sh等複製過去即可。 
<br>
<br>
簡單來說，前一版的Tomcat安裝的樣子 
<br>
/var/apache-tomcat-5.5.20 
<br>
/var/tomcat5-&gt;/var/apache-tomcat-5.5.20 
<br>
/var/webapps 
<br>
新版的Tomcat要安裝成 
<br>
/var/apache-tomcat-5.5.23 
<br>
/var/tomcat5-&gt;/var/apache-tomcat-5.5.23 
<br>
/var/webapps(不動) 
<br>
<br>
tomcat-upgrade.sh: 
<br>
[code] 
<br>
#! /bin/bash 
<br>
# Name: Tomcat 5.x auto-upgrade installer 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 1.4 
<br>
# Since: 2006-04-30 
<br>
# Last Modified: 2007-09-16 
<br>
# 
<br>
# check the installed version of Tomcat 5.5 
<br>
# 
<br>
OLD_VERSION=`ls -l /var | grep tomcat5|awk '{print $11}'|cut -d "-" -f3` 
<br>
# 
<br>
# check the latest stable version of Tomcat 5.5 
<br>
# 
<br>
wget http://tomcat.apache.org/index.html -q -t 1 -T 5 -O /tmp/tomcat.html 
<br>
if [ -s /tmp/tomcat.html ]; then 
<br>
 TOMCAT_VERSION=`grep "5\.5\." /tmp/tomcat.html|grep -v "5\.5\.x"|cut -d"&gt;" -f2|cut -d"&lt;" -f1` 
<br>
fi 
<br>
rm -rf /tmp/tomcat.html 
<br>
<br>
echo "Install Tomcat ${TOMCAT_VERSION}" 
<br>
if [ ! -r apache-tomcat-${TOMCAT_VERSION}.tar.gz ]; then 
<br>
 wget http://apache.ntu.edu.tw/tomcat/tomcat-5/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz 
<br>
fi 
<br>
tar zxvf apache-tomcat-${TOMCAT_VERSION}.tar.gz -C /var 
<br>
cp /var/apache-tomcat-${OLD_VERSION}/bin/setenv.sh /var/apache-tomcat-${TOMCAT_VERSION}/bin 
<br>
<br>
# 
<br>
# find out old jar files that you put in common/lib yourself 
<br>
# 
<br>
ls -sort /var/apache-tomcat-${OLD_VERSION}/common/lib | awk '{print $9}' &gt; /tmp/old.txt 
<br>
ls -sort /var/apache-tomcat-${TOMCAT_VERSION}/common/lib | awk '{print $9}' &gt; /tmp/new.txt 
<br>
comm -23 /tmp/old.txt /tmp/new.txt &gt; /tmp/jarlist.txt 
<br>
rm -rf /tmp/old.txt /tmp/new.txt 
<br>
# 
<br>
# copy old jar files into new common/lib directory 
<br>
# 
<br>
for file in `cat /tmp/jarlist.txt` 
<br>
do 
<br>
 cp -rf /var/apache-tomcat-${OLD_VERSION}/common/lib/${file} /var/apache-tomcat-${TOMCAT_VERSION}/common/lib 
<br>
done 
<br>
<br>
# 
<br>
# find out old jar files that you put in common/endorsed yourself 
<br>
# 
<br>
ls -sort /var/apache-tomcat-${OLD_VERSION}/common/endorsed | awk '{print $9}' &gt; /tmp/old.txt 
<br>
ls -sort /var/apache-tomcat-${TOMCAT_VERSION}/common/endorsed | awk '{print $9}' &gt; /tmp/new.txt 
<br>
comm -23 /tmp/old.txt /tmp/new.txt &gt; /tmp/jarlist.txt 
<br>
rm -rf /tmp/old.txt /tmp/new.txt 
<br>
# 
<br>
# copy old jar files into new common/endorsed directory 
<br>
# 
<br>
for file in `cat /tmp/jarlist.txt` 
<br>
do 
<br>
 cp -rf /var/apache-tomcat-${OLD_VERSION}/common/endorsed/${file} /var/apache-tomcat-${TOMCAT_VERSION}/common/endorsed 
<br>
done 
<br>
# 
<br>
# copy old properties and class files into new common/classes directory 
<br>
# 
<br>
cp -rf /var/apache-tomcat-${OLD_VERSION}/common/classes/* /var/apache-tomcat-${TOMCAT_VERSION}/common/classes 
<br>
service httpd stop 
<br>
service tomcat stop 
<br>
rm -rf /var/tomcat5 
<br>
ln -s /var/apache-tomcat-${TOMCAT_VERSION} /var/tomcat5 
<br>
service tomcat start 
<br>
service httpd start 
<br>
[/code] 
<br>
 :arrow:[b]更新Tomcat JK Connector[/b] 
<br>
把原始檔下載回來重新編譯make再make install即可 
<br>
<br>
tomcat-connector-upgrade.sh: 
<br>
[code]#! /bin/bash 
<br>
# Name: Tomcat Connector 1.2.x auto-upgrade installer 
<br>
# Author: Andowson Chang (andowson [at] gmail [dot] com) 
<br>
# Version: 0.1 
<br>
# Since: 2007-03-17 
<br>
# Last Modified: 2007-03-17 
<br>
# 
<br>
# check the latest stable version of Tomcat Connector 1.2 
<br>
# 
<br>
wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html 
<br>
if [ -s /tmp/connector.html ]; then 
<br>
 TC_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d"&gt;" -f2|cut -d"&lt;" -f1 | grep "1.2" | cut -d" " -f2 | uniq` 
<br>
fi 
<br>
rm -rf /tmp/connector.html 
<br>
echo "Install Tomcat Connector JK ${TC_VERSION}" 
<br>
if [ ! -r tomcat-connectors-${TC_VERSION}-src.tar.gz ]; then 
<br>
 wget http://apache.ntu.edu.tw/tomcat/tomcat-connectors/jk/source/jk-${TC_VERSION}/tomcat-connectors-${TC_VERSION}-src.tar.gz 
<br>
fi 
<br>
tar zxvf tomcat-connectors-${TC_VERSION}-src.tar.gz 
<br>
cd tomcat-connectors-${TC_VERSION}-src/native 
<br>
yum -y install httpd-devel libtool automake 
<br>
./buildconf.sh 
<br>
./configure --with-apxs=/usr/sbin/apxs 
<br>
make 
<br>
service httpd stop 
<br>
make install 
<br>
service httpd start[/code] 
<br>
<br>
這裡的[code]yum -y install httpd-devel libtool automake[/code] 
<br>
是為了解決及避免出現下面錯誤訊息 
<br>
[quote]rm autom4te.cache 
<br>
libtoolize --force --automake --copy 
<br>
./buildconf.sh: line 7: libtoolize: command not found 
<br>
aclocal 
<br>
./buildconf.sh: line 11: aclocal: command not found 
<br>
autoheader 
<br>
./buildconf.sh: line 13: autoheader: command not found 
<br>
automake -a --foreign --copy 
<br>
./buildconf.sh: line 15: automake: command not found 
<br>
autoconf 
<br>
./buildconf.sh: line 17: autoconf: command not found 
<br>
rm autom4te.cache[/quote] 
<br>
<br>
附檔是兩個Linux上自動化更新的程式，下載附檔儲存到/root/setup/web下，並修改權限為755可執行，然後以root身份執行即可。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/54/74.page</guid>
				<link>https://forum.andowson.com/posts/preList/54/74.page</link>
				<pubDate><![CDATA[Sat, 17 Mar 2007 12:07:01]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
	</channel>
</rss>