#!/bin/bash # --------------------------------------------------------------- # create_link() { ln -s $1 $2 2> /dev/null if [ $? -eq 0 ]; then echo "[ OK ] Link created: ${1}->${2}" else echo "[FAILED] No such file or directory: ${1}" exit 1 fi } # --------------------------------------------------------------- # echo "Step 01." cd $APP_PATH/ marker_file="marker_file_step_01" if [ -f $marker_file ]; then echo "$marker_file already exists" else echo "$marker_file does not exist" django-admin startproject config . create_link src/onegeo_suite/ . # Handle Django config files if [ -f "config/urls.py" ]; then rm config/urls.py fi if [ -f "config/settings.py" ]; then rm config/settings.py fi cp src/docker/settings.py config/settings.py cp src/docker/urls.py config/urls.py # Wait for the postgres server echo "Waiting for database..." i=1 while true do if $(nc -z ${DB_HOST} 5432) ; then echo "[${DB_HOST}] The database server is ready." break fi echo "[Retry: $i] The database server is not ready. Next attempt in ${TIME_SLEEP:-1}s" sleep ${TIME_SLEEP:-1} ((i++)) done # Build database # python manage.py migrate # Build static files python manage.py collectstatic # build i18n *.mo files python manage.py compilemessages --locale=fr echo "Ok" > $marker_file fi echo "$(basename $0) complete."