#!/bin/bash set -eux if [[ -z "$(ls -A /app/data)" ]]; then ln -sf /app/data/wp-config.php /app/code/wp-config.php mv /app/code/wp-content /app/data/wp-content/ ln -s /app/data/wp-content /app/code/wp-content fi : ${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}');/" \ -e "s|define('WP_HOME',.*|define('WP_HOME', 'https://$(hostname -f)');|" \ -e "s|define('WP_SITEURL',.*|define('WP_SITEURL', 'https://$(hostname -f)');|" \ /app/configs/wp-config.php.template > /app/code/wp-config.php /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i MediaWiki