From dd8b567d7f4e522d6c10cf2c56c39bf3d27da963 Mon Sep 17 00:00:00 2001
From: Ethan Kromhout <ethan@unc.edu>
Date: Mon, 26 Aug 2019 08:55:31 -0400
Subject: [PATCH] Corrected PHP version number and added check for database
 starting

---
 Sources/HR/Dockerfile                      | 1 -
 Sources/HR/sentrifugo_server/Dockerfile    | 6 +++---
 Sources/HR/sentrifugo_server/entrypoint.sh | 3 ++-
 3 files changed, 5 insertions(+), 5 deletions(-)
 delete mode 100644 Sources/HR/Dockerfile

diff --git a/Sources/HR/Dockerfile b/Sources/HR/Dockerfile
deleted file mode 100644
index 1af79d8..0000000
--- a/Sources/HR/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-#to-do
diff --git a/Sources/HR/sentrifugo_server/Dockerfile b/Sources/HR/sentrifugo_server/Dockerfile
index b699348..5659e0e 100644
--- a/Sources/HR/sentrifugo_server/Dockerfile
+++ b/Sources/HR/sentrifugo_server/Dockerfile
@@ -19,13 +19,13 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update   && apt-get install -y  softw
 RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" >> /etc/apt/sources.list && echo "deb-src http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" >> /etc/apt/sourceis.list && apt-get update --allow-unauthenticated
 RUN cat /etc/apt/sources.list && ls -l /etc/apt/
 RUN apt-get  install -y --allow-unauthenticated apache2-bin libapache2-mod-php php-curl php-ldap php-mysql php-mcrypt \
-php-gd php-xml patch curl vim git mysql-client wget unzip lynx
+php-gd php-xml patch curl vim git mysql-client wget unzip lynx netcat
 
 RUN phpenmod mcrypt && phpenmod gd
 RUN a2enmod xml2enc && a2enmod rewrite
 
-RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.2/apache2/php.ini
-RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.2/cli/php.ini
+RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.3/apache2/php.ini
+RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php/7.3/cli/php.ini
 
 RUN useradd --uid 1000 --gid 50 docker
 
diff --git a/Sources/HR/sentrifugo_server/entrypoint.sh b/Sources/HR/sentrifugo_server/entrypoint.sh
index 0df0982..95534a1 100644
--- a/Sources/HR/sentrifugo_server/entrypoint.sh
+++ b/Sources/HR/sentrifugo_server/entrypoint.sh
@@ -5,11 +5,11 @@ cd /var/www/html
 if [ ! -s /var/www/html/sentrifugo/public/db_constants.php ]
 then
 sleep 15
+while ! nc -z  sentrifugo_data 3306 ; do echo waiting for mysql on sentrifugo_data to start; sleep 3; done;
 apachectl start && sleep 2 && curl -d "host=sentrifugo_data&username=sentrifugo&password=54y6RxN7GfC7aes3&dbname=sentrifugo" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step2.php && curl -data-raw "app_name=sentrifugo" -data-raw "email=sentrifugo.container@gmail.com" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:80/install/step3.php
 apachectl stop
 mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step3.sql
 mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step4.sql
-mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step5.sql
 mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/banderson.sql
 cd /tmp/
 /tmp
@@ -18,6 +18,7 @@ tar zxf lib_mysqludf_amqp-2.0.0.tar.gz
 cd /tmp/lib_mysqludf_amqp-2.0.0
 mysql -h sentrifugo_data -u root --password=54y6RxN7GfC7aes3 < installdb.sql
 mysql -h sentrifugo_data -u root --password=54y6RxN7GfC7aes3 sentrifugo  < /tmp/trigger.sql
+mysql -h sentrifugo_data -u sentrifugo --password=54y6RxN7GfC7aes3 sentrifugo < /tmp/step5.sql
 mv /var/www/html/sentrifugo/install /var/www/html/sentrifugo/install.old
 echo database initialization complete
 fi