diskimage-builder/flavours/nova-vm/first-boot.d/15-mysql

45 lines
1.2 KiB
Plaintext
Raw Normal View History

2012-11-09 11:04:13 +00:00
#!/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}';
2012-11-12 18:39:25 +00:00
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '${MYSQL_NOVAPASS}';
2012-11-09 11:04:13 +00:00
CREATE DATABASE IF NOT EXISTS cinder;
2012-11-12 18:39:25 +00:00
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '${MYSQL_CINDERPASS}';
2012-11-09 11:04:13 +00:00
CREATE DATABASE IF NOT EXISTS keystone;
2012-11-12 18:39:25 +00:00
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '${MYSQL_KEYSTONEPASS}';
2012-11-09 11:04:13 +00:00
CREATE DATABASE IF NOT EXISTS glance;
2012-11-12 18:39:25 +00:00
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '${MYSQL_GLANCEPASS}';
2012-11-09 11:04:13 +00:00
FLUSH PRIVILEGES;
EOF
mysql -uroot --password=$MYSQL_ADMPASS < $sqltfile
rm -f sqltfile