mariadb-is-ready 391 Bytes
#!/bin/sh
	
set -e
trap 'exit' TERM

check_mysqldb() {
	mysql --connect-timeout=1 --host="${MYSQL_HOST}" --user="${MYSQL_USER}" --password="${MYSQL_PASSWORD}" --port="${MYSQL_PORT:-3306}" -e "SELECT 'Ok' AS 'Healthy'"
}
while ! check_mysqldb; do
	echo "Waiting for database" 1>&2
	sleep 1
	count=5
	while [ $count -gt 0 ] && ! check_mysqldb; do
		count=$(($count - 1))
		sleep 1
	done
done