diff options
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 5376b02..ce96ab0 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" | |||
| 4 | CONTROLLER_HOST ?= "controller" | 4 | CONTROLLER_HOST ?= "controller" |
| 5 | MY_IP ?= "${COMPUTE_IP}" | 5 | MY_IP ?= "${COMPUTE_IP}" |
| 6 | MY_HOST ?= "${COMPUTE_HOST}" | 6 | MY_HOST ?= "${COMPUTE_HOST}" |
| 7 | DB_DATADIR ?= "/etc/postgresql" | ||
diff --git a/meta-openstack-controller-deploy/classes/hosts.bbclass b/meta-openstack-controller-deploy/classes/hosts.bbclass index 3b83aa5..d4062b4 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" | |||
| 5 | CONTROLLER_HOST ?= "controller" | 5 | CONTROLLER_HOST ?= "controller" |
| 6 | MY_IP ?= "${CONTROLLER_IP}" | 6 | MY_IP ?= "${CONTROLLER_IP}" |
| 7 | MY_HOST ?= "${CONTROLLER_HOST}" | 7 | MY_HOST ?= "${CONTROLLER_HOST}" |
| 8 | DB_DATADIR ?= "/etc/postgresql" | ||
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 |
