From 04b699a3c7cef6c5ad9f2efc202bbe376ad299b0 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 10 Dec 2018 13:22:25 +0100 Subject: [PATCH] [PHP-FPM] Trigger mysql_upgrade --- data/Dockerfiles/phpfpm/Dockerfile | 1 + data/Dockerfiles/phpfpm/docker-entrypoint.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/data/Dockerfiles/phpfpm/Dockerfile b/data/Dockerfiles/phpfpm/Dockerfile index a23a767e9..eb4110248 100644 --- a/data/Dockerfiles/phpfpm/Dockerfile +++ b/data/Dockerfiles/phpfpm/Dockerfile @@ -20,6 +20,7 @@ RUN apk add -U --no-cache autoconf \ imagemagick \ imagemagick-dev \ imap-dev \ + jq \ libjpeg-turbo \ libjpeg-turbo-dev \ libmemcached-dev \ diff --git a/data/Dockerfiles/phpfpm/docker-entrypoint.sh b/data/Dockerfiles/phpfpm/docker-entrypoint.sh index bf3d1025a..481e097a8 100755 --- a/data/Dockerfiles/phpfpm/docker-entrypoint.sh +++ b/data/Dockerfiles/phpfpm/docker-entrypoint.sh @@ -14,10 +14,24 @@ until [[ $(redis-cli -h redis-mailcow PING) == "PONG" ]]; do sleep 2 done +# Set a default release format + if [[ -z $(redis-cli --raw -h redis-mailcow GET Q_RELEASE_FORMAT) ]]; then redis-cli --raw -h redis-mailcow SET Q_RELEASE_FORMAT raw fi +# Check of mysql_upgrade + +CONTAINER_ID= +CONTAINER_ID=$(curl --silent --insecure https://dockerapi/containers/json | jq -r ".[] | {name: .Config.Labels[\"com.docker.compose.service\"], id: .Id}" | jq -rc "select( .name | tostring | contains(\"mysql-mailcow\")) | .id") +if [[ ! -z ${CONTAINER_ID} ]]; then + SQL_UPGRADE_RETURN=$(curl --silent --insecure -XPOST https://dockerapi/containers/${CONTAINER_ID}/exec -d '{"cmd":"system", "task":"mysql_upgrade"}' --silent -H 'Content-type: application/json' | jq -r .type) + if [[ ${SQL_UPGRADE_RETURN} == 'warning' ]]; then + echo "MySQL applied an upgrade, restarting PHP-FPM..." + exit 1 + fi +fi + # Trigger db init echo "Running DB init..." php -c /usr/local/etc/php -f /web/inc/init_db.inc.php