Tomcat创建实例的一个脚本(shell 脚本)
2011-07-14 15:34
351 查看
#!/bin/bash
tc_home=/opt/oracle/tomcat/
instanceName=$1 【创建的实例】
cd .. >> /dev/null
template_dir=`pwd`
echo $template_dir
if [ ! -d $tc_home ] ;then
mkdir -p $tc_home 【目录不存在就创建】
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表示非空串】
cp -rf $template_dir $tc_home$instanceName
【将当前目录中的文件拷贝到新创建的实例中】
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 【删除乱码,注意这个字符可以按住ctrl键,然后按vm就会出现】
echo "New instance $instanceName has successfully builded, and "
grep port $conffile 【将创建的那几个端口的相关信息输出】
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
tc_home=/opt/oracle/tomcat/
instanceName=$1 【创建的实例】
cd .. >> /dev/null
template_dir=`pwd`
echo $template_dir
if [ ! -d $tc_home ] ;then
mkdir -p $tc_home 【目录不存在就创建】
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表示非空串】
cp -rf $template_dir $tc_home$instanceName
【将当前目录中的文件拷贝到新创建的实例中】
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 【删除乱码,注意这个字符可以按住ctrl键,然后按vm就会出现】
echo "New instance $instanceName has successfully builded, and "
grep port $conffile 【将创建的那几个端口的相关信息输出】
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
相关文章推荐
- 如何确保 Shell 脚本只有一个实例运行
- 管理多tomcat实例的shell脚本
- [shell应用进阶]:限制同时运行脚本实例的个数 -- 串行化:换一个思路。
- 通过脚本案例学习shell(五) 通过创建DNS脚本一步一步教你将一个普通脚本规范到一个生产环境脚本 推荐
- Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- 转:Shell 编程--本文结合大量实例阐述如何编写一个shell脚本。
- linux、shell脚本实例一“查找一个文件或者目录 找到了提示 没找到则输出未找到”
- Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- shell脚本只运行一个实例
- 用c++创建一个Linux上的Daemon程序,含SHELL管理脚本(一)
- 本文结合大量实例阐述如何编写一个shell脚本
- Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- 用c++创建一个Linux上的Daemon程序,含SHELL管理脚本(二)
- 做一个创建cocos2d-x新项目的shell脚本
- Shell脚本控制tomcat的docker容器的创建,删除,启动,关闭
- 如何使Shell脚本只有一个实例在运行
- 一个简单的自动创建Shell脚本的脚本
- bat脚本实例实现只允许运行一个实例(安装程序、创建快捷方式脚本)
- shell脚本 自动创建用户详解及实例代码
- 转:Shell 编程--本文结合大量实例阐述如何编写一个shell脚本。