2019-06-05 17:28:06 +00:00
|
|
|
echo "Initialising MySQL..."
|
2019-05-09 06:56:08 +00:00
|
|
|
mysql_connection_max_attempts=10
|
|
|
|
mysql_connection_attempt=0
|
|
|
|
until mysql -u root --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e 'exit'
|
|
|
|
do
|
|
|
|
mysql_connection_attempt=$(expr $mysql_connection_attempt + 1)
|
|
|
|
echo " [$mysql_connection_attempt/$mysql_connection_max_attempts] Waiting for MySQL service (this may take a while)..."
|
|
|
|
if [ $mysql_connection_attempt -eq $mysql_connection_max_attempts ]
|
|
|
|
then
|
2019-06-05 17:28:06 +00:00
|
|
|
echo "MySQL initialisation error" 1>&2
|
2019-05-09 06:56:08 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 10
|
|
|
|
done
|
|
|
|
echo "MySQL is up and running"
|
|
|
|
|
|
|
|
mysql -u root --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e 'CREATE DATABASE IF NOT EXISTS {{ OPENEDX_MYSQL_DATABASE }};'
|
2019-07-03 14:09:33 +00:00
|
|
|
mysql -u root --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e 'GRANT ALL ON {{ OPENEDX_MYSQL_DATABASE }}.* TO "{{ OPENEDX_MYSQL_USERNAME }}"@"%" IDENTIFIED BY "{{ OPENEDX_MYSQL_PASSWORD }}";'
|