tomcat 多執行個體部署指令碼

來源:互聯網
上載者: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 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 多執行個體部署指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.