diskimage-builder/elements/nova-vm/first-boot.d/15-mysql
Monty Taylor 1eff4a436e Rename flavour to element.
Flavour is overloaded in openstack due to it being used by nova. Element
seems to have the same feeling of combinability without using a term already
in active use in the openstack community.

Change-Id: Ia4c028d4062a8f69c66665821c94dd4bcdf06031
2012-12-05 14:04:58 -08:00

44 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
set -e
set -o xtrace
source $(dirname $0)/defaults
#MYSQL_ADMPASS
#MYSQL_NOVAPASS
#MYSQL_GLANCEPASS
#MYSQL_KEYSTONEPASS
#MYSQL_CINDERPASS
service mysql stop || true
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables"
sqltfile=`mktemp`
cat <<EOF > $sqltfile
USE mysql;
UPDATE user SET password=PASSWORD("$MYSQL_ADMPASS") WHERE user='root';
EOF
$MYSQL_BOOTSTRAP < $sqltfile
rm -f $sqltfile
sed -i 's/^bind-address/#bind-address/' /etc/mysql/my.cnf
service mysql start
sqltfile=`mktemp`
cat <<EOF > $sqltfile
CREATE DATABASE IF NOT EXISTS nova;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '${MYSQL_NOVAPASS}';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '${MYSQL_NOVAPASS}';
CREATE DATABASE IF NOT EXISTS cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '${MYSQL_CINDERPASS}';
CREATE DATABASE IF NOT EXISTS keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '${MYSQL_KEYSTONEPASS}';
CREATE DATABASE IF NOT EXISTS glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '${MYSQL_GLANCEPASS}';
FLUSH PRIVILEGES;
EOF
mysql -uroot --password=$MYSQL_ADMPASS < $sqltfile
rm -f sqltfile