Skip to content

Commit

Permalink
Apply "chown", but very conservatively
Browse files Browse the repository at this point in the history
In the interest of not breaking people, only chown the root directory when we've determined WordPress is not installed, the permissions on the directory are root:root/0:0 (and it is thus likely the directory was "helpfully" auto-created by Docker), and we are running as root (and thus able to chown).
  • Loading branch information
neil authored and tianon committed Jan 31, 2019
1 parent d775299 commit 4e108fd
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.1/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.1/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.1/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.2/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.2/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.2/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.3/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.3/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down
5 changes: 5 additions & 0 deletions php7.3/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# 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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
Expand Down

0 comments on commit 4e108fd

Please sign in to comment.