diff options
| -rw-r--r-- | meta-openstack/recipes-dbs/postgresql/postgresql/postgresql-init | 36 | ||||
| -rw-r--r-- | meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend | 5 |
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% | |||
| 8 | DB_PASSWORD=%DB_PASSWORD% | 8 | DB_PASSWORD=%DB_PASSWORD% |
| 9 | DATA_DIR=%DB_DATADIR% | 9 | DATA_DIR=%DB_DATADIR% |
| 10 | 10 | ||
| 11 | if [ ! -e $DATA_DIR ]; then | 11 | initdb(){ |
| 12 | mkdir -p $DATA_DIR | 12 | if [ ! -e $DATA_DIR ]; then |
| 13 | chown postgres $DATA_DIR | 13 | mkdir -p $DATA_DIR |
| 14 | fi | 14 | chown postgres $DATA_DIR |
| 15 | fi | ||
| 15 | 16 | ||
| 16 | if [ -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 |
| 19 | fi | 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 |
| 22 | sudo -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 | 31 | if [ "$1" == "initdb" ]; then |
| 25 | echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf | 32 | initdb |
| 26 | echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf | 33 | exit 0 |
| 27 | echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf | 34 | fi |
| 28 | systemctl restart postgresql | ||
| 29 | 35 | ||
| 30 | count=0 | 36 | count=0 |
| 31 | done=0 | 37 | done=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 | ||
| 48 | PACKAGES += " ${PN}-setup" | 53 | PACKAGES += " ${PN}-setup" |
