aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-dangling/postgresql/postgresql_8.4.7.bbappend
blob: 98e7207c004e1eaafaa30d054dfada4c9a8b7e3e (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
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
PRINC := "${@int(PRINC) + 1}"

SRC_URI += "file://postgresql"

inherit useradd update-rc.d identity

do_install_append() {
    install -d ${D}${sysconfdir}/${PN}
    chown postgres ${D}${sysconfdir}/${PN}

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

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"

pkg_postinst_${PN} () {
    if [ "x$D" != "x" ]; then
        exit 1
    fi

    sudo -u postgres initdb -D /etc/${PN}/
    /etc/init.d/postgresql start
    sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'"
    ln -s /usr/share/zoneinfo /usr/share/postgresql/timezone
}

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

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