[PHP-FPM] Fix SQL upgrade script
parent
c77368ee70
commit
ffed14c277
|
@ -25,23 +25,26 @@ CONTAINER_ID=
|
||||||
# Todo: Better check if upgrade failed
|
# Todo: Better check if upgrade failed
|
||||||
# This can happen due to a broken sogo_view
|
# This can happen due to a broken sogo_view
|
||||||
[ -s /mysql_upgrade_loop ] && SQL_LOOP_C=$(cat /mysql_upgrade_loop)
|
[ -s /mysql_upgrade_loop ] && SQL_LOOP_C=$(cat /mysql_upgrade_loop)
|
||||||
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")
|
until [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ ^[[:alnum:]]*$ ]]; do
|
||||||
if [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ [^a-zA-Z0-9] ]]; then
|
CONTAINER_ID=$(curl --silent --insecure https://dockerapi/containers/json | jq -r ".[] | {name: .Config.Labels[\"com.docker.compose.service\"], id: .Id}" 2> /dev/null | jq -rc "select( .name | tostring | contains(\"mysql-mailcow\")) | .id" 2> /dev/null)
|
||||||
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)
|
done
|
||||||
if [[ ${SQL_UPGRADE_RETURN} == 'warning' ]]; then
|
echo "MySQL @ ${CONTAINER_ID}"
|
||||||
if [ -z ${SQL_LOOP_C} ]; 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)
|
||||||
echo 1 > /mysql_upgrade_loop
|
if [[ ${SQL_UPGRADE_RETURN} == 'warning' ]]; then
|
||||||
echo "MySQL applied an upgrade, restarting PHP-FPM..."
|
if [ -z ${SQL_LOOP_C} ]; then
|
||||||
exit 1
|
echo 1 > /mysql_upgrade_loop
|
||||||
else
|
echo "MySQL applied an upgrade, restarting PHP-FPM..."
|
||||||
rm /mysql_upgrade_loop
|
exit 1
|
||||||
echo "MySQL was not applied previously, skipping. Restart php-fpm-mailcow to retry or run mysql_upgrade manually."
|
else
|
||||||
while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do
|
rm /mysql_upgrade_loop
|
||||||
echo "Waiting for SQL to return..."
|
echo "MySQL was not applied previously, skipping. Restart php-fpm-mailcow to retry or run mysql_upgrade manually."
|
||||||
sleep 2
|
while ! mysqladmin status --socket=/var/run/mysqld/mysqld.sock -u${DBUSER} -p${DBPASS} --silent; do
|
||||||
done
|
echo "Waiting for SQL to return..."
|
||||||
fi
|
sleep 2
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "MySQL is up-to-date"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Trigger db init
|
# Trigger db init
|
||||||
|
|
Loading…
Reference in New Issue