2
2
3
3
set -eo pipefail
4
4
5
+ #
6
+ # Setup Wordpress files, extracts from files provided by official WordPress base image
7
+ #
5
8
setupWP () {
6
9
echo " >> Installing Wordpress"
7
10
/usr/local/bin/docker-entrypoint.sh || exit 1
8
11
}
9
12
13
+ #
14
+ # Preinstall WordPress, setup admin account, set URL, install plugins etc. - make it immediately ready
15
+ #
10
16
preinstallWP () {
11
17
if [[ " ${WP_PREINSTALL} " == " true" ]]; then
12
18
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}
13
19
/usr/local/bin/install-plugins-first-time.sh no-wait
14
20
fi
15
21
}
16
22
23
+ #
24
+ # Automatic updates
25
+ #
17
26
scheduleAutoupdate () {
18
27
echo -n " >> Checking if autoupdate should be scheduled..."
19
28
if [[ " ${AUTO_UPDATE_CRON} " != " " ]]; then
@@ -24,6 +33,9 @@ scheduleAutoupdate() {
24
33
fi
25
34
}
26
35
36
+ #
37
+ # Basic AUTH on wp-login.php is a very primitive additional layer of security against bots
38
+ #
27
39
setupBasicAuth () {
28
40
if [[ " ${BASIC_AUTH_USER} " ]] && [[ " ${BASIC_AUTH_PASSWORD} " ]]; then
29
41
echo " >> Writing to basic auth file - /opt/htpasswd"
@@ -33,17 +45,34 @@ setupBasicAuth() {
33
45
fi
34
46
}
35
47
48
+ #
49
+ # Runtime configuration setup: NGINX, PHP configuration is templated during startup
50
+ # to allow using environment variables as configuration
51
+ #
36
52
setupConfiguration () {
37
53
echo " >> Rendering configuration files..."
38
54
p2 --template /templates/etc/nginx/nginx.conf > /etc/nginx/nginx.conf
39
55
p2 --template /templates/usr/local/etc/php/php.ini > /usr/local/etc/php/php.ini
40
56
}
41
57
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
+
42
70
scheduleAutoupdate
43
71
setupBasicAuth
44
72
setupConfiguration
45
73
setupWP
46
74
preinstallWP
75
+ copyExtraFiles
47
76
48
77
# Allows to pass own CMD
49
78
# Also allows to execute tests on the container
@@ -52,4 +81,9 @@ if [[ "${1}" == "exec" ]] || [[ "${1}" == "sh" ]] || [[ "${1}" == "bash" ]] || [
52
81
exec " $@ "
53
82
fi
54
83
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