#! /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