Tomcat multi-Instance deployment script

Source: Internet
Author: User

#!/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 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: $NUM 1"

Read-p "is ok,please enter Y or N:" READ1

if [$READ 1 = = y];then

Sed-i s/8005/$NUM 1/$TT/$ITN/conf/server.xml

#sed-i 42s/$/", $NUM 1"/' 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: $NUM 2"

Read-p "is ok,please enter Y or N:" READ2

if [$READ 2 = = y];then

Sed-i s/8080/$NUM 2/$TT/$ITN/conf/server.xml

#sed-i 58s/$/", $NUM 2"/' 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: $NUM 3"

Read-p "is ok,please enter Y or N:" READ3

if [$READ 3 = = y];then

Sed-i s/8009/$NUM 3/$TT/$ITN/conf/server.xml

#sed-i 73s/$/", $NUM 3"/' 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 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 "Hello, \n$itn server is as follows: \nip:192.168.5.10\n user name: $UN \ n Password: $PA \ n \ nthe account permissions are limited to the following directories: \ntomcat instance path: $TT/$ITN \ n Program Storage directory: $JA/$ITN \ n program local direct test port number: $NUM 2 (not allowed to change privately) \ n Program extranet access: $ITN \ n Thank you! "

}


#The Main Program

AIAS

MPN1

MPN2

MPN3

AU

Icmpn

Ifo


This article is from the "Operation and maintenance of the Road" blog, please be sure to keep this source http://lrtao2010.blog.51cto.com/10425744/1713878

Tomcat multi-Instance deployment script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.