diff --git a/Dockerfile b/Dockerfile index aea12836..1475796e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ LABEL ImageOS=centos7 LABEL Version=$version ENV VERSION=$version ENV TOMCAT_VERSION="6.0.35" - ENV WAIT_TIME=60 LABEL Build docker build --rm --tag $maintainer/$imagename . @@ -41,4 +40,4 @@ VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs EXPOSE 8080 8009 8005 -CMD ["/opt/bin/start.sh"] \ No newline at end of file +CMD ["/opt/bin/start.sh"] diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index 2b0e354d..2d859e83 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -3,13 +3,13 @@ log="/tmp/grouper.log" echo "Installing schema" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt >> $log echo "Preparing subjects" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt >> $log echo "Adding Quickstart data" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt >> $log echo "Checking" >> $log -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log \ No newline at end of file +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log diff --git a/container_files/bin/cleanup.sh b/container_files/bin/cleanup.sh index a829a2ed..8a9bcb47 100755 --- a/container_files/bin/cleanup.sh +++ b/container_files/bin/cleanup.sh @@ -1,5 +1,11 @@ #!/bin/bash -log="/tmp/grouper.log" - -rm -f /tmp/firsttimerunning >> $log \ No newline at end of file +log="/tmp/grouper-cleanup.log" +date >> $log +if [ -z ${COMPOSE+x} ];then +echo "Not composed so not waiting for MariaDB and first time running was ok: " >> $log +rm -f /tmp/firsttimerunning >> $log +else +echo "Composed with MariaDB, running completed" >> $log +rm -f /tmp/firsttimerunning >> $log +fi diff --git a/container_files/bin/configure.sh b/container_files/bin/configure.sh index 4fc9d922..f092a113 100755 --- a/container_files/bin/configure.sh +++ b/container_files/bin/configure.sh @@ -1,7 +1,7 @@ #!/bin/bash -log="/tmp/grouper.log" - +log="/tmp/grouper-configure.log" +date >> $log #sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/etc/grouper.installer.properties >> $log # Long-lived configuration values, these are symlinked into place @@ -24,4 +24,4 @@ sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/etc/grouper.properties >> $lo cat /opt/etc/grouper.hibernate.properties >> $log -cat /opt/etc/grouper.properties >> $log \ No newline at end of file +cat /opt/etc/grouper.properties >> $log diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index 9a780614..3bda674b 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -log="/tmp/start.log" +log="/tmp/start-main.log" echo "Starting Container: " > $log date >> $log @@ -20,5 +20,4 @@ else echo "Grouper container has run." >> $log echo "If there are problems, docker rm this container and try again." >> $log fi - exit 0 diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index d354de68..d918f9e9 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -1,7 +1,7 @@ #!/bin/bash -log="/tmp/start.log" - +log="/tmp/start-starting.log" +date >> $log if [ -z ${COMPOSE+x} ] then echo "Not composed so not waiting for MariaDB: " > $log @@ -13,11 +13,21 @@ then echo "Not composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" exit 0 fi else echo "Composed so waiting for MariaDB: " > $log - /opt/wait-for-it/wait-for-it.sh $MYSQL_HOST:3306 -t $WAIT_TIME --strict -- /opt/bin/main.sh + echo "Testing connectivy to database before continue with install" + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" + laststatus="$?" + while [ "$laststatus" != "0" ]; do + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;" + laststatus="$?" + sleep 5 + echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE" + done + /opt/bin/main.sh laststatus="$?" echo "Composed status: $laststatus" if [ "$laststatus" != "0" ]; then @@ -25,6 +35,7 @@ else echo "Composed non-zero exit status: $laststatus" exit 1 else + echo "Grouper was configured" exit 0 fi fi