#!/bin/bash set -eux if [[ -z "$(ls -A /app/data)" ]]; then echo "Copying wp-content files on first run" mv /app/code/wp-content /app/data/wp-content/ fi [[ ! -L "/app/code/wp-content" ]] && rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data ln -sf /app/data/wp-content /app/code/wp-content : ${MYSQL_URL:=} if [[ -z "${MYSQL_URL}" ]]; then echo "MYSQL_URL is empty" exit 1 fi proto="$(echo "${MYSQL_URL}" | sed -e's,^\(.*://\).*,\1,g')" url="$(echo ${MYSQL_URL/$proto/})" username="$(echo ${url} | cut -d: -f1)" password=$(echo ${url/$username:/} | cut -d@ -f1) host="$(echo ${url/$username:$password@/} | cut -d/ -f1)" db="$(echo ${url} | grep / | cut -d/ -f2-)" sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${db}');/" \ -e "s/define('DB_USER',.*/define('DB_USER', '${username}');/" \ -e "s/define('DB_PASSWORD',.*/define('DB_PASSWORD', '${password}');/" \ -e "s/define('DB_HOST',.*/define('DB_HOST', '${host}');/" \ /app/configs/wp-config.php.template > /app/code/wp-config.php /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i WordPress