1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/bin/bash
- set -eux
- readonly WP=/app/code/wp
- if [[ -z "$(ls -A /app/data)" ]]; then
- echo "Copying wp-content files on first run"
- mv /app/code/wp-content /app/data/wp-content/
- rm -rf /app/code/wp-content
- ln -sf /app/data/wp-content /app/code/wp-content
- $WP core config --allow-root --dbname="${MYSQL_DATABASE}" --dbuser="${MYSQL_USERNAME}" --dbpass="${MYSQL_PASSWORD}" --dbhost="${MYSQL_HOST}" --extra-php <<EOF
- // prevent user from changing the Settings->General, WordPress and Blog address values.
- define('WP_HOME', 'https://$(hostname -f)');
- define('WP_SITEURL', 'https://$(hostname -f)');
- /*
- http://cmanios.wordpress.com/2014/04/12/nginx-https-reverse-proxy-to-wordpress-with-apache-http-and-different-port/
- http://wordpress.org/support/topic/compatibility-with-wordpress-behind-a-reverse-proxy
- https://wordpress.org/support/topic/wp_home-and-wp_siteurl
- */
- // If WordPress is behind reverse proxy which proxies https to http
- if (!empty(\$_SERVER['HTTP_X_FORWARDED_FOR'])) {
- \$_SERVER['HTTP_HOST'] = \$_SERVER['HTTP_X_FORWARDED_HOST'];
- if (\$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
- \$_SERVER['HTTPS']='on';
- }
- EOF
- readonly admin_password=$(pwgen -1)
- readonly admin_email=${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}
- echo "Admin password is ${admin_password}"
- $WP --url="https://$(hostname -f)" core install \
- --allow-root \
- --url="https://$(hostname -f)" \
- --title="My blog" \
- --admin_user=admin \
- --admin_password="${admin_password}" \
- --admin_email="${admin_email}"
- echo "Installing OAuth plugin"
- ./wp plugin install --allow-root --activate --force https://github.com//cloudron-io/WP-OAuth/archive/5e77ff326b26f6175fefcd25f46d6c45e0fa14fa.zip
- else
- rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data
- ln -sf /app/data/wp-content /app/code/wp-content
- fi
- # Settings to be updated on every run
- sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${MYSQL_DATABASE}');/" \
- -e "s/define('DB_USER',.*/define('DB_USER', '${MYSQL_USERNAME}');/" \
- -e "s/define('DB_PASSWORD',.*/define('DB_PASSWORD', '${MYSQL_PASSWORD}');/" \
- -e "s/define('DB_HOST',.*/define('DB_HOST', '${MYSQL_HOST}');/" \
- -i /app/data/wp-config.php # sed -i seems to destroy symlink
- /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i WordPress
|