From 777f112a7ff476234e9fa511d867f06865f5b302 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 17 Dec 2020 10:47:59 +0000 Subject: [PATCH] Update scripts/start.sh from MON repo Change-Id: Ia22d953234da67291fa396ef8ebef4640fcc597f Signed-off-by: garciadeblas --- docker/MON/scripts/start.sh | 55 +------------------------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/docker/MON/scripts/start.sh b/docker/MON/scripts/start.sh index d2b6b1b2..59501941 100644 --- a/docker/MON/scripts/start.sh +++ b/docker/MON/scripts/start.sh @@ -20,61 +20,8 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact: glavado@whitestack.com ## -DB_EXISTS="" - -max_attempts=120 -function wait_db(){ - db_host=$1 - db_port=$2 - attempt=0 - echo "Wait until $max_attempts seconds for MySQL mano Server ${db_host}:${db_port} " - while ! mysqladmin ping -h"$db_host" -P"$db_port" --silent; do - #wait 120 sec - if [ $attempt -ge $max_attempts ]; then - echo - echo "Can not connect to database ${db_host}:${db_port} during $max_attempts sec" - return 1 - fi - attempt=$[$attempt+1] - echo -n "." - sleep 1 - done - return 0 -} - -function is_db_created() { - db_host=$1 - db_port=$2 - db_user=$3 - db_pswd=$4 - db_name=$5 - - if mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -q $db_name; then - echo "DB $db_name exists" - return 0 - else - echo "DB $db_name does not exist" - return 1 - fi -} - -if [[ $OSMMON_SQL_DATABASE_URI == *'mysql'* ]]; then - DB_HOST=$(echo $OSMMON_SQL_DATABASE_URI | sed -r 's|^\w+://.+:.+@(.+):.*$|\1|') - DB_PORT=$(echo $OSMMON_SQL_DATABASE_URI | sed -r 's|^\w+://.*:([0-9]+).*$|\1|') - DB_USER=$(echo $OSMMON_SQL_DATABASE_URI | sed -r 's|^\w+://(.+):.+@.+$|\1|') - DB_PASSWORD=$(echo $OSMMON_SQL_DATABASE_URI | sed -r 's|^.+://.+:(.+)@.*$|\1|') - DB_NAME=$(echo $OSMMON_SQL_DATABASE_URI | sed -r 's|^\w+://.+:.+@.+:.*/(.+)$|\1|') - - wait_db "$DB_HOST" "$DB_PORT" || exit 1 - - is_db_created "$DB_HOST" "$DB_PORT" "$DB_USER" "$DB_PASSWORD" "$DB_NAME" && DB_EXISTS="Y" - - if [ -z $DB_EXISTS ]; then - mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" --default_character_set utf8 -e "CREATE DATABASE $DB_NAME" - fi -fi osm-mon-server & osm-mon-evaluator & osm-mon-collector & -osm-mon-dashboarder \ No newline at end of file +osm-mon-dashboarder -- 2.25.1