#!/bin/sh
#kill tomcat pid
path="/../usr/local/test/"
tarPath="/../usr/local/"
pidlist=`ps -ef|grep tomcat6-box | grep -v "grep"|awk '{print $2}'`
#ps -u $USER|grep "java"|grep -v "grep"
if [ "$pidlist" = "" ]
then
echo "BOX服务已经停止"
else
for pid in ${pidlist}
{
kill -9 $pid
echo "KILL $pid:"
}
echo "BOX服务停止"
fi
#delete
cd "$path"tomcat6-box-I/webapps
rm -fr web
mkdir web
cd "$path"tomcat6-box-II/webapps
rm -fr web
mkdir web
cd "$path"tomcat6-box-III/webapps
rm -fr web
mkdir web
#tar
echo 开始解压文件:web.tar
tar -xf "$tarPath"web.tar -C "$path"tomcat6-box-I/webapps/web
tar -xf "$tarPath"web.tar -C "$path"tomcat6-box-II/webapps/web
tar -xf "$tarPath"web.tar -C "$path"tomcat6-box-III/webapps/web
echo 解压文件完毕
#sed
echo 开始修改配置文件
cd "$path"tomcat6-box-I/webapps/web/WEB-INF/classes/META-INF
sed -i 's/1099/10000/g' ext-spring-jmx.xml
sed -i 's/localhost/192.168.0.99/g' ext-spring-jmx.xml
cd "$path"tomcat6-box-II/webapps/web/WEB-INF/classes/META-INF
sed -i 's/1099/10001/g' ext-spring-jmx.xml
sed -i 's/localhost/192.169.0.99/g' ext-spring-jmx.xml
cd "$path"tomcat6-box-III/webapps/web/WEB-INF/classes/META-INF
sed -i 's/1099/10002/g' ext-spring-jmx.xml
sed -i 's/localhost/192.170.0.99/g' ext-spring-jmx.xml
echo 修改配置文件完毕
#start
echo 启动服务
cd "$path"tomcat6-box-I/bin;./startup.sh
echo BOX-I服务开启
cd "$path"tomcat6-box-II/bin;./startup.sh
echo BOX-II服务开启
cd "$path"tomcat6-box-III/bin;./startup.sh
echo BOX-III服务开启
echo 服务启动完毕