Tomcat Startup Script

From GFIPM Implementation Wiki
Revision as of 18:36, 5 September 2017 by Jeff.Krug (Talk | contribs)

Jump to: navigation, search
#!/bin/sh
#
# Tomcat Startup Script
#
# chkconfig: 235 90 90
# description: Loads up the Apache Tomcat Application Server
# processname: tomcat
# config: /opt/tomcat/conf/server.xml
#
# Source function library.

if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

RETVAL=0

# Set JAVA_HOME
export JAVA_HOME=/usr/java/latest
export CATALINA_HOME=/opt/tomcat
export CATALINA_OPTS="-Didp.home=/opt/idp3 -Xmx512m -XX:MaxPermSize=128m -Dconfig.location.assure.mail=/opt/user-reg-tool/AssureMailConfig.groovy -Dconfig.location.assure.recaptcha=/opt/user-reg-tool/AssureStagingRecaptchaConfig.groovy"

# Define the tomcat username
TOMCAT_USER="tomcat"

# See how we were called.
start() {
    echo -n "Starting $TOMCAT_PROG: "
    su $TOMCAT_USER $CATALINA_HOME/bin/catalina.sh start
        RETVAL=$?
        return $RETVAL
}

stop() {
    echo -n "Stopping $TOMCAT_PROG: "
    su $TOMCAT_USER $CATALINA_HOME/bin/catalina.sh stop
    sleep 5
    if [ -e $CATALINA_HOME/webapps/idp ] ; then 
       rm -rf $CATALINA_HOME/webapps/idp
    fi
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 7
        start
        ;;
  *)
        echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}"
        exit 1
esac

exit $RETVAL