28 lines
910 B
Bash
Executable File
28 lines
910 B
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
MYSQL_INITIALIZED="/mnt/state/var/lib/mysql/galera.initialized"
|
|
|
|
pid_path=/var/run/mysqld/mysqld.pid
|
|
mkdir -p $(dirname $pid_path)
|
|
chown mysql:root $(dirname $pid_path)
|
|
|
|
if [ ! -e ${MYSQL_INITIALIZED} ]; then
|
|
if os-is-bootstrap-host; then
|
|
# Needed to setup initial tables. This command is idempotent.
|
|
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/state/var/lib/mysql --no-defaults --pid-file=$pid_path --wsrep-new-cluster
|
|
|
|
# We install this init script so we can trust this path exists
|
|
/etc/init.d/mysql bootstrap-pxc
|
|
|
|
touch ${MYSQL_INITIALIZED}
|
|
elif [ $? -eq 1 ]; then
|
|
os-svc-restart -n mysql
|
|
|
|
touch ${MYSQL_INITIALIZED}
|
|
else
|
|
echo "We are neither cluster initializer or joiner. Refusing to bootstrap mysql cluster until role is known."
|
|
exit 1
|
|
fi
|
|
fi
|