From 0603b7fdb05a00fe9508c538a135f77d95f8f0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Flode=CC=81n?= Date: Mon, 8 Jan 2018 00:44:59 +0100 Subject: [PATCH 1/2] Check if volume contains older version of WordPress and update it --- docker-entrypoint.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( From ef736a9b6b95e29bcb3165a7a6da18726c410730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Flode=CC=81n?= Date: Mon, 8 Jan 2018 00:49:28 +0100 Subject: [PATCH 2/2] Run update.sh script --- php5.6/apache/docker-entrypoint.sh | 16 ++++++++++++---- php5.6/fpm-alpine/docker-entrypoint.sh | 16 ++++++++++++---- php5.6/fpm/docker-entrypoint.sh | 16 ++++++++++++---- php7.0/apache/docker-entrypoint.sh | 16 ++++++++++++---- php7.0/fpm-alpine/docker-entrypoint.sh | 16 ++++++++++++---- php7.0/fpm/docker-entrypoint.sh | 16 ++++++++++++---- php7.1/apache/docker-entrypoint.sh | 16 ++++++++++++---- php7.1/fpm-alpine/docker-entrypoint.sh | 16 ++++++++++++---- php7.1/fpm/docker-entrypoint.sh | 16 ++++++++++++---- php7.2/apache/docker-entrypoint.sh | 16 ++++++++++++---- php7.2/fpm-alpine/docker-entrypoint.sh | 16 ++++++++++++---- php7.2/fpm/docker-entrypoint.sh | 16 ++++++++++++---- 12 files changed, 144 insertions(+), 48 deletions(-) diff --git a/php5.6/apache/docker-entrypoint.sh b/php5.6/apache/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php5.6/apache/docker-entrypoint.sh +++ b/php5.6/apache/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php5.6/fpm-alpine/docker-entrypoint.sh b/php5.6/fpm-alpine/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php5.6/fpm-alpine/docker-entrypoint.sh +++ b/php5.6/fpm-alpine/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php5.6/fpm/docker-entrypoint.sh b/php5.6/fpm/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php5.6/fpm/docker-entrypoint.sh +++ b/php5.6/fpm/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.0/apache/docker-entrypoint.sh b/php7.0/apache/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.0/apache/docker-entrypoint.sh +++ b/php7.0/apache/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.0/fpm-alpine/docker-entrypoint.sh b/php7.0/fpm-alpine/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.0/fpm-alpine/docker-entrypoint.sh +++ b/php7.0/fpm-alpine/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.0/fpm/docker-entrypoint.sh b/php7.0/fpm/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.0/fpm/docker-entrypoint.sh +++ b/php7.0/fpm/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.1/apache/docker-entrypoint.sh b/php7.1/apache/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.1/apache/docker-entrypoint.sh +++ b/php7.1/apache/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.1/fpm-alpine/docker-entrypoint.sh b/php7.1/fpm-alpine/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.1/fpm-alpine/docker-entrypoint.sh +++ b/php7.1/fpm-alpine/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.1/fpm/docker-entrypoint.sh b/php7.1/fpm/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.1/fpm/docker-entrypoint.sh +++ b/php7.1/fpm/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.2/apache/docker-entrypoint.sh b/php7.2/apache/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.2/apache/docker-entrypoint.sh +++ b/php7.2/apache/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.2/fpm-alpine/docker-entrypoint.sh b/php7.2/fpm-alpine/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.2/fpm-alpine/docker-entrypoint.sh +++ b/php7.2/fpm-alpine/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=( diff --git a/php7.2/fpm/docker-entrypoint.sh b/php7.2/fpm/docker-entrypoint.sh index a91cd2dc7f..37414ca1ad 100755 --- a/php7.2/fpm/docker-entrypoint.sh +++ b/php7.2/fpm/docker-entrypoint.sh @@ -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 @@ -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 ) @@ -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=(