You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
7
-
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
8
-
file_env() {
9
-
local var="$1"
10
-
local fileVar="${var}_FILE"
11
-
local def="${2:-}"
12
-
if [ "${!var:-}" ] && [ "${!fileVar:-}" ];then
13
-
echo>&2"error: both $var and $fileVar are set (but are exclusive)"
14
-
exit 1
15
-
fi
16
-
local val="$def"
17
-
if [ "${!var:-}" ];then
18
-
val="${!var}"
19
-
elif [ "${!fileVar:-}" ];then
20
-
val="$(<"${!fileVar}")"
21
-
fi
22
-
export"$var"="$val"
23
-
unset"$fileVar"
24
-
}
25
-
26
-
if [[ "$1"== apache2* ]] || [ "$1"== php-fpm ];then
27
-
if [ "$(id -u)"='0' ];then
4
+
if [[ "$1"== apache2* ]] || [ "$1"='php-fpm' ];then
5
+
uid="$(id -u)"
6
+
gid="$(id -g)"
7
+
if [ "$uid"='0' ];then
28
8
case"$1"in
29
9
apache2*)
30
10
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
41
21
;;
42
22
esac
43
23
else
44
-
user="$(id -u)"
45
-
group="$(id -g)"
24
+
user="$uid"
25
+
group="$gid"
46
26
fi
47
27
48
28
if [ !-e index.php ] && [ !-e wp-includes/version.php ];then
49
29
# if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory)
if [ !-s wp-config.php ] && [ "${#wpEnvs[@]}"-gt 0 ];then
69
+
forwpConfigDockerin \
70
+
wp-config-docker.php \
71
+
/usr/src/wordpress/wp-config-docker.php \
72
+
;do
73
+
if [ -s"$wpConfigDocker" ];then
74
+
echo>&2"No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})"
75
+
# using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables)
echo>&2"WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
274
-
echo>&2' continuing anyways (which might have unexpected results)'
275
-
echo>&2
276
-
fi
277
88
fi
278
-
279
-
# now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
0 commit comments