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=( 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=(