Skip to content

Commit d368dc0

Browse files
author
Mike
committed
rebase
- make proper use of mysql_host - use mysqlshow to prevent secured containers failing - memcached - fix mysqlhost
1 parent 1165f76 commit d368dc0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

entrypoint.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,29 @@ 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
5152
while ! mysqlshow -u$MYSQL_USER -p$MYSQL_PASSWORD > /dev/null 2>&1; do
5253
echo "Waiting for mysql to be ready";
5354
sleep 1;
5455
done;
5556

56-
57-
# Don't errase the database if it exists
57+
# Don't errase the database if it exists & has table
5858
if [ $(mysql -N -s -u $MYSQL_USER --password=$MYSQL_PASSWORD -e \
5959
"select count(*) from information_schema.tables where \
6060
table_schema='$MYSQL_DATABASE';") -ge 1 ]; then
6161
echo "Database already created... skipping creation..."
6262
else
63+
echo "creating DB"
6364
import_empty_db "$MYSQL_USER" "$MYSQL_PASSWORD" "$MYSQL_DATABASE" "$CTF_PATH" "prod"
6465
fi
6566

6667
# Configuring settings.ini
6768
cat "$CTF_PATH/settings.tmpl.ini" \
6869
| sed "s/MYSQL_PORT/$MYSQL_PORT/g" \
70+
| sed "s/MYSQL_HOST/$MYSQL_HOST/g" \
6971
| sed "s/MYSQL_DATABASE/$MYSQL_DATABASE/g" \
7072
| sed "s/MYSQL_USER/$MYSQL_USER/g" \
7173
| sed "s/MYSQL_PASSWORD/$MYSQL_PASSWORD/g" \

templates/fbctf.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ 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;

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)