3 # Copyright 2020 Samsung Electronics Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 echo "---> emssimulator-swm-netconf_post.sh"
19 set -e # Exit with zero only if all commands succeed
21 SERVICE_NAME="ems-netconf-swm"
22 DOCKER_COMPOSE_LOG="/tmp/docker-compose.log"
23 DOCKER_COMPOSE_LOG_MSG=( "INFO success:" "entered RUNNING state" )
24 DOCKER_COMPOSE_SLEEP_INTERVAL=4
29 sleep ${DOCKER_COMPOSE_SLEEP_INTERVAL} # Hang for a while so the services settle
30 docker-compose logs --no-color > ${DOCKER_COMPOSE_LOG}
32 # Get the supervisord services running within container
33 supervisord_services=($(docker-compose exec -T ${SERVICE_NAME} /bin/sh -c \
34 'cat /etc/supervisord.conf /etc/supervisord.d/*' | grep -ho "program:[-a-zA-Z0-9]*" | cut -d: -f 2))
36 # Check all services are running and fail if not
37 for service in ${supervisord_services[@]};
39 if ! grep -q "${DOCKER_COMPOSE_LOG_MSG[0]} $service ${DOCKER_COMPOSE_LOG_MSG[1]}" ${DOCKER_COMPOSE_LOG};
41 echo "ERROR: Service $service is not running, failing the build."