Tuesday, February 28, 2012

Setting up liferay/tomcat as service on suse linux

1. Copy the attached file to /etc/init.d
2. Modify the paths
3. Run the following command to add the script as service
chkconfig --add liferay
---------------------------------
Filename: liferay



#!/bin/sh
#
# /etc/init.d/tomcat
#
# This is the init script for starting up the
#  Jakarta Tomcat server
#
# description: Starts and stops the Tomcat daemon.
#


tomcat=/media/Resources/data/www/liferay-portal-6.0.6/tomcat-6.0.29
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh


start() {
  echo -n $"Starting Tomcat service: "
  sh $startup
  echo $?
}


stop() {
  echo -n $"Stopping Tomcat service: "
  sh $shutdown
  echo $?
}


restart() {
  stop
  start
}


status() {
  #ps -aef | grep liferay | grep -v tomcat6 | grep -v grep
  numproc=`ps -ef | grep liferay | grep -v "grep liferay" | wc -l`
  if [ $numproc -gt 0 ]; then
    echo "Liferay is running..."
  else
    echo "Liferay is stopped..."
  fi
}


# Handle the different input options
case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
status)
  status
  ;;
restart)
  restart
  ;;
*)
  echo $"Usage: $0 {start|stop|restart|status}"
  exit 1
esac


exit 0

No comments:

Post a Comment