summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support
diff options
context:
space:
mode:
authorAmy Fong <Amy.Fong@windriver.com>2014-03-13 13:57:39 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-03-15 00:42:00 -0400
commita21b481b00acd2169eb1a90ecb547c4752904156 (patch)
tree32e4c582c282d53d458ade1301d74d96b5b1c2f1 /meta-openstack/recipes-support
parent13b70dd07c8c2cdd799bd4b1f725157401b34068 (diff)
downloadmeta-cloud-services-a21b481b00acd2169eb1a90ecb547c4752904156.tar.gz
OpenStack: Fix postgresql file permissions
- make database directory to be configurable, defaulting to /var/lib/postgres/data - modify init scripts to create database's data directory if it doesn't exist Signed-off-by: Amy Fong <Amy.Fong@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-support')
-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
3 files changed, 23 insertions, 13 deletions
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-support/postgresql/postgresql/postgresql
index 5a34ec0..cfff759 100644
--- a/meta-openstack/recipes-support/postgresql/postgresql/postgresql
+++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql
@@ -13,14 +13,15 @@
13 13
14DAEMON=/usr/bin/postmaster 14DAEMON=/usr/bin/postmaster
15DESC="PostgreSQL RDBMS server" 15DESC="PostgreSQL RDBMS server"
16DEFAULT_DATA_DIR=%DB_DATADIR%
16 17
17datadir=`grep ^data_directory /etc/postgresql/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"` 18datadir=`grep ^data_directory $DEFAULT_DATA_DIR/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"`
18if [ "$datadir" = "" ] ; then 19if [ "$datadir" = "" ] ; then
19 datadir=/etc/postgresql 20 datadir=$DEFAULT_DATA_DIR
20else 21else
21 if [ ! -e $datadir/postgresql.conf ] ; then 22 if [ ! -e $datadir/postgresql.conf ] ; then
22 if [ -e /etc/postgresql/postgresql.conf -a -e $datadir ] ; then 23 if [ -e $DEFAULT_DATA_DIR/postgresql.conf -a -e $datadir ] ; then
23 ln -s /etc/postgresql/*.conf $datadir/ 24 ln -s $DEFAULT_DATA_DIR/*.conf $datadir/
24 fi 25 fi
25 fi 26 fi
26fi 27fi
@@ -55,9 +56,9 @@ stop ()
55 if [ $? -eq 0 ]; then 56 if [ $? -eq 0 ]; then
56 echo "done." 57 echo "done."
57 else 58 else
58 if [ -f /etc/postgresql/postmaster.pid -a "$datadir" != "/etc/postgresql" ] ; then 59 if [ -f $DEFAULT_DATA_DIR/postmaster.pid -a "$datadir" != "$DEFAULT_DATA_DIR" ] ; then
59 # Special case for transition 60 # Special case for transition
60 sudo -u postgres /usr/bin/pg_ctl stop -w -D /etc/postgresql -m fast -s 61 sudo -u postgres /usr/bin/pg_ctl stop -w -D $DEFAULT_DATA_DIR -m fast -s
61 fi 62 fi
62 if ! pidof ${DAEMON} > /dev/null; then 63 if ! pidof ${DAEMON} > /dev/null; then
63 echo "done." 64 echo "done."
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
index c9c3807..f5e7dfb 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%
6COMPUTE_IP=%COMPUTE_IP% 6COMPUTE_IP=%COMPUTE_IP%
7DB_USER=%DB_USER% 7DB_USER=%DB_USER%
8DB_PASSWORD=%DB_PASSWORD% 8DB_PASSWORD=%DB_PASSWORD%
9DATA_DIR=%DB_DATADIR%
9 10
10if [ -e /etc/${PN}/PG_VERSION ]; then 11if [ ! -e $DATA_DIR ]; then
12 mkdir -p $DATA_DIR
13 chown postgres $DATA_DIR
14fi
15
16if [ -e $DATA_DIR/PG_VERSION ]; then
11 # the database has already been initialized, return 17 # the database has already been initialized, return
12 exit 0 18 exit 0
13fi 19fi
14 20
15sudo -u postgres initdb -D /etc/${PN}/ 21sudo -u postgres initdb -D $DATA_DIR
16echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf 22echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
17echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf 23echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
18echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf 24echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
19/etc/init.d/postgresql start 25/etc/init.d/postgresql start
20 26
21count=0 27count=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 c485e2d..80bfe1e 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 \
6 6
7inherit useradd update-rc.d identity hosts 7inherit useradd update-rc.d identity hosts
8 8
9# default
10DB_DATADIR ?= "/var/lib/postgres/data"
11
9do_install_append() { 12do_install_append() {
10 install -d ${D}${sysconfdir}/${PN} 13 sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${WORKDIR}/postgresql
11 chown postgres ${D}${sysconfdir}/${PN} 14 sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${WORKDIR}/postgresql-init
12 15
13 install -d ${D}${sysconfdir}/init.d/ 16 install -d ${D}${sysconfdir}/init.d/
14 install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql 17 install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql