aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
blob: d2dbd9119ad554cf100a989d9b2cf175360c7e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
PRINC := "${@int(PRINC) + 1}"

SRC_URI += "file://postgresql \
            file://postgresql-init"

inherit useradd update-rc.d identity hosts autotools-brokensep

# default
DB_DATADIR ?= "/var/lib/postgres/data"

do_install_append() {
    INIT_D_DEST_DIR=${D}${sysconfdir}/init.d

    install -d ${D}${sysconfdir}/init.d/
    install -m 0755 ${WORKDIR}/postgresql ${INIT_D_DEST_DIR}/postgresql
    install -m 0755 ${WORKDIR}/postgresql-init ${INIT_D_DEST_DIR}/postgresql-init

    sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${INIT_D_DEST_DIR}/postgresql
    sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${INIT_D_DEST_DIR}/postgresql-init

    sed -e "s:%DB_USER%:${DB_USER}:g" -i ${INIT_D_DEST_DIR}/postgresql-init
    sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${INIT_D_DEST_DIR}/postgresql-init

    sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${INIT_D_DEST_DIR}/postgresql-init
    sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${INIT_D_DEST_DIR}/postgresql-init

    sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${INIT_D_DEST_DIR}/postgresql-init
    sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${INIT_D_DEST_DIR}/postgresql-init
}

RDEPENDS_${PN} += "postgresql-timezone eglibc-utils update-rc.d"
USERADD_PACKAGES = "${PN}"
GROUPADD_PARAM_${PN} = "--system postgres"
USERADD_PARAM_${PN}  = "--system --home /var/lib/postgres -g postgres \
                        --no-create-home --shell /bin/false postgres"

PACKAGES += " ${PN}-setup"
ALLOW_EMPTY_${PN}-setup = "1"

pkg_postinst_${PN}-setup () {
    # postgres 9.2.4 postinst
    if [ "x$D" != "x" ]; then
        exit 1
    fi
      
    /etc/init.d/postgresql-init
    if [ $? -ne 0 ]; then
        echo "[ERROR] postgres: unable to create admin account"
        exit 1
    fi
}

FILES_${PN} += "${localstatedir}/run/${PN}"

INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_NAME = "${PN}"
INITSCRIPT_PARAMS = "defaults"