From 91d04c64771832a0b8815ffbe1f0f9920320d94d Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:41:00 -0500 Subject: Initial OpenECOMP policy/engine commit Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh --- .../install/servers/common/tomcat/init.d/tomcatd | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd (limited to 'packages/base/src/files/install/servers/common/tomcat/init.d') diff --git a/packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd b/packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd new file mode 100644 index 000000000..114f8a77e --- /dev/null +++ b/packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd @@ -0,0 +1,91 @@ +#!/bin/bash + +function update_monitor() { + COMPONENT=$1 + STATUS=$2 + if [[ -f ${POLICY_HOME}/etc/monitor/monitor.cfg ]]; then + /bin/sed -i.bak \ + -e "s/^${COMPONENT}=.*/${COMPONENT}=${STATUS}/g" \ + ${POLICY_HOME}/etc/monitor/monitor.cfg + fi +} + +# unmonitored stop, does not change monitor status (immutable) +function um_stop() { + cd ${TOMCAT_BASE}/bin/ + ${TOMCAT_BASE}/bin/catalina.sh stop -force + + # make sure .. + pid=$(pgrep -f -u ${POLICY_USER} "${TOMCAT_RUNNING}" 2> /dev/null) + RETVAL=$? + if [[ ${RETVAL} == 0 ]]; then + pkill -u ${POLICY_USER} -f "${TOMCAT_RUNNING}" -KILL + RETVAL=$? + fi +} + +function stop() { + um_stop + update_monitor ${{COMPONENT_TYPE}} off +} + +# unmonitored start, does not change monitor status (immutable) +function um_start() { + cd ${TOMCAT_BASE}/bin/ + ${TOMCAT_BASE}/bin/catalina.sh start + RETVAL=$? +} + +function start() { + um_start + if [[ ${RETVAL} != 0 ]]; then + update_monitor ${{COMPONENT_TYPE}} off + else + update_monitor ${{COMPONENT_TYPE}} on + fi +} + +TOMCAT_BASE=${POLICY_HOME}/servers/${{COMPONENT_TYPE}} +TOMCAT_RUNNING="^$JAVA_HOME/bin/java .* -Dcatalina.base=${TOMCAT_BASE} .* start$" + +PWD_ENTER=${PWD} +RETVAL=0 + +. ${POLICY_HOME}/etc/profile.d/env.sh + +case "$1" in + status) + pid=$(pgrep -f -u ${POLICY_USER} "${TOMCAT_RUNNING}" 2> /dev/null) + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + echo "running with pid ${pid}" + else + echo "stopped" + fi + ;; + restart) + stop + sleep 2 + start + ;; + start) + start + ;; + umstart) + um_start + ;; + stop) + stop + ;; + umstop) + um_stop + ;; + *) + cd ${TOMCAT_BASE}/bin/ + ${TOMCAT_BASE}/bin/catalina.sh "$@" + RETVAL=$? + ;; +esac + +cd ${PWD_ENTER} +exit ${RETVAL} -- cgit 1.2.3-korg