summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init36
-rw-r--r--meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend5
2 files changed, 26 insertions, 15 deletions
diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
index cc7b13e..e1f9484 100644
--- a/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init
@@ -8,24 +8,30 @@ DB_USER=%DB_USER%
8DB_PASSWORD=%DB_PASSWORD% 8DB_PASSWORD=%DB_PASSWORD%
9DATA_DIR=%DB_DATADIR% 9DATA_DIR=%DB_DATADIR%
10 10
11if [ ! -e $DATA_DIR ]; then 11initdb(){
12 mkdir -p $DATA_DIR 12 if [ ! -e $DATA_DIR ]; then
13 chown postgres $DATA_DIR 13 mkdir -p $DATA_DIR
14fi 14 chown postgres $DATA_DIR
15 fi
15 16
16if [ -e $DATA_DIR/PG_VERSION ]; then 17 if [ -e $DATA_DIR/PG_VERSION ]; then
17 # the database has already been initialized, return 18 # the database has already been initialized, return
18 exit 0 19 exit 0
19fi 20 fi
21
22 # Create the DB
23 sudo -u postgres initdb -D $DATA_DIR
20 24
21# Create the DB 25 # Allow readers/writers by IP
22sudo -u postgres initdb -D $DATA_DIR 26 echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf
27 echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
28 echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf
29 }
23 30
24# Allow readers/writers by IP 31if [ "$1" == "initdb" ]; then
25echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf 32 initdb
26echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf 33 exit 0
27echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf 34fi
28systemctl restart postgresql
29 35
30count=0 36count=0
31done=0 37done=0
diff --git a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
index 1b8a952..5bf25e1 100644
--- a/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
+++ b/meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
@@ -43,6 +43,11 @@ do_install_append() {
43 do 43 do
44 sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f 44 sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
45 done 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
46} 51}
47 52
48PACKAGES += " ${PN}-setup" 53PACKAGES += " ${PN}-setup"