Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-integ / recipes-dbs / postgresql / postgresql_openstack.inc
1 FILESEXTRAPATHS_prepend := "${THISDIR}/postgresql:"
2
3 SRC_URI += " \
4     file://postgresql-init \
5     file://postgresql-init.service \
6     "
7
8 inherit identity hosts
9
10 SYSTEMD_AUTO_ENABLE_${PN} = "enable"
11
12 # default
13 DB_DATADIR ?= "/var/lib/postgres/data"
14
15 do_install_append() {
16     D_DEST_DIR=${D}${sysconfdir}/postgresql
17
18     install -d ${D_DEST_DIR}
19     install -m 0755 ${WORKDIR}/postgresql-init ${D_DEST_DIR}/postgresql-init
20
21     sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${D_DEST_DIR}/postgresql-init
22
23     sed -e "s:%DB_USER%:${DB_USER}:g" -i ${D_DEST_DIR}/postgresql-init
24     sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${D_DEST_DIR}/postgresql-init
25
26     sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${D_DEST_DIR}/postgresql-init
27     sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
28
29     sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${D_DEST_DIR}/postgresql-init
30     sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
31
32     install -d ${D}${systemd_unitdir}/system/
33     PG_INIT_SERVICE_FILE=${D}${systemd_unitdir}/system/postgresql-init.service
34     install -m 644 ${WORKDIR}/postgresql-init.service ${PG_INIT_SERVICE_FILE}
35     sed -e "s:%SYSCONFIGDIR%:${sysconfdir}:g" -i ${PG_INIT_SERVICE_FILE}
36
37     # Update PGDATA throughout
38     files="${D}${localstatedir}/lib/${BPN}/.profile"
39     files="$files ${D}${systemd_unitdir}/system/postgresql.service"
40     files="$files ${D}${bindir}/${BPN}-setup"
41     files="$files ${D}${sysconfdir}/init.d/${BPN}-server"
42     for f in $files
43     do
44         sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
45     done
46
47     # Ensure DB is initialize before we attempt to start the service
48     FILE=${D}${systemd_unitdir}/system/postgresql.service
49     sed -e '/ExecStart=.*/i ExecStartPre=-${sysconfdir}/postgresql/postgresql-init initdb' -i $FILE
50     sed -e '/ExecStartPre=.*/i PermissionsStartOnly=true' -i $FILE
51 }
52
53 PACKAGES += " ${PN}-setup"
54
55 SYSTEMD_PACKAGES += "${PN}-setup"
56 SYSTEMD_SERVICE_${PN}-setup = "postgresql-init.service"
57
58 FILES_${PN}-setup = " \
59     ${systemd_unitdir}/system \
60 "