From 42557dd67e223e6ea38ff6803363024415ac67dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Flod=C3=A9n?= Date: Mon, 6 Aug 2018 22:13:52 +0200 Subject: [PATCH] Compare Grav version on startup and upgrade if necessary --- php7.2/apache/docker-entrypoint.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/php7.2/apache/docker-entrypoint.sh b/php7.2/apache/docker-entrypoint.sh index 139d33a..de67071 100755 --- a/php7.2/apache/docker-entrypoint.sh +++ b/php7.2/apache/docker-entrypoint.sh @@ -1,7 +1,21 @@ #!/bin/sh set -e +message="" + if [ -z "$(ls -A /var/www/html)" ]; then + message="Grav not found in $PWD - copying now..." +else + # trick sort -V to handle -alpha, -beta, -rc etc. See https://stackoverflow.com/a/40391207 + newest_version=`sed -n "s/^define('GRAV_VERSION', '\(.*\)');$/\1/p" system/defines.php /usr/src/grav-admin/system/defines.php | sed '/-/!{s/$/_/}' | sort -V | tail -1` + current_version=`sed -n "s/^define('GRAV_VERSION', '\(.*\)');$/\1/p" system/defines.php | sed '/-/!{s/$/_/}'` + if [ $newest_version != $current_version ]; then + message="Newer version of Grav found - copying now..." + fi +fi + +if [ -n "$message" ]; then + echo $message cp -a /usr/src/grav-admin/. /var/www/html/ chown -R www-data:www-data /var/www/html if [ "$GRAV_REVERSE_PROXY" = "true" ]; then