A script for Tomcat to create an instance (shell script)

Source: Internet
Author: User

 

#! /Bin/bash

Tc_home =/opt/Oracle/tomcat/

InstanceName = $1 [created instance]

 

CD...>/dev/null

Template_dir = 'pwd'

Echo $ template_dir

If [! -D $ tc_home]; then

Mkdir-p $ tc_home [Create if the directory does not exist]

Fi

 

Usemethod (){

Echo-e "Usage: Sh creattcinstance InstanceName

Note: The instance name must be as the format:
Tomcatserverxxx-x

Shutdown port (10000-10100)

AJP port (8010-8079)

Http port (8080-8190)

HTTPS port (8440-8540)

JMX port (6900-6970 )"

}

 

Insnum = 'echo $ InstanceName | awk-F-'{Print $2 }''

Conffile = "$ tc_home" "$ instancename"/CONF/Catalina. Properties

If [-N
"$ Insnum"]; then-N indicates a non-empty string]

CP-RF $ template_dir $ tc_home $ InstanceName
[Copy the files in the current directory to the newly created instance]

Echo "shutdown. Port = 1000 $ insnum" >>$ conffile

Echo "AJP. Port = 801 $ insnum" >>$ conffile

Echo "HTTP. Port = 808 $ insnum" >>$ conffile

Echo "HTTPS. Port = 804 $ insnum" >>$ conffile

Echo "JMX. Port = 690 $ insnum" >>$ conffile

Else

Echo "warn, Please define your instance name in right format ."

Exit

Fi

 

 

 

If [-F "$ conffile"]; then

Sed-I's/^ m // '$ conffile [Delete Garbled text. Note that you can press Ctrl to delete this character and press VM to display it]

Echo "new instance $ InstanceName has successfully builded, and"

Grep port $ conffile [output information about the created ports]

Else

Usemethod

Exit

Fi

 

Cat> ~ /Start _ $ InstanceName. Sh <EOF

#! /Bin/sh

CD/opt/Oracle/tomcat/$ InstanceName/bin

Sh Catalina. Sh start

Tail-F/opt/Oracle/tomcat/$ InstanceName/logs/Catalina. Out

EOF

 

Cat> ~ /Stop _ $ InstanceName. Sh <EOF

#! /Bin/sh

CD/opt/Oracle/tomcat/$ InstanceName/bin

Sh Catalina. Sh stop

Tail-F/opt/Oracle/tomcat/$ InstanceName/logs/Catalina. Out

EOF

Related Article

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.