2 #*******************************************************************************
3 # ============LICENSE_START=======================================================
5 # ================================================================================
6 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
20 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 #*******************************************************************************
24 if [ -f "/tmp/exitdmaapMRpostproc" ]; then
25 echo "file /tmp/exitdmaapMRpostproc found .exiting..........."
28 . `dirname $0`/install.env
30 mkdir -p ${ROOT_DIR}/conf || fail 100 "Error on creating the conf directory."
31 mkdir -p ${ROOT_DIR}/docs || fail 100 "Error on creating the docs directory."
32 mkdir -p ${ROOT_DIR}/lib || fail 100 "Error on creating the lib directory."
33 mkdir -p ${ROOT_DIR}/log || fail 100 "Error on creating the logs directory."
35 ##############################################################################
36 # REMOVING THE DATA DIRECTORY
37 # The following if statement is checking to see if a new version is being installed
38 # on top of another version. If a new version is installed on top of the current
39 # version WITHOUT a proper deinstall, this will remove the data directory which
40 # is necessary to cleanup old AJSC route metadata. If CSTEM chooses to re-run
41 # the install_postproc.sh to update swm node variables, this if statement will NOT
42 # remove the data directory which is necessary for the SAME version to utilize the
43 # correct data directory route metadata.
44 ##############################################################################
45 if [ "${AFTSWM_ACTION_NEW_VERSION}" != "${AFTSWM_ACTION_PREVIOUS_VERSION}" ]
47 rm -rf ${ROOT_DIR}/data
50 # Cleaning the jetty directory which contains the AJSC exploded war as well as
51 # any other apps running under jetty directory
52 rm -rf ${ROOT_DIR}/jetty
54 # A simple override for the SOA Cloud platform value. Normally this is not
55 # needed outside of SOA Cloud development sandboxes
56 # this is used in the template.lrm.xml file during startup of the service
57 if [ ! -z "${SCLD_PLATFORM}" ]; then
58 SCLD_OPTIONAL_PLATFORM_FLAG="-Dplatform=${SCLD_PLATFORM}"; export SCLD_OPTIONAL_PLATFORM_FLAG
61 ##############################################################################
62 # PROCESS TEMPLATE FILES FROM ENVIRONMENT
63 # pattern: looks for all files starting with "template.", processes them using the
64 # current environment, then renames them by removing the "template." in the same
66 ##############################################################################
67 utilpath=`dirname $0`/utils
68 for tfile in `ls ${ROOT_DIR}/bundleconfig/etc/sysprops/template.* ${ROOT_DIR}/bundleconfig/etc/appprops/template.* ${ROOT_DIR}/bin/template.* ${ROOT_DIR}/etc/template.* 2>/dev/null`; do
69 dfile=`echo ${tfile} | sed -e 's@/template\.@/@g'`
70 sh ${utilpath}/findreplace.sh ${tfile} ${dfile} || exit 200
73 runningCount=`${LRMCLI} -running | grep -w ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} | wc -l` || fail 300 "Unable to determine how many instances are running prior to notifying LRM of the upgrade"
75 ##############################################################################
76 # DEPLOY CONTAINER TO LRM
77 ##############################################################################
79 if [ -z "${RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS}" ]
81 RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS=180
82 export RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS
87 DTE_TME_STAMP=`date +%Y%m%d_%H%M%S`
89 LRM_ADD_LOG=/tmp/${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME}_ADD_${DTE_TME_STAMP}.out
90 echo "Adding resource to lrm"
91 echo "${LRMCLI} -add -file ${ROOT_DIR}/etc/lrm.xml -ttw ${RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS}"
92 ${LRMCLI} -add -file ${ROOT_DIR}/etc/lrm.xml -ttw ${RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS} > ${LRM_ADD_LOG}
94 echo "LRMCLI ADD RC : ${LRM_ADD_RC}"
95 if [ "${LRM_ADD_RC}" -ne "0" ]; then
97 RSRC_EXIST=`cat ${LRM_ADD_LOG} | grep SCLD-LRM-1024` # resource is already added
98 if [ "${RSRC_EXIST:-}x" = "x" ]; then
99 echo "LRM add for Resource ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} failed..."
104 echo "LRM Resource for ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} already exists. Proceeding with either addOrUpgrade or modify"
105 echo "Get the number of configured ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} instance"
106 versionCtr=`${LRMCLI} -configured | grep ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} | awk {'print $3'} | wc -l`
107 if [ ${versionCtr} -eq 1 ]; then
108 echo "Updating lrm resource"
109 echo "${LRMCLI} -addOrUpgrade -file ${ROOT_DIR}/etc/lrm.xml -ttw ${RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS}"
110 ${LRMCLI} -addOrUpgrade -file ${ROOT_DIR}/etc/lrm.xml -ttw ${RESOURCE_MANAGER_WAIT_TIME_IN_SECONDS} || abort "lrmcli addOrUpgrade failed"
112 echo "Modifying lrm resource"
113 echo "${LRMCLI} -modify -file ${ROOT_DIR}/etc/lrm.xml"
114 ${LRMCLI} -modify -file ${ROOT_DIR}/etc/lrm.xml || abort "lrmcli modify failed"
118 echo "LRMCLI execution on ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} executed succesfully!"
120 ls ${ROOT_DIR}/bundleconfig/etc/appprops/MsgRtrApi.properties
122 if [ ! -z $CONFIG_ZK_SERVERS ]; then
123 sed -i '/config.zk.servers=/c\config.zk.servers='$CONFIG_ZK_SERVERS ${ROOT_DIR}/bundleconfig/etc/appprops/MsgRtrApi.properties
126 if [ ! -z $TRANSID_REQD ]; then
127 sed -i '/transidUEBtopicreqd=/c\transidUEBtopicreqd='$TRANSID_REQD ${ROOT_DIR}/bundleconfig/etc/appprops/MsgRtrApi.properties
130 if [ ! -z $MR_TOPICFACTOTRYCLASS ]; then
131 sed -i '/msgRtr.topicfactory.aaf=/c\msgRtr.topicfactory.aaf='$MR_TOPICFACTOTRYCLASS ${ROOT_DIR}/bundleconfig/etc/appprops/MsgRtrApi.properties
134 if [ ! -z $MR_NAMESPACE ]; then
135 sed -i '/msgRtr.namespace.aaf=/c\msgRtr.namespace.aaf='$MR_NAMESPACE ${ROOT_DIR}/bundleconfig/etc/appprops/MsgRtrApi.properties
139 if [ ! -z $CADI_KEYFILE ]; then
140 sed -i '/cadi_keyfile=/c\cadi_keyfile='$CADI_KEYFILE ${ROOT_DIR}/etc/cadi.properties
143 if [ ! -z $AAF_URL ]; then
144 sed -i '/aaf_url=/c\aaf_url='$AAF_URL ${ROOT_DIR}/etc/cadi.properties
147 if [ ! -z $AAF_ID ]; then
148 sed -i '/aaf_id=/c\aaf_id='$AAF_ID ${ROOT_DIR}/etc/cadi.properties
151 if [ ! -z $AAF_PWD ]; then
152 sed -i '/aaf_password=/c\aaf_password='$AAF_PWD ${ROOT_DIR}/etc/cadi.properties
155 if [ ! -z $MR_LOGLOC ]; then
156 sed -i '/<property name="logDirectory" value=/c\<property name="logDirectory" value="'$MR_LOGLOC'"/>' ${ROOT_DIR}/bundleconfig/etc/logback.xml
159 if [ ! -z $MR_KSPATH ]; then
160 sed -i '/<Set name="KeyStorePath">/c\<Set name="KeyStorePath">'$MR_KSPATH'</Set>' ${ROOT_DIR}/etc/ajsc-jetty.xml
163 if [ ! -z $MR_KSPWD ]; then
164 sed -i '/<Set name="KeyStorePassword">/c\<Set name="KeyStorePassword">'$MR_KSPWD'</Set>' ${ROOT_DIR}/etc/ajsc-jetty.xml
168 if [ ! -z $MR_KMPWD ]; then
169 sed -i '/<Set name="KeyManagerPassword">/c\<Set name="KeyManagerPassword">'$MR_KMPWD'</Set>' ${ROOT_DIR}/etc/ajsc-jetty.xml
174 if [ "${runningCount}" -eq 0 ]; then
175 if [ "${LRM_START_SVC}" = "true" ]; then
176 echo "${LRMCLI} -start -name ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} -version ${AFTSWM_ACTION_NEW_VERSION} -routeoffer ${AFT_SERVICE_ENV} | egrep SUCCESS\|SCLD-LRM-1041"
177 ${LRMCLI} -start -name ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} -version ${AFTSWM_ACTION_NEW_VERSION} -routeoffer ${AFT_SERVICE_ENV} | egrep SUCCESS\|SCLD-LRM-1041
178 if [ $? -ne 0 ]; then
179 fail 500 "Start of ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME} with routeOffer ${AFT_SERVICE_ENV} failed"
181 echo "${LRMCLI} -running | grep -w ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME}"
182 ${LRMCLI} -running | grep -w ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME}
184 echo "PROC_USER_MSG: LRM_START_SVC is set to false and no running instances were found prior to upgrading so ending install with no running service instances."
187 ${LRMCLI} -running | grep -w ${SOA_CLOUD_NAMESPACE}.${AFTSWM_ACTION_ARTIFACT_NAME}