start.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. -e "s|define('WP_HOME',.*|define('WP_HOME', 'https://$(hostname -f)');|" \
  24. -e "s|define('WP_SITEURL',.*|define('WP_SITEURL', 'https://$(hostname -f)');|" \
  25. -i /app/data/wp-config.php
  26. /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i MediaWiki