#! /bin/bash # chkconfig: 2345 95 80 # description: custom Tomcat export TOMCAT_HOME=/opt/tomcat export JAVA_HOME=/opt/jdk ## Modified to startup in the liferay bin directory because of bug in liferay startup script TOMCAT_BIN=/opt/tomcat/bin TOMCAT_USER=tomcat # Function to run the excution command function execCommand() { OLD_PWD=`pwd` cd $TOMCAT_BIN /sbin/runuser -c "$1" $TOMCAT_USER sleep 1 # allows prompt to return cd $OLD_PWD } # Function to check if the liferay process is already running function checkExist() { exist=`ps aux | grep "opt/tomcat" | grep -v grep | awk {'print $2'}` } case "$1" in start) checkExist if [ -n "$exist" ] then echo "Dude! There is already an instance started! Run '/etc/init.d/tomcat stop' before running this comm nd."; else execCommand "./catalina.sh start "; fi ;; stop) checkExist if [ -n "$exist" ] then execCommand "./catalina.sh stop "; sleep 10 else echo "Dude! jBoss is NOT running!" fi checkExist if [ -n "$exist" ] then kill -9 $exist fi ;; *) echo "Usage $0 {start|stop}" exit 1 ;; esac