#!/bin/bash -e

statusFile=/tmp/mysql-status
while [[ true ]]; do
  mysql -h127.0.0.1 -uroot -pwordpress -e "SELECT 1 FROM mysql.user LIMIT 1;" &> ${statusFile} 
  if [[ $? -eq 1 ]]; then
    cat /tmp/mysql-status
    echo "MySQL not running, waiting."
    sleep 1
  else
    rm ${statusFile}
    echo "MySQL running, ready to proceed."
    break;
  fi
done