From 5e99c3047c404c29dd38abb15a0646e994cd3700 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 20 May 2016 10:37:01 +0200 Subject: [PATCH] rebase --- entrypoint.sh | 13 ++++++++----- templates/fbctf.conf | 3 +-- templates/settings.tmpl.ini | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9e866ef..63cd78e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,7 +37,7 @@ if ${SSL_SELF_SIGNED:=true}; then ln -s /etc/nginx/sites-available/fbctf-ssl.conf /etc/nginx/sites-enabled/fbctf-ssl.conf else ln -s /etc/nginx/sites-available/fbctf.conf /etc/nginx/sites-enabled/fbctf.conf - sed -i -r -e '/private static bool \$s_secure/ {s/true/false/}' /var/www/fbctf/src/SessionUtils.php + sed -i -r -e '/private static bool \$s_secure/ {s/true/false/}' $CTF_PATH/src/SessionUtils.php fi # Forward request and error logs to docker log collector @@ -45,26 +45,29 @@ ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log # Set linked mysql container as mysql host -echo -e "[client]\nhost=mysql" > ~/.my.cnf + +echo -e "[client]\nhost=$MYSQL_HOST" > ~/.my.cnf # Wait for the mysql container to be ready -while ! nc -z mysql 3306; do - echo "Waiting for mysql to start"; +while ! mysqlshow -u$MYSQL_USER -p$MYSQL_PASSWORD > /dev/null 2>&1; do + echo "Waiting for mysql to be ready"; sleep 1; done; -# Don't errase the database if it exists +# Don't errase the database if it exists & has table if [ $(mysql -N -s -u $MYSQL_USER --password=$MYSQL_PASSWORD -e \ "select count(*) from information_schema.tables where \ table_schema='$MYSQL_DATABASE';") -ge 1 ]; then echo "Database already created... skipping creation..." else +echo "creating DB" import_empty_db "$MYSQL_USER" "$MYSQL_PASSWORD" "$MYSQL_DATABASE" "$CTF_PATH" "prod" fi # Configuring settings.ini cat "$CTF_PATH/settings.tmpl.ini" \ | sed "s/MYSQL_PORT/$MYSQL_PORT/g" \ + | sed "s/MYSQL_HOST/$MYSQL_HOST/g" \ | sed "s/MYSQL_DATABASE/$MYSQL_DATABASE/g" \ | sed "s/MYSQL_USER/$MYSQL_USER/g" \ | sed "s/MYSQL_PASSWORD/$MYSQL_PASSWORD/g" \ diff --git a/templates/fbctf.conf b/templates/fbctf.conf index 9e1786a..3b0d961 100644 --- a/templates/fbctf.conf +++ b/templates/fbctf.conf @@ -9,7 +9,6 @@ server { location ~ \.php$ { try_files $uri =404; - #fastcgi_pass unix:/var/run/hhvm/sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; @@ -17,4 +16,4 @@ server { } error_page 400 401 402 403 404 500 /error.php; client_max_body_size 25M; -} +} \ No newline at end of file diff --git a/templates/settings.tmpl.ini b/templates/settings.tmpl.ini index 1ecd1ae..86ab051 100644 --- a/templates/settings.tmpl.ini +++ b/templates/settings.tmpl.ini @@ -1,10 +1,10 @@ ; Values are replaced by env variables at boot time -DB_HOST = 'mysql' +DB_HOST = 'MYSQL_HOST' DB_PORT = 'MYSQL_PORT' DB_NAME = 'MYSQL_DATABASE' DB_USERNAME = 'MYSQL_USER' DB_PASSWORD = 'MYSQL_PASSWORD' -MC_HOST = 'memcached' +MC_HOST = 'MEMCACHED_HOST' MC_PORT = 'MEMCACHED_PORT'