Skip to content
Snippets Groups Projects
Commit dc286968 authored by Steven Dake's avatar Steven Dake
Browse files

Move scripts for galera to docker_templates

Change-Id: I16639642d4e8bc5074d72d2f4b7fa1ec3a8f31de
Partially-Implements: blueprint remove-docker-dir
parent 155f5a58
No related branches found
No related tags found
No related merge requests found
#!/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
#!/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
}
#!/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
../../docker/common/galera/config-external.sh
\ No newline at end of file
#!/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
../../docker/common/galera/config-galera.sh
\ No newline at end of file
#!/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
}
../../docker/common/galera/start.sh
\ No newline at end of file
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment