#!/bin/bash # # This is an entrypoint that runs the MySQL server in the 'master' mode. # source ${CONTAINER_SCRIPTS_PATH}/common.sh set -eu export_setting_variables [ -f ${CONTAINER_SCRIPTS_PATH}/validate-replication-variables.sh ] && source ${CONTAINER_SCRIPTS_PATH}/validate-replication-variables.sh [ -f ${CONTAINER_SCRIPTS_PATH}/validate-variables.sh ] && source ${CONTAINER_SCRIPTS_PATH}/validate-variables.sh log_volume_info $MYSQL_DATADIR # The 'server-id' for master needs to be constant export MYSQL_SERVER_ID=1 log_info "The 'master' server-id is ${MYSQL_SERVER_ID}" # Process the MySQL configuration files log_info 'Processing MySQL configuration files ...' envsubst < ${CONTAINER_SCRIPTS_PATH}/my-base.cnf.template > /etc/my.cnf.d/base.cnf envsubst < ${CONTAINER_SCRIPTS_PATH}/my-paas.cnf.template > /etc/my.cnf.d/paas.cnf envsubst < ${CONTAINER_SCRIPTS_PATH}/my-master.cnf.template > /etc/my.cnf.d/master.cnf envsubst < ${CONTAINER_SCRIPTS_PATH}/my-repl-gtid.cnf.template > /etc/my.cnf.d/repl-gtid.cnf envsubst < ${CONTAINER_SCRIPTS_PATH}/my-tuning.cnf.template > /etc/my.cnf.d/tuning.cnf if [ ! -d "$MYSQL_DATADIR/mysql" ]; then initialize_database "$@" else start_local_mysql "$@" fi log_info 'Setting passwords ...' [ -f ${CONTAINER_SCRIPTS_PATH}/passwd-change.sh ] && source ${CONTAINER_SCRIPTS_PATH}/passwd-change.sh # Setup the 'master' replication on the MySQL server mysql $mysql_flags <&1