diff options
Diffstat (limited to 'meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend')
| -rw-r--r-- | meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend | 46 |
1 files changed, 16 insertions, 30 deletions
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 7c28fa1..3174e94 100644 --- a/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend +++ b/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 2 | PRINC := "${@int(PRINC) + 1}" | 2 | PRINC := "${@int(PRINC) + 1}" |
| 3 | 3 | ||
| 4 | SRC_URI += "file://postgresql" | 4 | SRC_URI += "file://postgresql \ |
| 5 | file://postgresql-init" | ||
| 5 | 6 | ||
| 6 | inherit useradd update-rc.d identity hosts | 7 | inherit useradd update-rc.d identity hosts |
| 7 | 8 | ||
| @@ -11,6 +12,18 @@ do_install_append() { | |||
| 11 | 12 | ||
| 12 | install -d ${D}${sysconfdir}/init.d/ | 13 | install -d ${D}${sysconfdir}/init.d/ |
| 13 | install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql | 14 | install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql |
| 15 | |||
| 16 | sed -e "s:%DB_USER%:${DB_USER}:g" -i ${WORKDIR}/postgresql-init | ||
| 17 | sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${WORKDIR}/postgresql-init | ||
| 18 | |||
| 19 | sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${WORKDIR}/postgresql-init | ||
| 20 | sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${WORKDIR}/postgresql-init | ||
| 21 | |||
| 22 | sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${WORKDIR}/postgresql-init | ||
| 23 | sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${WORKDIR}/postgresql-init | ||
| 24 | |||
| 25 | install -m 0755 ${WORKDIR}/postgresql-init ${D}${sysconfdir}/init.d/postgresql-init | ||
| 26 | |||
| 14 | } | 27 | } |
| 15 | 28 | ||
| 16 | USERADD_PACKAGES = "${PN}" | 29 | USERADD_PACKAGES = "${PN}" |
| @@ -24,38 +37,11 @@ pkg_postinst_${PN} () { | |||
| 24 | exit 1 | 37 | exit 1 |
| 25 | fi | 38 | fi |
| 26 | 39 | ||
| 27 | sudo -u postgres initdb -D /etc/${PN}/ | 40 | /etc/init.d/postgresql-init |
| 28 | sleep 2 | 41 | if [ $? -eq 0 ]; then |
| 29 | echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf | ||
| 30 | echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf | ||
| 31 | echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf | ||
| 32 | sleep 2 | ||
| 33 | /etc/init.d/postgresql start | ||
| 34 | sleep 5 | ||
| 35 | |||
| 36 | count=0 | ||
| 37 | done=0 | ||
| 38 | while [ $count -le 10 ] && [ $done -eq 0 ]; do | ||
| 39 | sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'" 2> /dev/null | ||
| 40 | if [ $? -ne 0 ]; then | ||
| 41 | echo "[INFO] postgres: failed to create account for ${DB_USER}, trying again" | ||
| 42 | /etc/init.d/postgresql stop | ||
| 43 | sleep 2 | ||
| 44 | /etc/init.d/postgresql start | ||
| 45 | sleep 1 | ||
| 46 | else | ||
| 47 | done=1 | ||
| 48 | fi | ||
| 49 | count=`expr $count + 1` | ||
| 50 | done | ||
| 51 | |||
| 52 | if [ $done -eq 0 ]; then | ||
| 53 | echo "[ERROR] postgres: unable to create admin account" | 42 | echo "[ERROR] postgres: unable to create admin account" |
| 54 | exit 1 | 43 | exit 1 |
| 55 | fi | 44 | fi |
| 56 | |||
| 57 | ln -s /usr/share/zoneinfo /usr/share/postgresql/timezone | ||
| 58 | # end postgres 9.2.4 postinst | ||
| 59 | } | 45 | } |
| 60 | 46 | ||
| 61 | FILES_${PN} += "${localstatedir}/run/${PN}" | 47 | FILES_${PN} += "${localstatedir}/run/${PN}" |
