From dc2869684afbdc715dc26b9feaf25f244ba6c1e8 Mon Sep 17 00:00:00 2001 From: Steven Dake <stdake@cisco.com> Date: Thu, 27 Aug 2015 17:55:22 -0700 Subject: [PATCH] Move scripts for galera to docker_templates Change-Id: I16639642d4e8bc5074d72d2f4b7fa1ec3a8f31de Partially-Implements: blueprint remove-docker-dir --- docker/common/galera/config-external.sh | 11 ------- docker/common/galera/config-galera.sh | 37 --------------------- docker/common/galera/start.sh | 25 -------------- docker_templates/galera/config-external.sh | 12 ++++++- docker_templates/galera/config-galera.sh | 38 +++++++++++++++++++++- docker_templates/galera/start.sh | 26 ++++++++++++++- 6 files changed, 73 insertions(+), 76 deletions(-) delete mode 100644 docker/common/galera/config-external.sh delete mode 100755 docker/common/galera/config-galera.sh delete mode 100755 docker/common/galera/start.sh mode change 120000 => 100644 docker_templates/galera/config-external.sh mode change 120000 => 100755 docker_templates/galera/config-galera.sh mode change 120000 => 100755 docker_templates/galera/start.sh diff --git a/docker/common/galera/config-external.sh b/docker/common/galera/config-external.sh deleted file mode 100644 index 43447a51c..000000000 --- a/docker/common/galera/config-external.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -SOURCE="/opt/kolla/mariadb/galera.cnf" -TARGET="/etc/my.cnf.d/galera.cnf" -OWNER="mysql" - -# Cluster configuration -if [[ -f "$SOURCE" ]]; then - cp $SOURCE $TARGET - chown ${OWNER}: $TARGET - chmod 0600 $TARGET -fi diff --git a/docker/common/galera/config-galera.sh b/docker/common/galera/config-galera.sh deleted file mode 100755 index e66084001..000000000 --- a/docker/common/galera/config-galera.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -function bootstrap_db { - mysqld_safe --wsrep-new-cluster & - - # Waiting for deamon - sleep 10 - expect -c ' - set timeout 10 - spawn mysql_secure_installation - expect "Enter current password for root (enter for none):" - send "\r" - expect "Set root password?" - send "y\r" - expect "New password:" - send "'"${DB_ROOT_PASSWORD}"'\r" - expect "Re-enter new password:" - send "'"${DB_ROOT_PASSWORD}"'\r" - expect "Remove anonymous users?" - send "y\r" - expect "Disallow root login remotely?" - send "n\r" - expect "Remove test database and access to it?" - send "y\r" - expect "Reload privilege tables now?" - send "y\r" - expect eof' - - mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" - mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" - mysqladmin -p"${DB_ROOT_PASSWORD}" shutdown -} - -function populate_db { - mysql_install_db - chown -R mysql: /var/lib/mysql -} diff --git a/docker/common/galera/start.sh b/docker/common/galera/start.sh deleted file mode 100755 index f8f8d7f77..000000000 --- a/docker/common/galera/start.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -o errexit - -CMD="/usr/bin/mysqld_safe" -ARGS="" - -# loading common functions -source /opt/kolla/kolla-common.sh - -# Execute config strategy -set_configs - -# loading functions -source /opt/kolla/config/config-galera.sh - -# This catches all cases of the BOOTSTRAP variable being set, including empty -if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then - ARGS="--wsrep-new-cluster" - touch /var/lib/mysql/cluster.exists - populate_db - bootstrap_db -fi - -exec $CMD $ARGS diff --git a/docker_templates/galera/config-external.sh b/docker_templates/galera/config-external.sh deleted file mode 120000 index 7fb399006..000000000 --- a/docker_templates/galera/config-external.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/galera/config-external.sh \ No newline at end of file diff --git a/docker_templates/galera/config-external.sh b/docker_templates/galera/config-external.sh new file mode 100644 index 000000000..43447a51c --- /dev/null +++ b/docker_templates/galera/config-external.sh @@ -0,0 +1,11 @@ +#!/bin/bash +SOURCE="/opt/kolla/mariadb/galera.cnf" +TARGET="/etc/my.cnf.d/galera.cnf" +OWNER="mysql" + +# Cluster configuration +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0600 $TARGET +fi diff --git a/docker_templates/galera/config-galera.sh b/docker_templates/galera/config-galera.sh deleted file mode 120000 index 7227efbaf..000000000 --- a/docker_templates/galera/config-galera.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/galera/config-galera.sh \ No newline at end of file diff --git a/docker_templates/galera/config-galera.sh b/docker_templates/galera/config-galera.sh new file mode 100755 index 000000000..e66084001 --- /dev/null +++ b/docker_templates/galera/config-galera.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +function bootstrap_db { + mysqld_safe --wsrep-new-cluster & + + # Waiting for deamon + sleep 10 + expect -c ' + set timeout 10 + spawn mysql_secure_installation + expect "Enter current password for root (enter for none):" + send "\r" + expect "Set root password?" + send "y\r" + expect "New password:" + send "'"${DB_ROOT_PASSWORD}"'\r" + expect "Re-enter new password:" + send "'"${DB_ROOT_PASSWORD}"'\r" + expect "Remove anonymous users?" + send "y\r" + expect "Disallow root login remotely?" + send "n\r" + expect "Remove test database and access to it?" + send "y\r" + expect "Reload privilege tables now?" + send "y\r" + expect eof' + + mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" + mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" + mysqladmin -p"${DB_ROOT_PASSWORD}" shutdown +} + +function populate_db { + mysql_install_db + chown -R mysql: /var/lib/mysql +} diff --git a/docker_templates/galera/start.sh b/docker_templates/galera/start.sh deleted file mode 120000 index 0c6dbd38f..000000000 --- a/docker_templates/galera/start.sh +++ /dev/null @@ -1 +0,0 @@ -../../docker/common/galera/start.sh \ No newline at end of file diff --git a/docker_templates/galera/start.sh b/docker_templates/galera/start.sh new file mode 100755 index 000000000..f8f8d7f77 --- /dev/null +++ b/docker_templates/galera/start.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -o errexit + +CMD="/usr/bin/mysqld_safe" +ARGS="" + +# loading common functions +source /opt/kolla/kolla-common.sh + +# Execute config strategy +set_configs + +# loading functions +source /opt/kolla/config/config-galera.sh + +# This catches all cases of the BOOTSTRAP variable being set, including empty +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]] && [[ ! -e /var/lib/mysql/cluster.exists ]]; then + ARGS="--wsrep-new-cluster" + touch /var/lib/mysql/cluster.exists + populate_db + bootstrap_db +fi + +exec $CMD $ARGS -- GitLab