Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if volume contains older version of WordPress and update it #272

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php5.6/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php5.6/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php5.6/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.0/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.0/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.0/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.1/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.1/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
16 changes: 12 additions & 4 deletions php7.1/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ file_env() {
unset "$fileVar"
}

# usage version "version.php"
# extracts Wordpress version from version.php file
version() {
sed -n 's/^\$wp_version[^0-9]*\([0-9.]*\).*;$/\1/p' $1 | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ "$(id -u)" = '0' ]; then
case "$1" in
Expand All @@ -40,8 +46,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
group="$(id -g)"
fi

if ! [ -e index.php -a -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if ! [ -e index.php -a -e wp-includes/version.php ] || [ $(version wp-includes/version.php) -lt $(version /usr/src/wordpress/wp-includes/version.php) ]; then
if [ -e wp-includes/version.php ]; then
echo >&2 "Older version of WordPress found in $PWD - copying now..."
else
echo >&2 "WordPress not found in $PWD - copying now..."
fi
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
Expand Down Expand Up @@ -71,8 +81,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version

# allow any of these "Authentication Unique Keys and Salts." to be specified via
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
uniqueEnvs=(
Expand Down
Loading