summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
diff options
context:
space:
mode:
authorMingli Yu <Mingli.Yu@windriver.com>2018-10-11 11:50:19 +0800
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-10-11 14:46:35 -0400
commit04b999aa9136ba90129e6679d232fd707e71f337 (patch)
tree42fd5487683316fe37b1080d2618fc6e1c5f2776 /meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
parent50c28a1eecb10db2ae649b10408f028eac4e9d03 (diff)
downloadmeta-cloud-services-04b999aa9136ba90129e6679d232fd707e71f337.tar.gz
postgresql: make append version independent
Make bbappend version independent and only effective when the openstack distro enabled. Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc')
-rw-r--r--meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc60
1 files changed, 60 insertions, 0 deletions
diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc b/meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
new file mode 100644
index 0000000..5bf25e1
--- /dev/null
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
@@ -0,0 +1,60 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3SRC_URI += " \
4 file://postgresql-init \
5 file://postgresql-init.service \
6 "
7
8inherit identity hosts
9
10SYSTEMD_AUTO_ENABLE_${PN} = "enable"
11
12# default
13DB_DATADIR ?= "/var/lib/postgres/data"
14
15do_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}/.bash_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
53PACKAGES += " ${PN}-setup"
54
55SYSTEMD_PACKAGES += "${PN}-setup"
56SYSTEMD_SERVICE_${PN}-setup = "postgresql-init.service"
57
58FILES_${PN}-setup = " \
59 ${systemd_unitdir}/system \
60"