diff options
author | 2017-02-14 19:41:00 -0500 | |
---|---|---|
committer | 2017-02-14 19:41:32 -0500 | |
commit | 91d04c64771832a0b8815ffbe1f0f9920320d94d (patch) | |
tree | fb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /packages/base/src/files/install/servers/common/tomcat/init.d | |
parent | b9d4caa40ef8e3566ac475968bce17b9b64b6939 (diff) |
Initial OpenECOMP policy/engine commit
Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'packages/base/src/files/install/servers/common/tomcat/init.d')
-rw-r--r-- | packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd | 91 |
1 files changed, 91 insertions, 0 deletions
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} |