aboutsummaryrefslogtreecommitdiffstats
path: root/packages/base/src/files/install/servers/common
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:00 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:32 -0500
commit91d04c64771832a0b8815ffbe1f0f9920320d94d (patch)
treefb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /packages/base/src/files/install/servers/common
parentb9d4caa40ef8e3566ac475968bce17b9b64b6939 (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')
-rwxr-xr-xpackages/base/src/files/install/servers/common/logparser/init.d/logparserd131
-rw-r--r--packages/base/src/files/install/servers/common/tomcat/bin/setenv.sh31
-rw-r--r--packages/base/src/files/install/servers/common/tomcat/conf/server.xml167
-rw-r--r--packages/base/src/files/install/servers/common/tomcat/init.d/tomcatd91
4 files changed, 420 insertions, 0 deletions
diff --git a/packages/base/src/files/install/servers/common/logparser/init.d/logparserd b/packages/base/src/files/install/servers/common/logparser/init.d/logparserd
new file mode 100755
index 000000000..37221b9c3
--- /dev/null
+++ b/packages/base/src/files/install/servers/common/logparser/init.d/logparserd
@@ -0,0 +1,131 @@
+#!/bin/bash
+#
+# init script for a Java application
+#
+
+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 start, does not change monitor status (immutable)
+function um_start() {
+ JMX_JAVA_OPTS="-Dcom.sun.management.jmxremote"
+ JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.port=${LOGPARSER_JMX_PORT}"
+ JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
+ JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
+ JVM_JAVA_OPTS="-Xms${LOGPARSER_X_MS_MB}M -Xmx${LOGPARSER_X_MX_MB}M"
+
+ JAVA_OPTS="${JAVA_OPTS} ${JMX_JAVA_OPTS} ${JVM_JAVA_OPTS}"
+
+ # Redirects default and error output to a log file
+ cd ${POLICY_HOME}/servers/${COMPONENT}/bin
+ nohup $JAVA_HOME/bin/java -jar ${JAVA_OPTS} ${SERVICE} ${SERVER} ${LOGTYPE} >> ${POLICY_HOME}/servers/${COMPONENT}/logs/stdout 2>&1 &
+RETVAL=$?
+ RETVAL=$?
+}
+
+# Starts the application
+function start() {
+ um_start
+ if [[ ${RETVAL} != 0 ]]; then
+ update_monitor ${COMPONENT} off
+ else
+ update_monitor ${COMPONENT} on
+ fi
+}
+
+# unmonitored stop, does not change monitor status (immutable)
+function um_stop() {
+ # Kills the application process
+ pkill -u ${POLICY_USER} -f "${SERVICE} ${SERVER} ${LOGTYPE}" -TERM
+ RETVAL=$?
+ if [[ ${RETVAL} != 0 ]]; then
+ sleep 2
+ pkill -u ${POLICY_USER} -f "${SERVICE} ${SERVER} ${LOGTYPE}" -KILL
+ RETVAL=$?
+ fi
+}
+
+# Stops the application
+function stop() {
+ um_stop
+ update_monitor ${COMPONENT} off
+}
+
+# Show the application status
+function status() {
+ # check status
+ pid=$(pgrep -f -u ${POLICY_USER} "${SERVICE} ${SERVER} ${LOGTYPE}" 2> /dev/null)
+ RETVAL=$?
+
+ # If the PID was returned means the application is running
+ if [ ${RETVAL} -eq 0 ] ; then
+ echo "running with pid ${pid}"
+ else
+ echo "stopped"
+ fi
+}
+
+# Main logic, a simple case to call functions
+
+# determine if this is a paplp or pdplp component
+COMPONENT=$(basename $0)
+
+CONF_FILE="${POLICY_HOME}/servers/${COMPONENT}/bin/parserlog.properties"
+SERVICE="${POLICY_HOME}/servers/${COMPONENT}/bin/logparser.jar"
+
+# read properties
+shopt -s extglob
+configfile="dos_or_unix" # set the actual path name of your (DOS or Unix) config file
+while IFS='= ' read lhs rhs
+do
+ if [[ ! $lhs =~ ^\ *# && -n $lhs ]]; then
+ rhs="${rhs%%\#*}" # Del in line right comments
+ rhs="${rhs%%*( )}" # Del trailing spaces
+ rhs="${rhs%\"*}" # Del opening string quotes
+ rhs="${rhs#\"*}" # Del closing string quotes
+ if [[ $lhs != *"."* ]]; then
+ declare $lhs="$rhs"
+ fi
+ fi
+done < "${CONF_FILE}"
+if [ $? -ne 0 ]; then
+ echo "error: cannot source configuration ${CONF_FILE}"
+ exit 1
+fi
+
+case "$1" in
+ status)
+ status
+ ;;
+ restart)
+ stop
+ sleep 2
+ start
+ ;;
+ start)
+ start
+ ;;
+ umstart)
+ um_start
+ ;;
+ stop)
+ stop
+ ;;
+ umstop)
+ um_stop
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|umstart|umstop|restart|status}"
+ RETVAL=1
+ ;;
+esac
+
+exit ${RETVAL}
+
diff --git a/packages/base/src/files/install/servers/common/tomcat/bin/setenv.sh b/packages/base/src/files/install/servers/common/tomcat/bin/setenv.sh
new file mode 100644
index 000000000..154b2a544
--- /dev/null
+++ b/packages/base/src/files/install/servers/common/tomcat/bin/setenv.sh
@@ -0,0 +1,31 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote"
+CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.port=${{TOMCAT_JMX_PORT}}"
+CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
+CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
+CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.keyStore=${POLICY_HOME}/etc/ssl/policy-keystore"
+CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWD}"
+CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStore=${POLICY_HOME}/etc/ssl/policy-keystore"
+CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStorePassword=${KEYSTORE_PASSWD}"
+CATALINA_OPTS="${CATALINA_OPTS} -Xms${{TOMCAT_X_MS_MB}}M"
+CATALINA_OPTS="${CATALINA_OPTS} -Xmx${{TOMCAT_X_MX_MB}}M"
+export CATALINA_OPTS
diff --git a/packages/base/src/files/install/servers/common/tomcat/conf/server.xml b/packages/base/src/files/install/servers/common/tomcat/conf/server.xml
new file mode 100644
index 000000000..e45450024
--- /dev/null
+++ b/packages/base/src/files/install/servers/common/tomcat/conf/server.xml
@@ -0,0 +1,167 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP Policy Engine
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- Note: A "Server" is not itself a "Container", so you may not
+ define subcomponents such as "Valves" at this level.
+ Documentation at /docs/config/server.html
+ -->
+<Server port="${{TOMCAT_SHUTDOWN_PORT}}" shutdown="SHUTDOWN">
+ <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
+ <!-- Security listener. Documentation at /docs/config/listeners.html
+ <Listener className="org.apache.catalina.security.SecurityListener" />
+ -->
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+ <!-- Prevent memory leaks due to use of particular java/javax APIs-->
+ <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
+ <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
+
+ <!-- Global JNDI resources
+ Documentation at /docs/jndi-resources-howto.html
+ -->
+ <GlobalNamingResources>
+ <!-- Editable user database that can also be used by
+ UserDatabaseRealm to authenticate users
+ -->
+ <Resource name="UserDatabase" auth="Container"
+ type="org.apache.catalina.UserDatabase"
+ description="User database that can be updated and saved"
+ factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+ pathname="conf/tomcat-users.xml" />
+ </GlobalNamingResources>
+
+ <!-- A "Service" is a collection of one or more "Connectors" that share
+ a single "Container" Note: A "Service" is not itself a "Container",
+ so you may not define subcomponents such as "Valves" at this level.
+ Documentation at /docs/config/service.html
+ -->
+ <Service name="Catalina">
+
+ <!--The connectors can use a shared executor, you can define one or more named thread pools-->
+ <!--
+ <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+ maxThreads="150" minSpareThreads="4"/>
+ -->
+
+
+ <!-- A "Connector" represents an endpoint by which requests are received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
+
+ <Connector port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443" />
+ -->
+ <!-- A "Connector" using the shared thread pool-->
+ <!--
+ <Connector executor="tomcatThreadPool"
+ port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443" />
+ -->
+ <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
+ This connector uses the NIO implementation that requires the JSSE
+ style configuration. When using the APR/native implementation, the
+ OpenSSL style configuration is required as described in the APR/native
+ documentation -->
+
+ <!-- Use http instead of https
+ <Connector port="${{SSL_HTTP_CONNECTOR_PORT}}" protocol="org.apache.coyote.http11.Http11NioProtocol"
+ maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
+ clientAuth="false" sslEnabledProtocols="TLSv1, TLSv1.1, TLSv1.2"
+ keystoreFile="${{POLICY_HOME}}/etc/ssl/policy-keystore" keystorePass="${{KEYSTORE_PASSWD}}"/>
+ -->
+ <Connector port="${{SSL_HTTP_CONNECTOR_PORT}}" protocol="org.apache.coyote.http11.Http11NioProtocol"
+ maxThreads="150" />
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector port="${{SSL_AJP_CONNECTOR_PORT}}" protocol="AJP/1.3" redirectPort="${{SSL_AJP_CONNECTOR_REDIRECT_PORT}}" />
+
+
+ <!-- An Engine represents the entry point (within Catalina) that processes
+ every request. The Engine implementation for Tomcat stand alone
+ analyzes the HTTP headers included with the request, and passes them
+ on to the appropriate Host (virtual host).
+ Documentation at /docs/config/engine.html -->
+
+ <!-- You should set jvmRoute to support load-balancing via AJP ie :
+ <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
+ -->
+ <Engine name="Catalina" defaultHost="localhost">
+
+ <!--For clustering, please take a look at documentation at:
+ /docs/cluster-howto.html (simple how to)
+ /docs/config/cluster.html (reference documentation) -->
+ <!--
+ <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
+ -->
+
+ <!-- Use the LockOutRealm to prevent attempts to guess user passwords
+ via a brute-force attack -->
+ <Realm className="org.apache.catalina.realm.LockOutRealm">
+ <!-- This Realm uses the UserDatabase configured in the global JNDI
+ resources under the key "UserDatabase". Any edits
+ that are performed against this UserDatabase are immediately
+ available for use by the Realm. -->
+ <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+ resourceName="UserDatabase"/>
+ </Realm>
+
+ <Host name="localhost" appBase="webapps"
+ unpackWARs="true" autoDeploy="true">
+
+ <!-- SingleSignOn valve, share authentication between web applications
+ Documentation at: /docs/config/valve.html -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Access log processes all example.
+ Documentation at: /docs/config/valve.html
+ Note: The pattern used is equivalent to using pattern="common" -->
+ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
+ prefix="localhost_access_log" suffix=".txt"
+ pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+
+ </Host>
+ </Engine>
+ </Service>
+</Server>
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}