Created
November 25, 2016 07:44
-
-
Save jaamo/ff47781489a9f369128a069c36a8a418 to your computer and use it in GitHub Desktop.
Revisions
-
jaamo created this gist
Nov 25, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ #!/bin/bash # Simple mysqld start script for containers # We do not use mysqld_safe # Variables MYSQLD=mysqld LOG_MESSAGE="Docker startscript: " wsrep_recover_position= OPT="$@" # Do we want to check for programms? which $MYSQLD || exit 1 # Check for mysql.* schema # If it does not exists we got to create it test -d /var/lib/mysql/mysql if [ $? != 0 ]; then mysql_install_db --user=mysql if [ $? != 0 ]; then echo "${LOG_MESSAGE} Tried to install mysql.* schema because /var/lib/mysql seemed empty" echo "${LOG_MESSAGE} it failed :(" fi fi # Get the GTID possition echo "${LOG_MESSAGE} Get the GTID positon" tmpfile=$(mktemp) $MYSQLD --wsrep-recover 2>${tmpfile} if [ $? != 0 ]; then echo "${LOG_MESSAGE} An error happened while trying to '--wsrep-recover'" cat ${tmpfile} rm ${tmpfile} exit 1 fi wsrep_start_position=$(sed -n 's/.*Recovered\ position:\s*//p' ${tmpfile}) # What should we do if there is no recoverd position? # We will not start, as most likely Galera is not configured if test -z ${wsrep_start_position} then echo "${LOG_MESSAGE} We found no wsrep position!" echo "${LOG_MESSAGE} Most likely Galera is not configured, so we refuse to start" exit 1 fi # Start mysqld exec $MYSQLD $OPT --wsrep_start_position=$wsrep_start_position # We should never end in here echo "${LOG_MESSAGE} Uhh thats evil! How are you able to see this in your log?!" exit 1