X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=docker%2Fscripts%2Fstart.sh;h=0e50f25775524c7836de19525f546daa2224261f;hb=4b9f79e2820a011f6ebbba7fb92cdc120b364650;hp=fc0b3c33a25a8fae79752fc51b82a535d1f22a5c;hpb=30d94690e5a7220fdc084139b594e0da383563c5;p=osm%2FMON.git diff --git a/docker/scripts/start.sh b/docker/scripts/start.sh index fc0b3c3..0e50f25 100644 --- a/docker/scripts/start.sh +++ b/docker/scripts/start.sh @@ -1,56 +1,25 @@ -DB_EXISTS="" +# -*- coding: utf-8 -*- -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 -} +# Copyright 2018 Whitestack, LLC +# ************************************************************* -function is_db_created() { - db_host=$1 - db_port=$2 - db_user=$3 - db_pswd=$4 - db_name=$5 +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC - 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 -} +# 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 -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 +# http://www.apache.org/licenses/LICENSE-2.0 - 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 +# 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. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: glavado@whitestack.com +## osm-mon-server & osm-mon-evaluator &