diff options
author | Amy Fong <Amy.Fong@windriver.com> | 2014-03-13 13:57:39 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-03-15 00:42:00 -0400 |
commit | a21b481b00acd2169eb1a90ecb547c4752904156 (patch) | |
tree | 32e4c582c282d53d458ade1301d74d96b5b1c2f1 /meta-openstack/recipes-support | |
parent | 13b70dd07c8c2cdd799bd4b1f725157401b34068 (diff) | |
download | meta-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')
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 | ||
14 | DAEMON=/usr/bin/postmaster | 14 | DAEMON=/usr/bin/postmaster |
15 | DESC="PostgreSQL RDBMS server" | 15 | DESC="PostgreSQL RDBMS server" |
16 | DEFAULT_DATA_DIR=%DB_DATADIR% | ||
16 | 17 | ||
17 | datadir=`grep ^data_directory /etc/postgresql/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"` | 18 | datadir=`grep ^data_directory $DEFAULT_DATA_DIR/postgresql.conf |sed -e "s#^.*= '##; s#'.*##"` |
18 | if [ "$datadir" = "" ] ; then | 19 | if [ "$datadir" = "" ] ; then |
19 | datadir=/etc/postgresql | 20 | datadir=$DEFAULT_DATA_DIR |
20 | else | 21 | else |
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 |
26 | fi | 27 | fi |
@@ -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% | |||
6 | COMPUTE_IP=%COMPUTE_IP% | 6 | COMPUTE_IP=%COMPUTE_IP% |
7 | DB_USER=%DB_USER% | 7 | DB_USER=%DB_USER% |
8 | DB_PASSWORD=%DB_PASSWORD% | 8 | DB_PASSWORD=%DB_PASSWORD% |
9 | DATA_DIR=%DB_DATADIR% | ||
9 | 10 | ||
10 | if [ -e /etc/${PN}/PG_VERSION ]; then | 11 | if [ ! -e $DATA_DIR ]; then |
12 | mkdir -p $DATA_DIR | ||
13 | chown postgres $DATA_DIR | ||
14 | fi | ||
15 | |||
16 | if [ -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 |
13 | fi | 19 | fi |
14 | 20 | ||
15 | sudo -u postgres initdb -D /etc/${PN}/ | 21 | sudo -u postgres initdb -D $DATA_DIR |
16 | echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf | 22 | echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf |
17 | echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf | 23 | echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf |
18 | echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf | 24 | echo "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 | ||
21 | count=0 | 27 | 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 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 | ||
7 | inherit useradd update-rc.d identity hosts | 7 | inherit useradd update-rc.d identity hosts |
8 | 8 | ||
9 | # default | ||
10 | DB_DATADIR ?= "/var/lib/postgres/data" | ||
11 | |||
9 | do_install_append() { | 12 | do_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 |