[PHP-FPM] Trigger mysql_upgrade

master
andryyy 2018-12-10 13:22:25 +01:00
parent 40500ae5b9
commit 04b699a3c7
2 changed files with 15 additions and 0 deletions

View File

@ -20,6 +20,7 @@ RUN apk add -U --no-cache autoconf \
imagemagick \ imagemagick \
imagemagick-dev \ imagemagick-dev \
imap-dev \ imap-dev \
jq \
libjpeg-turbo \ libjpeg-turbo \
libjpeg-turbo-dev \ libjpeg-turbo-dev \
libmemcached-dev \ libmemcached-dev \

View File

@ -14,10 +14,24 @@ until [[ $(redis-cli -h redis-mailcow PING) == "PONG" ]]; do
sleep 2 sleep 2
done done
# Set a default release format
if [[ -z $(redis-cli --raw -h redis-mailcow GET Q_RELEASE_FORMAT) ]]; then if [[ -z $(redis-cli --raw -h redis-mailcow GET Q_RELEASE_FORMAT) ]]; then
redis-cli --raw -h redis-mailcow SET Q_RELEASE_FORMAT raw redis-cli --raw -h redis-mailcow SET Q_RELEASE_FORMAT raw
fi 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 # Trigger db init
echo "Running DB init..." echo "Running DB init..."
php -c /usr/local/etc/php -f /web/inc/init_db.inc.php php -c /usr/local/etc/php -f /web/inc/init_db.inc.php