22
33set -eo pipefail
44
5+ #
6+ # Setup Wordpress files, extracts from files provided by official WordPress base image
7+ #
58setupWP () {
69 echo " >> Installing Wordpress"
710 /usr/local/bin/docker-entrypoint.sh || exit 1
811}
912
13+ #
14+ # Preinstall WordPress, setup admin account, set URL, install plugins etc. - make it immediately ready
15+ #
1016preinstallWP () {
1117 if [[ " ${WP_PREINSTALL} " == " true" ]]; then
1218 wp core install --url=${WP_SITE_URL} --title=${WP_SITE_TITLE} --admin_user=${WP_SITE_ADMIN_LOGIN} --admin_password=${WP_SITE_ADMIN_PASSWORD} --admin_email=${WP_SITE_ADMIN_EMAIL}
1319 /usr/local/bin/install-plugins-first-time.sh no-wait
1420 fi
1521}
1622
23+ #
24+ # Automatic updates
25+ #
1726scheduleAutoupdate () {
1827 echo -n " >> Checking if autoupdate should be scheduled..."
1928 if [[ " ${AUTO_UPDATE_CRON} " != " " ]]; then
@@ -24,6 +33,9 @@ scheduleAutoupdate() {
2433 fi
2534}
2635
36+ #
37+ # Basic AUTH on wp-login.php is a very primitive additional layer of security against bots
38+ #
2739setupBasicAuth () {
2840 if [[ " ${BASIC_AUTH_USER} " ]] && [[ " ${BASIC_AUTH_PASSWORD} " ]]; then
2941 echo " >> Writing to basic auth file - /opt/htpasswd"
@@ -33,17 +45,34 @@ setupBasicAuth() {
3345 fi
3446}
3547
48+ #
49+ # Runtime configuration setup: NGINX, PHP configuration is templated during startup
50+ # to allow using environment variables as configuration
51+ #
3652setupConfiguration () {
3753 echo " >> Rendering configuration files..."
3854 p2 --template /templates/etc/nginx/nginx.conf > /etc/nginx/nginx.conf
3955 p2 --template /templates/usr/local/etc/php/php.ini > /usr/local/etc/php/php.ini
4056}
4157
58+ #
59+ # Extra files: In /mnt/extra-files you can volume-mount extra files that would be copied into WWW-root directory
60+ # This allows to keep WWW-root directory not mounted by any volume to avoid conflicts with permissions
61+ # (mounted volumes are creating directories owned by ROOT)
62+ #
63+ copyExtraFiles () {
64+ echo " >> Copying extra files if placed in /mnt/extra-files"
65+ if [[ -d /mnt/extra-files ]]; then
66+ cp -rf /mnt/extra-files/* /var/www/riotkit/
67+ fi
68+ }
69+
4270scheduleAutoupdate
4371setupBasicAuth
4472setupConfiguration
4573setupWP
4674preinstallWP
75+ copyExtraFiles
4776
4877# Allows to pass own CMD
4978# Also allows to execute tests on the container
@@ -52,4 +81,9 @@ if [[ "${1}" == "exec" ]] || [[ "${1}" == "sh" ]] || [[ "${1}" == "bash" ]] || [
5281 exec " $@ "
5382fi
5483
55- exec multirun " php-fpm" " nginx -c /etc/nginx/nginx.conf" " crond -f -d 6" " /usr/local/bin/install-plugins-first-time.sh"
84+ multirun_args=(" php-fpm" " nginx -c /etc/nginx/nginx.conf" " /usr/local/bin/install-plugins-first-time.sh" )
85+ if [[ " ${AUTO_UPDATE_CRON} " != " " ]]; then
86+ multirun_args+=(" crond -f -d 6" )
87+ fi
88+
89+ exec multirun " ${multirun_args[@]} "
0 commit comments