From b17042b955489d8a023d09abad5436ff9b900dc3 Mon Sep 17 00:00:00 2001 From: Denes Nemeth Date: Mon, 12 Feb 2018 20:55:54 +0100 Subject: Updating Nokia driver Change-Id: I950afe6acbdb359cd67a448024f006a45e8fc293 Signed-off-by: Denes Nemeth Issue-ID: VFC-728 --- .../src/main/resources/docker-entrypoint.sh | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 nokiav2/deployment/src/main/resources/docker-entrypoint.sh (limited to 'nokiav2/deployment/src/main/resources/docker-entrypoint.sh') diff --git a/nokiav2/deployment/src/main/resources/docker-entrypoint.sh b/nokiav2/deployment/src/main/resources/docker-entrypoint.sh new file mode 100755 index 00000000..bd36b617 --- /dev/null +++ b/nokiav2/deployment/src/main/resources/docker-entrypoint.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# Copyright 2017, Nokia Corporation +# +# 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. +# +# + +CONFIG_LOCATION=/service/application.properties + +function shutdown(){ + echo "Recieved sutdown signal" + if [ ! -e /proc/$PID ] ; then + echo "The process already exited $PID" + exit + fi + echo "Sending shutdown signal to $PID" + kill -15 $PID + for i in `seq 0 20`; do + if [ ! -e /proc/$PID ] ; then + echo "The driver exited normally $PID" + exit 0 + fi + sleep 10 + done + echo "Terminating the driver forcefully $PID" + kill -9 $PID +} + +function switchLine(){ + PATTERN=$1 + REPLACEMENT=$2 + if [ ! -z $REPLACEMENT ]; then + sed -i "s/${PATTERN}.*/${PATTERN}/g" $CONFIG_LOCATION + sed -i "s|${PATTERN}|${PATTERN}=${REPLACEMENT}|g" $CONFIG_LOCATION + fi +} + +function configure(){ + if [ ! -z "$CONFIGURE" ] ; then + switchLine driverMsbExternalIp $EXTERNAL_IP + switchLine driverVnfmExternalIp $EXTERNAL_IP + switchLine messageBusIp $MSB_IP + switchLine cbamCatalogUrl $CBAM_CATALOG_URL + switchLine cbamLcnUrl $CBAM_LCN_URL + switchLine cbamKeyCloakBaseUrl $CBAM_KEYCLOAK_URL + switchLine cbamLcnUrl $CBAM_LCN_URL + switchLine cbamUsername $CBAM_USERNAME + switchLine cbamPassword $CBAM_PASSWORD + switchLine vnfmId $VNFM_ID + switchLine ipMap $IP_MAP + fi +} + + +#during shutdown signal the ervice to stop +trap shutdown SIGINT SIGTERM + +#configure if required +configure + +#start the service +cd /service + +while true ; do + echo "Starting server" + java -jar driver.war --spring.config.location=file:/service/application.properties &>> /service/service.log & + export PID=$! + echo "Server process started in background with id $PID" + while test -e /proc/$PID; do + sleep 10 + done + echo "Server quit (unexpected)" +done + -- cgit 1.2.3-korg