linux一键部署tomcat7 bash脚本

又重新整理了下tomcat7的配置教程和https证书的配置,顺便写了个一键部署的脚本,代码如下:

#!/bin/bash
#author merci

#tomcat部署目录
TOMCATDIR='/usr/local/'
#tomcat版本号
TOMCATVERSION='7.0.90'

checkJdk=`rpm -qa | grep 'java'`
if [ ! $checkJdk ]
then
    yum install  java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 -y
else
    yum remove java* -y
    yum install  java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 -y  
fi

wget http://mirrors.shu.edu.cn/apache/tomcat/tomcat-7/v${TOMCATVERSION}/bin/apache-tomcat-${TOMCATVERSION}.tar.gz
tar -zxvf apache-tomcat-${TOMCATVERSION}.tar.gz
mv apache-tomcat-${TOMCATVERSION} ${TOMCATDIR}/tomcat7
chmod -R +x ${TOMCATDIR}/tomcat7/bin
touch /etc/rc.d/init.d/tomcat
cat > /etc/rc.d/init.d/tomcat << EOF
#!/bin/bash
#
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "\atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi
RETVAL=\$?
CATALINA_HOME="${TOMCATDIR}tomcat7"
case "\$1" in
start)
if [ -f \$CATALINA_HOME/bin/startup.sh ];
then
echo \$"Starting Tomcat"
\$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f \$CATALINA_HOME/bin/shutdown.sh ];
then
echo \$"Stopping Tomcat"
\$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo \$"Usage: \$0 {start|stop}"
exit 1
;;
esac
exit \$RETVAL
EOF
chmod 755 /etc/rc.d/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
service tomcat start


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/502.html