12345678910111213141516171819202122232425262728293031 |
- #!/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}');/" \
- /app/configs/wp-config.php.template > /app/code/wp-config.php
- /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i WordPress
|