Skip to content

Commit 5e99c30

Browse files
author
Mike
committed
rebase
1 parent ac8b441 commit 5e99c30

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

entrypoint.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,37 @@ if ${SSL_SELF_SIGNED:=true}; then
3737
ln -s /etc/nginx/sites-available/fbctf-ssl.conf /etc/nginx/sites-enabled/fbctf-ssl.conf
3838
else
3939
ln -s /etc/nginx/sites-available/fbctf.conf /etc/nginx/sites-enabled/fbctf.conf
40-
sed -i -r -e '/private static bool \$s_secure/ {s/true/false/}' /var/www/fbctf/src/SessionUtils.php
40+
sed -i -r -e '/private static bool \$s_secure/ {s/true/false/}' $CTF_PATH/src/SessionUtils.php
4141
fi
4242

4343
# Forward request and error logs to docker log collector
4444
ln -sf /dev/stdout /var/log/nginx/access.log \
4545
&& ln -sf /dev/stderr /var/log/nginx/error.log
4646

4747
# Set linked mysql container as mysql host
48-
echo -e "[client]\nhost=mysql" > ~/.my.cnf
48+
49+
echo -e "[client]\nhost=$MYSQL_HOST" > ~/.my.cnf
4950

5051
# Wait for the mysql container to be ready
51-
while ! nc -z mysql 3306; do
52-
echo "Waiting for mysql to start";
52+
while ! mysqlshow -u$MYSQL_USER -p$MYSQL_PASSWORD > /dev/null 2>&1; do
53+
echo "Waiting for mysql to be ready";
5354
sleep 1;
5455
done;
5556

56-
# Don't errase the database if it exists
57+
# Don't errase the database if it exists & has table
5758
if [ $(mysql -N -s -u $MYSQL_USER --password=$MYSQL_PASSWORD -e \
5859
"select count(*) from information_schema.tables where \
5960
table_schema='$MYSQL_DATABASE';") -ge 1 ]; then
6061
echo "Database already created... skipping creation..."
6162
else
63+
echo "creating DB"
6264
import_empty_db "$MYSQL_USER" "$MYSQL_PASSWORD" "$MYSQL_DATABASE" "$CTF_PATH" "prod"
6365
fi
6466

6567
# Configuring settings.ini
6668
cat "$CTF_PATH/settings.tmpl.ini" \
6769
| sed "s/MYSQL_PORT/$MYSQL_PORT/g" \
70+
| sed "s/MYSQL_HOST/$MYSQL_HOST/g" \
6871
| sed "s/MYSQL_DATABASE/$MYSQL_DATABASE/g" \
6972
| sed "s/MYSQL_USER/$MYSQL_USER/g" \
7073
| sed "s/MYSQL_PASSWORD/$MYSQL_PASSWORD/g" \

templates/fbctf.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ server {
99

1010
location ~ \.php$ {
1111
try_files $uri =404;
12-
#fastcgi_pass unix:/var/run/hhvm/sock;
1312
fastcgi_pass 127.0.0.1:9000;
1413
fastcgi_index index.php;
1514
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1615
include fastcgi_params;
1716
}
1817
error_page 400 401 402 403 404 500 /error.php;
1918
client_max_body_size 25M;
20-
}
19+
}

templates/settings.tmpl.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; Values are replaced by env variables at boot time
22

3-
DB_HOST = 'mysql'
3+
DB_HOST = 'MYSQL_HOST'
44
DB_PORT = 'MYSQL_PORT'
55
DB_NAME = 'MYSQL_DATABASE'
66
DB_USERNAME = 'MYSQL_USER'
77
DB_PASSWORD = 'MYSQL_PASSWORD'
88

9-
MC_HOST = 'memcached'
9+
MC_HOST = 'MEMCACHED_HOST'
1010
MC_PORT = 'MEMCACHED_PORT'

0 commit comments

Comments
 (0)