aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-openstack-compute-deploy/classes/hosts.bbclass1
-rw-r--r--meta-openstack-controller-deploy/classes/hosts.bbclass1
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql/postgresql13
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql/postgresql-init16
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend7
5 files changed, 25 insertions, 13 deletions
diff --git a/meta-openstack-compute-deploy/classes/hosts.bbclass b/meta-openstack-compute-deploy/classes/hosts.bbclass
index 5376b029..ce96ab06 100644
--- a/meta-openstack-compute-deploy/classes/hosts.bbclass
+++ b/meta-openstack-compute-deploy/classes/hosts.bbclass
@@ -4,3 +4,4 @@ CONTROLLER_IP ?= "192.168.7.2"
CONTROLLER_HOST ?= "controller"
MY_IP ?= "${COMPUTE_IP}"
MY_HOST ?= "${COMPUTE_HOST}"
+DB_DATADIR ?= "/etc/postgresql"
diff --git a/meta-openstack-controller-deploy/classes/hosts.bbclass b/meta-openstack-controller-deploy/classes/hosts.bbclass
index 3b83aa5f..d4062b4d 100644
--- a/meta-openstack-controller-deploy/classes/hosts.bbclass
+++ b/meta-openstack-controller-deploy/classes/hosts.bbclass
@@ -5,3 +5,4 @@ CONTROLLER_IP ?= "192.168.7.2"
CONTROLLER_HOST ?= "controller"
MY_IP ?= "${CONTROLLER_IP}"
MY_HOST ?= "${CONTROLLER_HOST}"
+DB_DATADIR ?= "/etc/postgresql"
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-support/postgresql/postgresql/postgresql
index 5a34ec0e..cfff7596 100644
--- a/meta-openstack/recipes-support/postgresql/postgresql/postgresql
+++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql
@@ -13,14 +13,15 @@
DAEMON=/usr/bin/postmaster
DESC="PostgreSQL RDBMS server"
+DEFAULT_DATA_DIR=%DB_DATADIR%
-datadir=`grep ^data_directory /etc/postgresql/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"`
+datadir=`grep ^data_directory $DEFAULT_DATA_DIR/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"`
if [ "$datadir" = "" ] ; then
- datadir=/etc/postgresql
+ datadir=$DEFAULT_DATA_DIR
else
if [ ! -e $datadir/postgresql.conf ] ; then
- if [ -e /etc/postgresql/postgresql.conf -a -e $datadir ] ; then
- ln -s /etc/postgresql/*.conf $datadir/
+ if [ -e $DEFAULT_DATA_DIR/postgresql.conf -a -e $datadir ] ; then
+ ln -s $DEFAULT_DATA_DIR/*.conf $datadir/
fi
fi
fi
@@ -55,9 +56,9 @@ stop ()
if [ $? -eq 0 ]; then
echo "done."
else
- if [ -f /etc/postgresql/postmaster.pid -a "$datadir" != "/etc/postgresql" ] ; then
+ if [ -f $DEFAULT_DATA_DIR/postmaster.pid -a "$datadir" != "$DEFAULT_DATA_DIR" ] ; then
# Special case for transition
- sudo -u postgres /usr/bin/pg_ctl stop -w -D /etc/postgresql -m fast -s
+ sudo -u postgres /usr/bin/pg_ctl stop -w -D $DEFAULT_DATA_DIR -m fast -s
fi
if ! pidof ${DAEMON} > /dev/null; then
echo "done."
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
index c9c38073..f5e7dfb7 100644
--- a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
+++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
@@ -6,16 +6,22 @@ CONTROLLER_IP=%CONTROLLER_IP%
COMPUTE_IP=%COMPUTE_IP%
DB_USER=%DB_USER%
DB_PASSWORD=%DB_PASSWORD%
+DATA_DIR=%DB_DATADIR%
-if [ -e /etc/${PN}/PG_VERSION ]; then
+if [ ! -e $DATA_DIR ]; then
+ mkdir -p $DATA_DIR
+ chown postgres $DATA_DIR
+fi
+
+if [ -e $DATA_DIR/PG_VERSION ]; then
# the database has already been initialized, return
exit 0
fi
-sudo -u postgres initdb -D /etc/${PN}/
-echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf
-echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
-echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
+sudo -u postgres initdb -D $DATA_DIR
+echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
+echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
+echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
/etc/init.d/postgresql start
count=0
diff --git a/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend b/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
index c485e2d0..80bfe1ed 100644
--- a/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
+++ b/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
@@ -6,9 +6,12 @@ SRC_URI += "file://postgresql \
inherit useradd update-rc.d identity hosts
+# default
+DB_DATADIR ?= "/var/lib/postgres/data"
+
do_install_append() {
- install -d ${D}${sysconfdir}/${PN}
- chown postgres ${D}${sysconfdir}/${PN}
+ sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${WORKDIR}/postgresql
+ sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${WORKDIR}/postgresql-init
install -d ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql