Skip to content

Commit 1b48b4b

Browse files
authored
Merge pull request #249 from akolnoochenko/master
Change hardcoded www-data:www-data
2 parents 1e1456c + 43d3269 commit 1b48b4b

File tree

13 files changed

+312
-39
lines changed

13 files changed

+312
-39
lines changed

docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php5.6/apache/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php5.6/fpm-alpine/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php5.6/fpm/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php7.0/apache/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php7.0/fpm-alpine/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

php7.0/fpm/docker-entrypoint.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
if [ "$(id -u)" = '0' ]; then
28+
case "$1" in
29+
apache2*)
30+
user="${APACHE_RUN_USER:-www-data}"
31+
group="${APACHE_RUN_GROUP:-www-data}"
32+
;;
33+
*) # php-fpm
34+
user='www-data'
35+
group='www-data'
36+
;;
37+
esac
38+
else
39+
user="$(id -u)"
40+
group="$(id -g)"
41+
fi
42+
2743
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2844
echo >&2 "WordPress not found in $PWD - copying now..."
2945
if [ "$(ls -A)" ]; then
3046
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3147
( set -x; ls -A; sleep 10 )
3248
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
49+
tar --create \
50+
--file - \
51+
--one-file-system \
52+
--directory /usr/src/wordpress \
53+
--owner "$user" --group "$group" \
54+
. | tar --extract --file -
3455
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3556
if [ ! -e .htaccess ]; then
3657
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -46,7 +67,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4667
</IfModule>
4768
# END WordPress
4869
EOF
49-
chown www-data:www-data .htaccess
70+
chown "$user:$group" .htaccess
5071
fi
5172
fi
5273

@@ -115,7 +136,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
115136
}
116137
117138
EOPHP
118-
chown www-data:www-data wp-config.php
139+
chown "$user:$group" wp-config.php
119140
fi
120141

121142
# see http://stackoverflow.com/a/2705678/433558

0 commit comments

Comments
 (0)