@@ -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
3838else
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
4141fi
4242
4343# Forward request and error logs to docker log collector
4444ln -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;
5455done ;
5556
56- # Don't errase the database if it exists
57+ # Don't errase the database if it exists & has table
5758if [ $( 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..."
6162else
63+ echo " creating DB"
6264 import_empty_db " $MYSQL_USER " " $MYSQL_PASSWORD " " $MYSQL_DATABASE " " $CTF_PATH " " prod"
6365fi
6466
6567# Configuring settings.ini
6668cat " $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" \
0 commit comments