#!/bin/bash set -e; install() { cd /app wget --quiet https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz rm latest.tar.gz } config() { if [ -n $MYSQL_DATABASE ]; then sed -i "s:MYSQL_DATABASE:$MYSQL_DATABASE:" /app/wordpress/wp-config.php; fi if [ -n $MYSQL_USER ]; then sed -i "s:MYSQL_USER:$MYSQL_USER:" /app/wordpress/wp-config.php; fi if [ -n $MYSQL_PASSWORD ]; then sed -i "s:MYSQL_PASSWORD:$MYSQL_PASSWORD:" /app/wordpress/wp-config.php; fi if [ -n $MYSQL_HOST ]; then sed -i "s:MYSQL_HOST:$MYSQL_HOST:" /app/wordpress/wp-config.php; fi SALT_KEYS=$(curl -s https://api.wordpress.org/secret-key/1.1/salt) echo $SALT_KEYS >> /app/wordpress/wp-config.php; } create_wpconfig() { if [ -n /app/wordpress/wp-config.php ]; then cp /tmp/wp-config-sample.php /app/wordpress/wp-config.php; fi } install create_wpconfig config echo "Starting Wordpress" exec $@