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 845b2e0..f5121c3 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -23,7 +23,7 @@ echo "" >> $log if [ -e "/tmp/firsttimerunning" ]; then set -e - + /opt/bin/configure.sh >> $log /opt/bin/cleanup.sh >> $log