File: /srv/admin/scripts/mysql/mysql-check.sh
#!/bin/bash
#
# This script is executed in "/srv/admin/scripts/mysql-start.inc.sh" on every (re)start.
#
# Changes to this file will be preserved when updating the Debian package.
#
source /srv/admin/scripts/mysql/mysql-check.env.sh
source /srv/admin/scripts/mysql/debian-start.inc.sh
# If gandi.cnf does not exist, it means mysqld runs for the first time
# and mysqld_postinit was not executed yet, so no need to do following
# checks.
if [ ! -f "${MYSQL_GANDI_CNF}" ]; then
echo "Skipping mysql check"
exit 0
fi
# The following commands should be run when the server is up but in background
# where they do not block the server start and in one shell instance so that
# they run sequentially. They are supposed not to echo anything to stdout.
# If you want to disable the check for crashed tables comment
# "check_for_crashed_tables" out.
# (There may be no output to stdout inside the background process!)
echo "Checking for tables which need an upgrade, are corrupt or were "
echo "not closed cleanly."
(
upgrade_system_tables_if_necessary;
) >&2 &
exit 0