From eeeae9d2b257e980b0f79e6972820fadf7509b3c Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 21 Sep 2016 10:59:08 -0300 Subject: [PATCH 1/2] Added control to check default registry dabatase --- container_files/bin/main.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index 845b2e0..bf7e3ac 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -23,7 +23,24 @@ echo "" >> $log if [ -e "/tmp/firsttimerunning" ]; then set -e - + + echo "Testing connectivy to database $MYSQL_DATABASE before continue with install" >> $log + echo "Testing connectivy to database $MYSQL_DATABASE before continue with install" + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + echo "checking connectivity" >> $log + while [ "$laststatus" != "0" ]; do + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + sleep 5 + date >> $log + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" >> $log + done + echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" >> $log + echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" + date >> $log + /opt/bin/configure.sh >> $log /opt/bin/cleanup.sh >> $log From c6dbd5aacdb7485029b3e6ab01a0696c0ebc470e Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 21 Sep 2016 11:19:29 -0300 Subject: [PATCH 2/2] Added configure_mysql in other file --- container_files/bin/configure_mysql.sh | 37 ++++++++++++++++++++++++++ container_files/bin/main.sh | 17 ------------ 2 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 container_files/bin/configure_mysql.sh diff --git a/container_files/bin/configure_mysql.sh b/container_files/bin/configure_mysql.sh new file mode 100644 index 0000000..10d0b9b --- /dev/null +++ b/container_files/bin/configure_mysql.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Licensed to the University Corporation for Advanced Internet Development, +# Inc. (UCAID) under one or more contributor license agreements. See the +# NOTICE file distributed with this work for additional information regarding +# copyright ownership. The UCAID licenses this file to You 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. +# +log=/opt/log/configure_mysql.log + +date >> $log +echo "Starting Database connection with $MYSQL_DATABASE" >> $log +if [ -z ${COMPOSE+x} ]; then + echo "Comanage is not compsoed, no mariadb database are needed" >> $log +else + echo "Testing connectivy to database $MYSQL_DATABASE before continue with install" >> $log + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + echo "checking connectivity" >> $log + while [ "$laststatus" != "0" ]; do + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" + laststatus="$?" + sleep 5 + date >> $log + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" >> $log + done + echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" >> $log + date >> $log +fi diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index bf7e3ac..f5121c3 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -24,23 +24,6 @@ if [ -e "/tmp/firsttimerunning" ]; then set -e - echo "Testing connectivy to database $MYSQL_DATABASE before continue with install" >> $log - echo "Testing connectivy to database $MYSQL_DATABASE before continue with install" - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" - laststatus="$?" - echo "checking connectivity" >> $log - while [ "$laststatus" != "0" ]; do - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use $MYSQL_DATABASE; show tables;" - laststatus="$?" - sleep 5 - date >> $log - echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" - echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" >> $log - done - echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" >> $log - echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" - date >> $log - /opt/bin/configure.sh >> $log /opt/bin/cleanup.sh >> $log