start.sh 1016 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. set -eux
  3. if [[ -z "$(ls -A /app/data)" ]]; then
  4. cp /app/configs/wp-config.php.template /app/data/wp-config.php
  5. mv /app/code/wp-content /app/data/wp-content/
  6. ln -s /app/data/wp-content /app/code/wp-content
  7. fi
  8. : ${MYSQL_URL:=}
  9. if [[ -z "${MYSQL_URL}" ]]; then
  10. echo "MYSQL_URL is empty"
  11. exit 1
  12. fi
  13. proto="$(echo "${MYSQL_URL}" | sed -e's,^\(.*://\).*,\1,g')"
  14. url="$(echo ${MYSQL_URL/$proto/})"
  15. username="$(echo ${url} | cut -d: -f1)"
  16. password=$(echo ${url/$username:/} | cut -d@ -f1)
  17. host="$(echo ${url/$username:$password@/} | cut -d/ -f1)"
  18. db="$(echo ${url} | grep / | cut -d/ -f2-)"
  19. sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${db}');/" \
  20. -e "s/define('DB_USER',.*/define('DB_USER', '${username}');/" \
  21. -e "s/define('DB_PASSWORD',.*/define('DB_PASSWORD', '${password}');/" \
  22. -e "s/define('DB_HOST',.*/define('DB_HOST', '${host}');/" \
  23. -i /app/data/wp-config.php
  24. /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i MediaWiki