#! /bin/bash ## ** modified to support chkconfig 10/11/06 --dru # chkconfig: 2345 95 80 # description: custom Tomcat ## Modified to add environmental variables needed on boot 2/8/07 --ehab export JBOSS_HOME=/opt/jboss export JAVA_HOME=/opt/jdk JBOSS_BIN=/opt/jboss/bin JBOSS_USER=tomcat # Function to run the excution command function execCommand() { OLD_PWD=`pwd` cd $JBOSS_BIN /sbin/runuser -c "$1" $JBOSS_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/jboss" | 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/jboss stop' before running this command."; else execCommand "./run.sh -b 0.0.0.0 "; fi ;; stop) checkExist if [ -n "$exist" ] then #execCommand "./shutdown.sh --server=localhost:1199 --shutdown 2>&1&" execCommand "./shutdown.sh --shutdown 2>&1&" sleep 4 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