8 echo "Wait until $max_attempts seconds for MySQL mano Server ${db_host}:${db_port} "
9 while ! mysqladmin
ping -h"$db_host" -P"$db_port" --silent; do
11 if [ $attempt -ge $max_attempts ]; then
13 echo "Can not connect to database ${db_host}:${db_port} during $max_attempts sec"
23 function is_db_created
() {
30 RESULT
=`mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -o $db_name`
31 if [ "$RESULT" == "$db_name" ]; then
32 echo "DB $db_name exists"
35 echo "DB $db_name does not exist"
40 KEYSTONE_IP
=`ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'`
42 wait_db
"$DB_HOST" "$DB_PORT" ||
exit 1
44 is_db_created
"$DB_HOST" "$DB_PORT" "$ROOT_DB_USER" "$ROOT_DB_PASSWORD" "keystone" && DB_EXISTS
="Y"
46 if [ -z $DB_EXISTS ]; then
47 mysql
-h"$DB_HOST" -P"$DB_PORT" -u"$ROOT_DB_USER" -p"$ROOT_DB_PASSWORD" --default_character_set utf8
-e "CREATE DATABASE keystone"
48 mysql
-h"$DB_HOST" -P"$DB_PORT" -u"$ROOT_DB_USER" -p"$ROOT_DB_PASSWORD" --default_character_set utf8
-e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '$KEYSTONE_DB_PASSWORD'"
49 mysql
-h"$DB_HOST" -P"$DB_PORT" -u"$ROOT_DB_USER" -p"$ROOT_DB_PASSWORD" --default_character_set utf8
-e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '$KEYSTONE_DB_PASSWORD'"
52 # Setting Keystone database connection
53 sed -i "721s%.*%connection = mysql+pymysql://keystone:$KEYSTONE_DB_PASSWORD@$DB_HOST:$DB_PORT/keystone%" /etc
/keystone
/keystone.conf
55 # Setting Keystone tokens
56 sed -i "2934s%.*%provider = fernet%" /etc
/keystone
/keystone.conf
58 # Populate Keystone database
59 if [ -z $DB_EXISTS ]; then
60 su
-s /bin
/sh
-c "keystone-manage db_sync" keystone
63 # Initialize Fernet key repositories
64 keystone-manage fernet_setup
--keystone-user keystone
--keystone-group keystone
65 keystone-manage credential_setup
--keystone-user keystone
--keystone-group keystone
67 # Bootstrap Keystone service
68 if [ -z $DB_EXISTS ]; then
69 keystone-manage bootstrap
--bootstrap-password "$ADMIN_PASSWORD" \
70 --bootstrap-admin-url http
://"$KEYSTONE_IP":5000/v
3/ \
71 --bootstrap-internal-url http
://"$KEYSTONE_IP":5000/v
3/ \
72 --bootstrap-public-url http
://"$KEYSTONE_IP":5000/v
3/ \
73 --bootstrap-region-id RegionOne
76 # Restart Apache Service
77 service apache2 restart
80 if [ -z $DB_EXISTS ]; then
81 openstack user create
--domain default
--password "$NBI_PASSWORD" nbi
82 openstack project create
--domain defaul
--description "Service Project" service
83 openstack role add
--project service
--user nbi admin
86 while [ $
(ps
-ef |
grep -v grep |
grep apache2 |
wc -l) -ne 0 ]