From 6cfd9681b75c6ba7c7f6a706504e2d731bea97e1 Mon Sep 17 00:00:00 2001 From: Tim Miller Date: Wed, 20 Feb 2013 21:46:27 -0800 Subject: [PATCH] Seperate install of services and start scripts: This allows openstack services to be git/pip installed without installing any startup scripts. This is useful for keystone-db or nova-db elements, for example, where the service must be installed to perform database migration, but no service start scripts need be installed. Additionally, add a tool to create openstack sql databases. Use openstack pypi mirror: Use the openstack pypi mirror for openstack service installation. It's much faster than pypi.org. Also, pip install $svc_repo/tools/pip-requires first, if it exists, which is required to pick up oslo.config. Change-Id: I72751d4da59f8597d20aea2f27a9dfabe2f63a8f --- .../openstack-db/first-boot.d/50-openstack-db | 1 + elements/os-svc-install/bin/os-db-create | 19 ++++++ elements/os-svc-install/bin/os-svc-daemon | 32 +++++++++ elements/os-svc-install/bin/os-svc-install | 60 ++++++++++++++++ .../install.d/04-os-svc-install | 7 -- elements/os-svc-install/os-svc-install | 68 ------------------- .../pre-install.d/04-os-svc-install | 9 +++ 7 files changed, 121 insertions(+), 75 deletions(-) create mode 100755 elements/os-svc-install/bin/os-db-create create mode 100755 elements/os-svc-install/bin/os-svc-daemon create mode 100755 elements/os-svc-install/bin/os-svc-install delete mode 100755 elements/os-svc-install/install.d/04-os-svc-install delete mode 100755 elements/os-svc-install/os-svc-install create mode 100755 elements/os-svc-install/pre-install.d/04-os-svc-install diff --git a/elements/openstack-db/first-boot.d/50-openstack-db b/elements/openstack-db/first-boot.d/50-openstack-db index c8ae46693..ed8585870 100755 --- a/elements/openstack-db/first-boot.d/50-openstack-db +++ b/elements/openstack-db/first-boot.d/50-openstack-db @@ -23,3 +23,4 @@ glance-manage db_sync create-os-db ovs_quantum quantum $db_pass + diff --git a/elements/os-svc-install/bin/os-db-create b/elements/os-svc-install/bin/os-db-create new file mode 100755 index 000000000..7e27d50ca --- /dev/null +++ b/elements/os-svc-install/bin/os-db-create @@ -0,0 +1,19 @@ +#!/bin/bash +set -eu + +function create_db { + local sql=" + drop database if exists $1; + create database if not exists $1; + grant all on $1.* to '$2'@'localhost' identified by '$3'; + grant all on $1.* to '$2'@'%' identified by '$3'; + flush privileges;" + echo "$sql" | mysql +} + +if [ $# -lt 3 ]; then + echo "Usage: os-db-create DB_NAME DB_USER DB_PASS" + exit 1 +fi + +create_db $* diff --git a/elements/os-svc-install/bin/os-svc-daemon b/elements/os-svc-install/bin/os-svc-daemon new file mode 100755 index 000000000..87c594610 --- /dev/null +++ b/elements/os-svc-install/bin/os-svc-daemon @@ -0,0 +1,32 @@ +#!/bin/bash +set -eu + + +function install_upstart { + local name=$1 + local user=$2 + local cmd=$3 + shift; shift; shift + local args=$* + cat > /etc/init/$name.conf < $f <