Skip to content

Commit 7d84aae

Browse files
praiskuppkubatrh
authored andcommitted
iron the s2i hooks
- postgresql-config renamed to postgresql-cfg to have consistent naming across sclorg images - the postgresql-cfg is now handled in "pre-init" phase, at the same time when the environment volumes are taken into account - postgresql-start-hook renamed to postgresql-start to avoid non-standard -hook suffix - better documentation to ensure reader when/under which condition the hooks are evaluated - the CONTAINER_SCRIPTS_PATH path has ./postgresql/ path in itself, there's no need to prefix once more the hook directory like "postgrsql-init" -- "init" is enough
1 parent 078bc08 commit 7d84aae

File tree

17 files changed

+66
-63
lines changed

17 files changed

+66
-63
lines changed

9.4/root/usr/bin/run-postgresql

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fi
2424

2525
pg_ctl -w start -o "-h ''"
2626
if $PG_INITIALIZED ; then
27-
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
27+
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
2828
migrate_db
2929
create_users
3030
fi
3131

32-
process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
32+
process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
3333

3434
pg_ctl stop
3535

9.4/root/usr/share/container-scripts/postgresql/README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
252252
The directory passed to `s2i build` should contain one or more of the
253253
following directories:
254254

255-
##### `postgresql-config/`
255+
##### `postgresql-cfg/`
256256

257-
contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
257+
Contained configuration files (`*.conf`) will be included at the end of image
258+
postgresql.conf file.
258259

259260

260261
##### `postgresql-init/`
261262

262-
contained shell scripts (`*.sh`) are sourced once, when database is initialized
263+
Contained shell scripts (`*.sh`) are sourced when the database is freshly
264+
initialized (after successful initdb run which made the data directory
265+
non-empty). At the time of sourcing these scripts, the local PostgreSQL
266+
server is running. For re-deployments scenarios with persistent data
267+
directory, the scripts are not sourced (no-op).
263268

264-
##### `postgresql-start-hook/`
265269

266-
contained shell scripts (`*.sh`) are sourced before every start
270+
##### `postgresql-start/`
271+
272+
Same sematics as `postgresql-init/`, except that these scripts are
273+
always sourced (after `postgresql-init/` scripts, if they exist).
274+
267275

268276
----------------------------------------------
269277

9.4/root/usr/share/container-scripts/postgresql/common.sh

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
125125
< "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
126126
>> "${POSTGRESQL_CONFIG_FILE}"
127127
fi
128+
129+
(
130+
shopt -s nullglob
131+
for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
132+
echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
133+
done
134+
)
128135
}
129136

130137
function generate_postgresql_recovery_config() {

9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh

-14
This file was deleted.

9.5/root/usr/bin/run-postgresql

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fi
2424

2525
pg_ctl -w start -o "-h ''"
2626
if $PG_INITIALIZED ; then
27-
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
27+
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
2828
migrate_db
2929
create_users
3030
fi
3131

32-
process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
32+
process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
3333

3434
pg_ctl stop
3535

9.5/root/usr/share/container-scripts/postgresql/README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
252252
The directory passed to `s2i build` should contain one or more of the
253253
following directories:
254254

255-
##### `postgresql-config/`
255+
##### `postgresql-cfg/`
256256

257-
contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
257+
Contained configuration files (`*.conf`) will be included at the end of image
258+
postgresql.conf file.
258259

259260

260261
##### `postgresql-init/`
261262

262-
contained shell scripts (`*.sh`) are sourced once, when database is initialized
263+
Contained shell scripts (`*.sh`) are sourced when the database is freshly
264+
initialized (after successful initdb run which made the data directory
265+
non-empty). At the time of sourcing these scripts, the local PostgreSQL
266+
server is running. For re-deployments scenarios with persistent data
267+
directory, the scripts are not sourced (no-op).
263268

264-
##### `postgresql-start-hook/`
265269

266-
contained shell scripts (`*.sh`) are sourced before every start
270+
##### `postgresql-start/`
271+
272+
Same sematics as `postgresql-init/`, except that these scripts are
273+
always sourced (after `postgresql-init/` scripts, if they exist).
274+
267275

268276
----------------------------------------------
269277

9.5/root/usr/share/container-scripts/postgresql/common.sh

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
125125
< "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
126126
>> "${POSTGRESQL_CONFIG_FILE}"
127127
fi
128+
129+
(
130+
shopt -s nullglob
131+
for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
132+
echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
133+
done
134+
)
128135
}
129136

130137
function generate_postgresql_recovery_config() {

9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh

-14
This file was deleted.

latest/root/usr/bin/run-postgresql

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fi
2424

2525
pg_ctl -w start -o "-h ''"
2626
if $PG_INITIALIZED ; then
27-
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
27+
process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
2828
migrate_db
2929
create_users
3030
fi
3131

32-
process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
32+
process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
3333

3434
pg_ctl stop
3535

latest/root/usr/share/container-scripts/postgresql/README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
252252
The directory passed to `s2i build` should contain one or more of the
253253
following directories:
254254

255-
##### `postgresql-config/`
255+
##### `postgresql-cfg/`
256256

257-
contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
257+
Contained configuration files (`*.conf`) will be included at the end of image
258+
postgresql.conf file.
258259

259260

260261
##### `postgresql-init/`
261262

262-
contained shell scripts (`*.sh`) are sourced once, when database is initialized
263+
Contained shell scripts (`*.sh`) are sourced when the database is freshly
264+
initialized (after successful initdb run which made the data directory
265+
non-empty). At the time of sourcing these scripts, the local PostgreSQL
266+
server is running. For re-deployments scenarios with persistent data
267+
directory, the scripts are not sourced (no-op).
263268

264-
##### `postgresql-start-hook/`
265269

266-
contained shell scripts (`*.sh`) are sourced before every start
270+
##### `postgresql-start/`
271+
272+
Same sematics as `postgresql-init/`, except that these scripts are
273+
always sourced (after `postgresql-init/` scripts, if they exist).
274+
267275

268276
----------------------------------------------
269277

latest/root/usr/share/container-scripts/postgresql/common.sh

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
125125
< "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
126126
>> "${POSTGRESQL_CONFIG_FILE}"
127127
fi
128+
129+
(
130+
shopt -s nullglob
131+
for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
132+
echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
133+
done
134+
)
128135
}
129136

130137
function generate_postgresql_recovery_config() {

latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh

-14
This file was deleted.

0 commit comments

Comments
 (0)