码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat 多实例部署脚本

时间:2015-11-18 12:49:50      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:多实例部署脚本

#!/bin/bash

PA=ABC.com

JA=/JavaWeb

TT=/usr/local/tomcat

#Add an instance, and make the appropriate settings

AIAS () {

echo -e "\n"

[ ! -d $JA ] && echo "Warning:Not found $JA,Please check " && exit 1 

[ ! -d $TT ] && echo "Warning:Not found $TT,Please check " && exit 1 

[ ! -d $TT/conf/ ] && echo "Warning:Not found $TT/conf/,Please check " && exit 1 

[ ! -d $TT/webapps/ ] && echo "Warning:Not found $TT/webapps/,Please check " && exit 1 

[ ! -d $TT/temp/ ] && echo "Warning:Not found $TT/temp/,Please check " && exit 1 

[ ! -d $TT/work/ ] && echo "Warning:Not found $TT/work/,Please check " && exit 1 

[ ! -d $TT/logs/ ] && echo "Warning:Not found $TT/logs/,Please check " && exit 1 

read -p "Enter the instance name you want to create:" ITN

echo "The instance name is $ITN"

read -p "Is ok,please enter y or n:" READA

if [ $READA == y ];then

mkdir -p $JA/$ITN/ROOT

echo -e "#!/bin/bash\nexport  CATALINA_BASE=$TT/$ITN\nsh "\$CATALINA_HOME"/bin/startup.sh" >$JA/$ITN/start.sh

echo -e "#!/bin/bash\nexport  CATALINA_BASE=$TT/$ITN\nsh "\$CATALINA_HOME"/bin/shutdown.sh" >$JA/$ITN/stop.sh

chmod 755 $JA/$ITN/start.sh

chmod 755 $JA/$ITN/stop.sh



mkdir $TT/$ITN

cp -r $TT/conf/ $TT/$ITN

cp -r $TT/webapps/ $TT/$ITN

cp -r $TT/temp/ $TT/$ITN

cp -r $TT/work/ $TT/$ITN

cp -r $TT/logs/ $TT/$ITN

sed -i -e s/webapps/"\/JavaWeb\/$ITN"/ $TT/$ITN/conf/server.xml

else 

AIAS

fi

}


#Modify the port number

MPN1 () {

echo -e "\n"

echo "Please enter a Server port number"


read -p "Please enter a port number:" NUM1

echo "The port number you enter is:$NUM1"

read -p "Is ok,Please enter y or n:" READ1

if [ $READ1 == y ];then

sed -i s/8005/$NUM1/ $TT/$ITN/conf/server.xml

# sed -i 42s/$/",$NUM1"/ `pwd`/tomcatadd.sh

echo -e "\n" 

else 

MPN1

fi

}


MPN2 () {

echo "Please enter a Connector port number"


read -p "Please enter a port number:" NUM2

echo "The port number you enter is:$NUM2"

read -p "Is ok,Please enter y or n:" READ2

if [ $READ2 == y ];then

sed -i s/8080/$NUM2/ $TT/$ITN/conf/server.xml

# sed -i 58s/$/",$NUM2"/ `pwd`/tomcatadd.sh

echo -e "\n" 

else 

MPN2

fi

}


MPN3 () {

echo "Please enter a Connector port number"


read -p "Please enter a port number:" NUM3

echo "The port number you enter is:$NUM3"

read -p "Is ok,Please enter y or n:" READ3

if [ $READ3 == y ];then

sed -i s/8009/$NUM3/ $TT/$ITN/conf/server.xml

# sed -i 73s/$/",$NUM3"/ `pwd`/tomcatadd.sh

echo -e "\n"

else 

MPN3

fi

}

#Add a user

AU () {

echo "the instance name is $ITN"

read -p "Please enter the name of the user you want to add:" UN

echo "The name you enter is:$UN"

read -p "Is ok,Please enter y or n:" READAU

if [ $READAU == y ];then

useradd $UN

echo $PA | passwd --stdin $UN &>/dev/null

chown -R $UN $JA/$ITN

chown -R $UN $TT/$ITN

echo -e "\n"

else 

AU

fi

}


#Information confirmation


ICMPN () {

echo "Make sure the information is correct"

echo -e "\n" 

sleep 3

sed -n ‘22p‘ $TT/$ITN/conf/server.xml

echo -e "\n"

sed -n ‘71,73p‘ $TT/$ITN/conf/server.xml

echo -e "\n"

sed -n ‘93p‘ $TT/$ITN/conf/server.xml

echo -e "\n"

sed -n ‘125,126p‘ $TT/$ITN/conf/server.xml

echo -e "\n"

sleep 5

echo ll $JA

echo `/bin/ls -l $JA | grep $ITN`

echo -e "\n"

echo ll $JA/$ITN

echo `/bin/ls -l $JA/$ITN`

echo -e "\n"

echo ll $TT/$ITN

echo `/bin/ls -l $TT/$ITN`

echo -e "\n"

}


#Information output

IFO () {

echo -e "你好,\n$ITN服务器如下:\nIP:192.168.5.10\n用户名:$UN\n密码:$PA\n\n账号权限仅限于以下目录:\nTomcat实例路径:$TT/$ITN \n程序存放目录:$JA/$ITN\n程序本地直接测试端口号:$NUM2(不允许私自更改)\n程序外网访问:$ITN \n谢谢!"

}


#The main program

AIAS 

MPN1 

MPN2

MPN3

AU

ICMPN

IFO


本文出自 “运维之道” 博客,请务必保留此出处http://lrtao2010.blog.51cto.com/10425744/1713878

tomcat 多实例部署脚本

标签:多实例部署脚本

原文地址:http://lrtao2010.blog.51cto.com/10425744/1713878

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!