From 0e1d445ea1d3c3b6b6784c4a4a35cbb6c8f10659 Mon Sep 17 00:00:00 2001
From: Ben Parees <bparees@redhat.com>
Date: Wed, 21 Dec 2016 11:19:00 -0500
Subject: [PATCH 001/509] deprecate v9.2

---
 .../container-scripts/postgresql/README.md    | 96 +------------------
 Makefile                                      |  2 +-
 README.md                                     | 16 ++--
 3 files changed, 8 insertions(+), 106 deletions(-)

diff --git a/9.2/root/usr/share/container-scripts/postgresql/README.md b/9.2/root/usr/share/container-scripts/postgresql/README.md
index 09f7d82c..f8f4176c 100644
--- a/9.2/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.2/root/usr/share/container-scripts/postgresql/README.md
@@ -1,98 +1,4 @@
 PostgreSQL Docker image
 =======================
 
-This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
-Users can choose between RHEL and CentOS based images.
-
-
-Environment variables and volumes
-----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-|    Variable name             |    Description                                 |
-| :--------------------------- | ---------------------------------------------- |
-|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
-|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
-|  `POSTGRESQL_DATABASE`       | Database name                                  |
-|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-|    Variable name              |    Description                                                          |    Default
-| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
-|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed. This also sets the maximum number of prepared transactions. |  100
-|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
-|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
-|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
-
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
-
-|  Volume mount point      | Description                           |
-| :----------------------- | ------------------------------------- |
-|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Usage
-----------------------
-
-For this, we will assume that you are using the `centos/postgresql-94-centos7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-94-centos7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.4/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.4/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
-
-PostgreSQL auto-tuning
---------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
+**The PostgreSQL 9.2 image is deprecated.**
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 19c001a6..21e30c01 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in hack/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.2 9.4 9.5
+VERSIONS = 9.4 9.5
 OPENSHIFT_NAMESPACES = 9.2
 
 # Include common Makefile code.
diff --git a/README.md b/README.md
index afd4a1f2..9350245d 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,6 @@ official [OpenShift Documentation](https://docs.openshift.org/latest/using_image
 Versions
 ---------------
 PostgreSQL versions currently provided are:
-* postgresql-9.2
 * postgresql-9.4
 * postgresql-9.5
 
@@ -33,7 +32,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone https://github.com/openshift/postgresql.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSION=9.4
+    $ make build TARGET=rhel7 VERSION=9.5
     ```
 
 *  **CentOS7 based image**
@@ -41,7 +40,7 @@ Choose either the CentOS7 or RHEL7 based image:
     This image is available on DockerHub. To download it run:
 
     ```
-    $ docker pull openshift/postgresql-92-centos7
+    $ docker pull centos/postgresql-95-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -49,7 +48,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone https://github.com/openshift/postgresql.git
     $ cd postgresql
-    $ make build VERSION=9.2
+    $ make build TARGET=centos7 VERSION=9.5
     ```
 
 **Notice: By omitting the `VERSION` parameter, the build/test action will be performed
@@ -59,9 +58,6 @@ on all provided versions of PostgreSQL.**
 Usage
 ---------------------------------
 
-For information about usage of Dockerfile for PostgreSQL 9.2,
-see [usage documentation](9.2/README.md).
-
 For information about usage of Dockerfile for PostgreSQL 9.4,
 see [usage documentation](9.4/README.md).
 
@@ -83,19 +79,19 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSION=9.2
+    $ make test TARGET=rhel7 VERSION=9.5
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test VERSION=9.2
+    $ make test TARGET=centos7 VERSION=9.5
     ```
 +By using the `TEST_CASE` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSION=9.2 TEST_CASE="run_general_tests run_replication_test"
+    $ make test VERSION=9.5 TEST_CASE="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSION` parameter, the build/test action will be performed

From 5545c51112d3ff426caf42bb5b68d275f0a26da7 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 6 Sep 2016 15:20:31 +0200
Subject: [PATCH 002/509] build: move common parts out from this project

Per discussion in PR #138 and some private discussion with
@omron93:  We keep the "warning" Makefile-hack to inform users who
have old clones of this repository and will do "git pull" (those
users must explicitly init the git module).
---
 .gitmodules    |   3 ++
 Makefile       |   9 +++--
 README.md      |   4 +-
 common         |   1 +
 hack/build.sh  | 103 -------------------------------------------------
 hack/common.mk |  36 -----------------
 6 files changed, 12 insertions(+), 144 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 common
 delete mode 100755 hack/build.sh
 delete mode 100644 hack/common.mk

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..aee9c814
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "common"]
+	path = common
+	url = https://github.com/sclorg/container-common-scripts.git
diff --git a/Makefile b/Makefile
index 21e30c01..4632f68f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
-# Variables are documented in hack/build.sh.
+# Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
 VERSIONS = 9.4 9.5
 OPENSHIFT_NAMESPACES = 9.2
 
-# Include common Makefile code.
-include hack/common.mk
+# HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
+# New clones should use '--recursive'.
+.PHONY: $(shell test -f common/common.mk || echo >&2 'Please do "git submodule update --init" first.')
+
+include common/common.mk
diff --git a/README.md b/README.md
index 9350245d..212a2bdf 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ Choose either the CentOS7 or RHEL7 based image:
     subscribed RHEL machine.
 
     ```
-    $ git clone https://github.com/openshift/postgresql.git
+    $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
     $ make build TARGET=rhel7 VERSION=9.5
     ```
@@ -46,7 +46,7 @@ Choose either the CentOS7 or RHEL7 based image:
     To build a PostgreSQL image from scratch run:
 
     ```
-    $ git clone https://github.com/openshift/postgresql.git
+    $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
     $ make build TARGET=centos7 VERSION=9.5
     ```
diff --git a/common b/common
new file mode 160000
index 00000000..a2ae0add
--- /dev/null
+++ b/common
@@ -0,0 +1 @@
+Subproject commit a2ae0add450912bf9a33df79cf435efb9d8da936
diff --git a/hack/build.sh b/hack/build.sh
deleted file mode 100755
index 78cb46e6..00000000
--- a/hack/build.sh
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/bash -e
-# This script is used to build, test and squash the OpenShift Docker images.
-#
-# Name of resulting image will be: 'NAMESPACE/BASE_IMAGE_NAME-VERSION-OS'.
-#
-# BASE_IMAGE_NAME - Usually name of the main component within container.
-# OS - Specifies distribution - "rhel7" or "centos7"
-# VERSION - Specifies the image version - (must match with subdirectory in repo)
-# TEST_MODE - If set, build a candidate image and test it
-# TAG_ON_SUCCESS - If set, tested image will be re-tagged as a non-candidate
-#       image, if the tests pass.
-# VERSIONS - Must be set to a list with possible versions (subdirectories)
-# OPENSHIFT_NAMESPACES - Which of available versions (subdirectories) should be
-#       put into openshift/ namespace.
-
-OS=${1-$OS}
-VERSION=${2-$VERSION}
-
-DOCKERFILE_PATH=""
-
-test -z "$BASE_IMAGE_NAME" && {
-  BASE_DIR_NAME=$(echo $(basename `pwd`) | sed -e 's/-[0-9]*$//g')
-  BASE_IMAGE_NAME="${BASE_DIR_NAME#sti-}"
-}
-
-# Cleanup the temporary Dockerfile created by docker build with version
-trap "rm -f ${DOCKERFILE_PATH}.version" SIGINT SIGQUIT EXIT
-
-# Perform docker build but append the LABEL with GIT commit id at the end
-function docker_build_with_version {
-  local dockerfile="$1"
-  # Use perl here to make this compatible with OSX
-  DOCKERFILE_PATH=$(perl -MCwd -e 'print Cwd::abs_path shift' $dockerfile)
-  cp ${DOCKERFILE_PATH} "${DOCKERFILE_PATH}.version"
-  git_version=$(git rev-parse --short HEAD)
-  echo "LABEL io.openshift.builder-version=\"${git_version}\"" >> "${dockerfile}.version"
-  if [[ "${UPDATE_BASE}" == "1" ]]; then
-    BUILD_OPTIONS+=" --pull=true"
-  fi
-  docker build ${BUILD_OPTIONS} -t ${IMAGE_NAME} -f "${dockerfile}.version" .
-  if [[ "${SKIP_SQUASH}" != "1" ]]; then
-    squash "${dockerfile}.version"
-  fi
-  rm -f "${DOCKERFILE_PATH}.version"
-}
-
-# Install the docker squashing tool[1] and squash the result image
-# [1] https://github.com/goldmann/docker-squash
-function squash {
-  # FIXME: We have to use the exact versions here to avoid Docker client
-  #        compatibility issues
-  easy_install -q --user docker_py==1.7.2 docker-squash==1.0.1
-  base=$(awk '/^FROM/{print $2}' $1)
-  ${HOME}/.local/bin/docker-squash -f $base ${IMAGE_NAME}
-}
-
-# Versions are stored in subdirectories. You can specify VERSION variable
-# to build just one single version. By default we build all versions
-dirs=${VERSION:-$VERSIONS}
-
-for dir in ${dirs}; do
-  case " $OPENSHIFT_NAMESPACES " in
-    *\ ${dir}\ *)
-      NAMESPACE="openshift/"
-      ;;
-    *)
-      if [ "${OS}" == "centos7" ]; then
-        NAMESPACE="centos/"
-      else
-        # we don't test rhel versions of SCL owned images
-        if [[ "${SKIP_RHEL_SCL}" == "1" ]]; then
-          echo "Skipping rhel scl image ${BASE_IMAGE_NAME}-${dir//./}-{$OS}"
-          continue
-        fi
-        NAMESPACE="rhscl/"
-      fi
-  esac
-
-  IMAGE_NAME="${NAMESPACE}${BASE_IMAGE_NAME}-${dir//./}-${OS}"
-
-  if [[ -v TEST_MODE ]]; then
-    IMAGE_NAME+="-candidate"
-  fi
-
-  echo "-> Building ${IMAGE_NAME} ..."
-
-  pushd ${dir} > /dev/null
-  if [ "$OS" == "rhel7" -o "$OS" == "rhel7-candidate" ]; then
-    docker_build_with_version Dockerfile.rhel7
-  else
-    docker_build_with_version Dockerfile
-  fi
-
-  if [[ -v TEST_MODE ]]; then
-    make -C ../ ${TEST_CASE:-runtests} VERSION=$dir IMAGE_NAME=${IMAGE_NAME}
-    if [[ $? -eq 0 ]] && [[ "${TAG_ON_SUCCESS}" == "true" ]]; then
-      echo "-> Re-tagging ${IMAGE_NAME} image to ${IMAGE_NAME%"-candidate"}"
-      docker tag $IMAGE_NAME ${IMAGE_NAME%"-candidate"}
-    fi
-  fi
-
-  popd > /dev/null
-done
diff --git a/hack/common.mk b/hack/common.mk
deleted file mode 100644
index 4f97328d..00000000
--- a/hack/common.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-SKIP_SQUASH?=0
-
-build = hack/build.sh
-
-ifeq ($(TARGET),rhel7)
-	OS := rhel7
-else
-	OS := centos7
-endif
-
-tests = $(shell hack/run_test --list 2>/dev/null)
-
-script_env = \
-	TEST_CASE="$(TEST_CASE)"                        \
-	SKIP_SQUASH=$(SKIP_SQUASH)                      \
-	UPDATE_BASE=$(UPDATE_BASE)                      \
-	VERSIONS="$(VERSIONS)"                          \
-	OS=$(OS)                                        \
-	VERSION="$(VERSION)"                            \
-	BASE_IMAGE_NAME=$(BASE_IMAGE_NAME)              \
-	OPENSHIFT_NAMESPACES="$(OPENSHIFT_NAMESPACES)"
-
-.PHONY: build
-build:
-	$(script_env) $(build)
-
-.PHONY: test
-test:
-	$(script_env) TAG_ON_SUCCESS=$(TAG_ON_SUCCESS) TEST_MODE=true $(build)
-
-.PHONY: runtests
-runtests: $(tests)
-
-$(tests):
-	@echo Running test: $@;
-	VERSION=$(VERSION) IMAGE_NAME=$(IMAGE_NAME) hack/run_test $@;

From 2f9f70c98ec11ca7e3b3cabde65a41e97e12d263 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 23 Feb 2017 08:37:22 +0100
Subject: [PATCH 003/509] Add help.1 file (#162)

Atomic CLI tool shows groff formatted man page if called by atomic help <img>, so all images should support it.
Currently the man page is generated outside of the build system by pandoc -s -f markdown -t man.
Include run_doc_test in the TEST_LIST rather than standalone
---
 9.2/Dockerfile       |   1 +
 9.2/Dockerfile.rhel7 |   1 +
 9.2/root/help.1      |  12 +++
 9.4/root/help.1      | 190 +++++++++++++++++++++++++++++++++++++++++++
 9.5/root/help.1      | 190 +++++++++++++++++++++++++++++++++++++++++++
 hack/run_test        |  27 +++++-
 6 files changed, 420 insertions(+), 1 deletion(-)
 create mode 100644 9.2/root/help.1
 create mode 100644 9.4/root/help.1
 create mode 100644 9.5/root/help.1

diff --git a/9.2/Dockerfile b/9.2/Dockerfile
index 609af6a0..9aa7020e 100644
--- a/9.2/Dockerfile
+++ b/9.2/Dockerfile
@@ -23,6 +23,7 @@ LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database m
 
 EXPOSE 5432
 
+ADD README.md /help.md
 ADD root /
 
 # This image must forever use UID 26 for postgres user so our volumes are
diff --git a/9.2/Dockerfile.rhel7 b/9.2/Dockerfile.rhel7
index 7b9b7bff..f274a90e 100644
--- a/9.2/Dockerfile.rhel7
+++ b/9.2/Dockerfile.rhel7
@@ -28,6 +28,7 @@ LABEL name="openshift3/postgresql-92-rhel7" \
 
 EXPOSE 5432
 
+ADD README.md /help.md
 ADD root /
 
 # This image must forever use UID 26 for postgres user so our volumes are
diff --git a/9.2/root/help.1 b/9.2/root/help.1
new file mode 100644
index 00000000..3c74aa50
--- /dev/null
+++ b/9.2/root/help.1
@@ -0,0 +1,12 @@
+.\"t
+.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
+.\"
+.\" Automatically generated by Pandoc 1.16.0.2
+.\"
+.TH "POSTGRESQL\-92\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
+.hy
+.SH PostgreSQL Docker image
+.PP
+\f[B]The PostgreSQL 9.2 image is deprecated.\f[]
+.SH AUTHORS
+Red Hat.
diff --git a/9.4/root/help.1 b/9.4/root/help.1
new file mode 100644
index 00000000..b317b6d7
--- /dev/null
+++ b/9.4/root/help.1
@@ -0,0 +1,190 @@
+.\"t
+.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
+.\"
+.\"t
+.\" Automatically generated by Pandoc 1.16.0.2
+.\"
+.TH "POSTGRESQL\-94\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
+.hy
+.SH PostgreSQL Docker image
+.PP
+This repository contains Dockerfiles for PostgreSQL images for general
+usage and OpenShift.
+Users can choose between RHEL and CentOS based images.
+.SS Environment variables and volumes
+.PP
+The image recognizes the following environment variables that you can
+set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
+Docker run command.
+.PP
+.TS
+tab(@);
+lw(26.7n) lw(43.3n).
+T{
+Variable name
+T}@T{
+Description
+T}
+_
+T{
+\f[C]POSTGRESQL_USER\f[]
+T}@T{
+User name for PostgreSQL account to be created
+T}
+T{
+\f[C]POSTGRESQL_PASSWORD\f[]
+T}@T{
+Password for the user account
+T}
+T{
+\f[C]POSTGRESQL_DATABASE\f[]
+T}@T{
+Database name
+T}
+T{
+\f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
+T}@T{
+Password for the \f[C]postgres\f[] admin account (optional)
+T}
+.TE
+.PP
+The following environment variables influence the PostgreSQL
+configuration file.
+They are all optional.
+.PP
+.TS
+tab(@);
+lw(15.7n) lw(37.6n) lw(16.7n).
+T{
+Variable name
+T}@T{
+Description
+T}@T{
+Default
+T}
+_
+T{
+\f[C]POSTGRESQL_MAX_CONNECTIONS\f[]
+T}@T{
+The maximum number of client connections allowed
+T}@T{
+100
+T}
+T{
+\f[C]POSTGRESQL_MAX_PREPARED_TRANSACTIONS\f[]
+T}@T{
+Sets the maximum number of transactions that can be in the "prepared"
+state.
+If you are using prepared transactions, you will probably want this to
+be at least as large as max_connections
+T}@T{
+0
+T}
+T{
+\f[C]POSTGRESQL_SHARED_BUFFERS\f[]
+T}@T{
+Sets how much memory is dedicated to PostgreSQL to use for caching data
+T}@T{
+32M
+T}
+T{
+\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[]
+T}@T{
+Set to an estimate of how much memory is available for disk caching by
+the operating system and within the database itself
+T}@T{
+128M
+T}
+.TE
+.PP
+You can also set the following mount points by passing the
+\f[C]\-v\ /host:/container\f[] flag to Docker.
+.PP
+.TS
+tab(@);
+l l.
+T{
+Volume mount point
+T}@T{
+Description
+T}
+_
+T{
+\f[C]/var/lib/pgsql/data\f[]
+T}@T{
+PostgreSQL database cluster directory
+T}
+.TE
+.PP
+\f[B]Notice: When mouting a directory from the host into the container,
+ensure that the mounted directory has the appropriate permissions and
+that the owner and group of the directory matches the user UID or name
+which is running inside the container.\f[]
+.SS Usage
+.PP
+For this, we will assume that you are using the
+\f[C]openshift/postgresql\-92\-centos7\f[] image.
+If you want to set only the mandatory environment variables and not
+store the database in a host directory, execute the following command:
+.IP
+.nf
+\f[C]
+$\ docker\ run\ \-d\ \-\-name\ postgresql_database\ \-e\ POSTGRESQL_USER=user\ \-e\ POSTGRESQL_PASSWORD=pass\ \-e\ POSTGRESQL_DATABASE=db\ \-p\ 5432:5432\ openshift/postgresql\-92\-centos7
+\f[]
+.fi
+.PP
+This will create a container named \f[C]postgresql_database\f[] running
+PostgreSQL with database \f[C]db\f[] and user with credentials
+\f[C]user:pass\f[].
+Port 5432 will be exposed and mapped to the host.
+If you want your database to be persistent across container executions,
+also add a \f[C]\-v\ /host/db/path:/var/lib/pgsql/data\f[] argument.
+This will be the PostgreSQL database cluster directory.
+.PP
+If the database cluster directory is not initialized, the entrypoint
+script will first run
+\f[C]initdb\f[] (http://www.postgresql.org/docs/9.2/static/app-initdb.html)
+and setup necessary database users and passwords.
+After the database is initialized, or if it was already present,
+\f[C]postgres\f[] (http://www.postgresql.org/docs/9.2/static/app-postgres.html)
+is executed and will run as PID 1.
+You can stop the detached container by running
+\f[C]docker\ stop\ postgresql_database\f[].
+.SS PostgreSQL auto\-tuning
+.PP
+When the PostgreSQL image is run with the \f[C]\-\-memory\f[] parameter
+set and if there are no values provided for
+\f[C]POSTGRESQL_SHARED_BUFFERS\f[] and
+\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[] those values are automatically
+calculated based on the value provided in the \f[C]\-\-memory\f[]
+parameter.
+.PP
+The values are calculated based on the
+upstream (https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas.
+For the \f[C]shared_buffers\f[] we use 1/4 of given memory and for the
+\f[C]effective_cache_size\f[] we set the value to 1/2 of the given
+memory.
+.SS PostgreSQL admin account
+.PP
+The admin account \f[C]postgres\f[] has no password set by default, only
+allowing local connections.
+You can set it by setting the \f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
+environment variable when initializing your container.
+This will allow you to login to the \f[C]postgres\f[] account remotely.
+Local connections will still not require a password.
+.SS Changing passwords
+.PP
+Since passwords are part of the image configuration, the only supported
+method to change passwords for the database user
+(\f[C]POSTGRESQL_USER\f[]) and \f[C]postgres\f[] admin user is by
+changing the environment variables \f[C]POSTGRESQL_PASSWORD\f[] and
+\f[C]POSTGRESQL_ADMIN_PASSWORD\f[], respectively.
+.PP
+Changing database passwords through SQL statements or any way other than
+through the environment variables aforementioned will cause a mismatch
+between the values stored in the variables and the actual passwords.
+Whenever a database container starts it will reset the passwords to the
+values stored in the environment variables.
+.SH AUTHORS
+Red Hat.
diff --git a/9.5/root/help.1 b/9.5/root/help.1
new file mode 100644
index 00000000..89c84d93
--- /dev/null
+++ b/9.5/root/help.1
@@ -0,0 +1,190 @@
+.\"t
+.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
+.\"
+.\"t
+.\" Automatically generated by Pandoc 1.16.0.2
+.\"
+.TH "POSTGRESQL\-95\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
+.hy
+.SH PostgreSQL Docker image
+.PP
+This repository contains Dockerfiles for PostgreSQL images for general
+usage and OpenShift.
+Users can choose between RHEL and CentOS based images.
+.SS Environment variables and volumes
+.PP
+The image recognizes the following environment variables that you can
+set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
+Docker run command.
+.PP
+.TS
+tab(@);
+lw(26.7n) lw(43.3n).
+T{
+Variable name
+T}@T{
+Description
+T}
+_
+T{
+\f[C]POSTGRESQL_USER\f[]
+T}@T{
+User name for PostgreSQL account to be created
+T}
+T{
+\f[C]POSTGRESQL_PASSWORD\f[]
+T}@T{
+Password for the user account
+T}
+T{
+\f[C]POSTGRESQL_DATABASE\f[]
+T}@T{
+Database name
+T}
+T{
+\f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
+T}@T{
+Password for the \f[C]postgres\f[] admin account (optional)
+T}
+.TE
+.PP
+The following environment variables influence the PostgreSQL
+configuration file.
+They are all optional.
+.PP
+.TS
+tab(@);
+lw(15.7n) lw(37.6n) lw(16.7n).
+T{
+Variable name
+T}@T{
+Description
+T}@T{
+Default
+T}
+_
+T{
+\f[C]POSTGRESQL_MAX_CONNECTIONS\f[]
+T}@T{
+The maximum number of client connections allowed
+T}@T{
+100
+T}
+T{
+\f[C]POSTGRESQL_MAX_PREPARED_TRANSACTIONS\f[]
+T}@T{
+Sets the maximum number of transactions that can be in the "prepared"
+state.
+If you are using prepared transactions, you will probably want this to
+be at least as large as max_connections
+T}@T{
+0
+T}
+T{
+\f[C]POSTGRESQL_SHARED_BUFFERS\f[]
+T}@T{
+Sets how much memory is dedicated to PostgreSQL to use for caching data
+T}@T{
+32M
+T}
+T{
+\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[]
+T}@T{
+Set to an estimate of how much memory is available for disk caching by
+the operating system and within the database itself
+T}@T{
+128M
+T}
+.TE
+.PP
+You can also set the following mount points by passing the
+\f[C]\-v\ /host:/container\f[] flag to Docker.
+.PP
+.TS
+tab(@);
+l l.
+T{
+Volume mount point
+T}@T{
+Description
+T}
+_
+T{
+\f[C]/var/lib/pgsql/data\f[]
+T}@T{
+PostgreSQL database cluster directory
+T}
+.TE
+.PP
+\f[B]Notice: When mouting a directory from the host into the container,
+ensure that the mounted directory has the appropriate permissions and
+that the owner and group of the directory matches the user UID or name
+which is running inside the container.\f[]
+.SS Usage
+.PP
+For this, we will assume that you are using the
+\f[C]openshift/postgresql\-92\-centos7\f[] image.
+If you want to set only the mandatory environment variables and not
+store the database in a host directory, execute the following command:
+.IP
+.nf
+\f[C]
+$\ docker\ run\ \-d\ \-\-name\ postgresql_database\ \-e\ POSTGRESQL_USER=user\ \-e\ POSTGRESQL_PASSWORD=pass\ \-e\ POSTGRESQL_DATABASE=db\ \-p\ 5432:5432\ openshift/postgresql\-92\-centos7
+\f[]
+.fi
+.PP
+This will create a container named \f[C]postgresql_database\f[] running
+PostgreSQL with database \f[C]db\f[] and user with credentials
+\f[C]user:pass\f[].
+Port 5432 will be exposed and mapped to the host.
+If you want your database to be persistent across container executions,
+also add a \f[C]\-v\ /host/db/path:/var/lib/pgsql/data\f[] argument.
+This will be the PostgreSQL database cluster directory.
+.PP
+If the database cluster directory is not initialized, the entrypoint
+script will first run
+\f[C]initdb\f[] (http://www.postgresql.org/docs/9.2/static/app-initdb.html)
+and setup necessary database users and passwords.
+After the database is initialized, or if it was already present,
+\f[C]postgres\f[] (http://www.postgresql.org/docs/9.2/static/app-postgres.html)
+is executed and will run as PID 1.
+You can stop the detached container by running
+\f[C]docker\ stop\ postgresql_database\f[].
+.SS PostgreSQL auto\-tuning
+.PP
+When the PostgreSQL image is run with the \f[C]\-\-memory\f[] parameter
+set and if there are no values provided for
+\f[C]POSTGRESQL_SHARED_BUFFERS\f[] and
+\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[] those values are automatically
+calculated based on the value provided in the \f[C]\-\-memory\f[]
+parameter.
+.PP
+The values are calculated based on the
+upstream (https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas.
+For the \f[C]shared_buffers\f[] we use 1/4 of given memory and for the
+\f[C]effective_cache_size\f[] we set the value to 1/2 of the given
+memory.
+.SS PostgreSQL admin account
+.PP
+The admin account \f[C]postgres\f[] has no password set by default, only
+allowing local connections.
+You can set it by setting the \f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
+environment variable when initializing your container.
+This will allow you to login to the \f[C]postgres\f[] account remotely.
+Local connections will still not require a password.
+.SS Changing passwords
+.PP
+Since passwords are part of the image configuration, the only supported
+method to change passwords for the database user
+(\f[C]POSTGRESQL_USER\f[]) and \f[C]postgres\f[] admin user is by
+changing the environment variables \f[C]POSTGRESQL_PASSWORD\f[] and
+\f[C]POSTGRESQL_ADMIN_PASSWORD\f[], respectively.
+.PP
+Changing database passwords through SQL statements or any way other than
+through the environment variables aforementioned will cause a mismatch
+between the values stored in the variables and the actual passwords.
+Whenever a database container starts it will reset the passwords to the
+values stored in the environment variables.
+.SH AUTHORS
+Red Hat.
diff --git a/hack/run_test b/hack/run_test
index 21328c60..6bbd465f 100755
--- a/hack/run_test
+++ b/hack/run_test
@@ -14,7 +14,8 @@ run_container_creation_tests
 run_general_tests
 run_change_password_test
 run_replication_test
-run_master_restart_test"
+run_master_restart_test
+run_doc_test"
 
 test $# -eq 1 -a ${1-} == --list && echo "$TEST_LIST" && exit 0
 test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
@@ -498,6 +499,30 @@ $volume_options
   echo "  Success!"
 }
 
+run_doc_test() {
+  local tmpdir=$(mktemp -d)
+  local f
+  echo "  Testing documentation in the container image"
+  # Extract the help files from the container
+  for f in /usr/share/container-scripts/postgresql/README.md help.1 ; do
+    docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
+    # Check whether the files include some important information
+    for term in POSTGRESQL_ADMIN_PASSWORD volume 5432 ; do
+      if ! cat ${tmpdir}/$(basename ${f}) | grep -q -e "${term}" ; then
+        echo "ERROR: File /${f} does not include '${term}'."
+        return 1
+      fi
+    done
+  done
+  # Check whether the files use the correct format
+  if ! file ${tmpdir}/help.1 | grep -q roff ; then
+    echo "ERROR: /help.1 is not in troff or groff format"
+    return 1
+  fi
+  echo "  Success!"
+  echo
+}
+
 function run_general_tests() {
   PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin
   PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin

From beff12a39d50e62f7d334513abb3ea03923fc1b5 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 11 Apr 2017 09:00:49 +0200
Subject: [PATCH 004/509] Get rid of warning when running the test suite
 without any arguments

---
 hack/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hack/run_test b/hack/run_test
index 6bbd465f..d857f266 100755
--- a/hack/run_test
+++ b/hack/run_test
@@ -17,7 +17,7 @@ run_replication_test
 run_master_restart_test
 run_doc_test"
 
-test $# -eq 1 -a ${1-} == --list && echo "$TEST_LIST" && exit 0
+test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
 test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 

From 482a0fad0034a4571600d29f544302d174ee378f Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 27 Apr 2017 12:18:02 +0200
Subject: [PATCH 005/509] Don't fail if $MEMORY_LIMIT_IN_BYTES is unset (#164)

This is result of failing root/usr/bin/cgroup-limits script;
which throws warnings in case of failure.

Hot-fixes: #163
---
 9.2/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 9.4/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 9.5/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/9.2/root/usr/share/container-scripts/postgresql/common.sh b/9.2/root/usr/share/container-scripts/postgresql/common.sh
index 8dbc02d2..9608bcc6 100644
--- a/9.2/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.2/root/usr/share/container-scripts/postgresql/common.sh
@@ -6,7 +6,7 @@ export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIO
 # limits are set).
 # Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
 # and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES}" ]]; then
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
     export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
 else
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index 7e909754..f107047f 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -6,7 +6,7 @@ export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIO
 # limits are set).
 # Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
 # and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES}" ]]; then
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
     export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
 else
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index 0fde554d..ca58a0bb 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -6,7 +6,7 @@ export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIO
 # limits are set).
 # Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
 # and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES}" ]]; then
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
     export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
 else

From fc3e315b31efead21217cdf511b9c5f3159face0 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 17 Mar 2017 16:31:54 +0100
Subject: [PATCH 006/509] Speedup 'docker build' from caches

Installing of RPM takes fair amount of time so we need to have it
done before 'ADD root /' statement;  so if something is changed in
'root' directory, 'docker build' doesn't have to re-download and
re-install all the packages.

There's, however, still the 'aufs' docker issue we touched in
issue #116 (docker/docker#24660) so we need to have
`fix-permissions` installed before package installation is done.
---
 9.4/Dockerfile       | 4 +++-
 9.4/Dockerfile.rhel7 | 4 +++-
 9.5/Dockerfile       | 4 +++-
 9.5/Dockerfile.rhel7 | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index 24c8e10d..c165df06 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -23,7 +23,7 @@ LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database m
 
 EXPOSE 5432
 
-ADD root /
+ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -43,6 +43,8 @@ RUN yum install -y centos-release-scl && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
+ADD root /
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index e87a4c6a..ed6c4ebb 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -28,7 +28,7 @@ LABEL name="rhscl/postgresql-94-rhel7" \
 
 EXPOSE 5432
 
-ADD root /
+ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -53,6 +53,8 @@ RUN yum install -y yum-utils gettext && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
+ADD root /
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 07ea69c5..22b375af 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -23,7 +23,7 @@ LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database m
 
 EXPOSE 5432
 
-ADD root /
+ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -43,6 +43,8 @@ RUN yum install -y centos-release-scl-rh && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
+ADD root /
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index e7c95f76..b4888395 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -28,7 +28,7 @@ LABEL name="rhscl/postgresql-95-rhel7" \
 
 EXPOSE 5432
 
-ADD root /
+ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -53,6 +53,8 @@ RUN yum install -y yum-utils gettext && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
+ADD root /
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.

From c2a7dc9b787c4f4d35d7ba77c6c78923a056f64e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 17 May 2017 12:38:55 +0200
Subject: [PATCH 007/509] tests: Only test help.1

---
 common        | 2 +-
 hack/run_test | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common b/common
index a2ae0add..6be43756 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a2ae0add450912bf9a33df79cf435efb9d8da936
+Subproject commit 6be437562875b731c8be34470ef35c9a1eecef16
diff --git a/hack/run_test b/hack/run_test
index d857f266..f0b8e1f9 100755
--- a/hack/run_test
+++ b/hack/run_test
@@ -504,11 +504,11 @@ run_doc_test() {
   local f
   echo "  Testing documentation in the container image"
   # Extract the help files from the container
-  for f in /usr/share/container-scripts/postgresql/README.md help.1 ; do
+  for f in help.1 ; do
     docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
     # Check whether the files include some important information
-    for term in POSTGRESQL_ADMIN_PASSWORD volume 5432 ; do
-      if ! cat ${tmpdir}/$(basename ${f}) | grep -q -e "${term}" ; then
+    for term in "POSTGRESQL\_ADMIN\_PASSWORD" volume 5432 ; do
+      if ! cat ${tmpdir}/$(basename ${f}) | grep -F -q -e "${term}" ; then
         echo "ERROR: File /${f} does not include '${term}'."
         return 1
       fi

From 30f6dd49d365a2d60f7e728c7cf2108d8039b3fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Skalick=C3=BD?= <MSkalicky@seznam.cz>
Date: Thu, 15 Jun 2017 14:37:05 +0200
Subject: [PATCH 008/509] Dockerfiles update (#173)

* Use COPY instruction instead of ADD

(COPY is preffered for simple usage - see https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#add-or-copy)

* Provide same labels for all base image variants (CentOS, RHEL, Fedora)
 - follow recomended labels from Project Atomic Container best practices
 - add summary and description labels (Fedora requirements) - use ENV for simple using of same value in more descriptive labels
 - remove architecture label for RHEL based images (this label is set in RHEL image - no need to define it again)

* Change summary and description to match Fedora pkgdb for Postgresql container

* Update summary to contain "PostgreSQL"

* Use label instead of MAINTAINER insctruction (deprecated)

* Fix wrong version strings (C&P errors)
---
 9.4/Dockerfile       | 22 ++++++++++++++++------
 9.4/Dockerfile.rhel7 | 22 +++++++++++++---------
 9.5/Dockerfile       | 22 ++++++++++++++++------
 9.5/Dockerfile.rhel7 | 22 +++++++++++++---------
 4 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index c165df06..195ea770 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -10,20 +10,30 @@ FROM centos:centos7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
-
 ENV POSTGRESQL_VERSION=9.4 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$SUMMARY" \
       io.k8s.display-name="PostgreSQL 9.4" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94"
+      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
+      name="centos/postgresql-94-centos7" \
+      com.redhat.component="rh-postgresql94-docker" \
+      version="9.4" \
+      release="1" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
-ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -43,7 +53,7 @@ RUN yum install -y centos-release-scl && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
-ADD root /
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index ed6c4ebb..c0b6e047 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -14,21 +14,25 @@ ENV POSTGRESQL_VERSION=9.4 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$SUMMARY" \
       io.k8s.display-name="PostgreSQL 9.4" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94"
-
-# Labels consumed by Red Hat build service
-LABEL name="rhscl/postgresql-94-rhel7" \
+      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
+      name="rhscl/postgresql-94-rhel7" \
       com.redhat.component="rh-postgresql94-docker" \
       version="9.4" \
-      release="1" \
-      architecture="x86_64"
+      release="1"
 
 EXPOSE 5432
 
-ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -53,7 +57,7 @@ RUN yum install -y yum-utils gettext && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
-ADD root /
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 22b375af..1a1fb835 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -10,20 +10,30 @@ FROM centos:centos7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
-
 ENV POSTGRESQL_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$SUMMARY" \
       io.k8s.display-name="PostgreSQL 9.5" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95"
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="centos/postgresql-95-centos7" \
+      com.redhat.component="rh-postgresql95-docker" \
+      version="9.5" \
+      release="1" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
-ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -43,7 +53,7 @@ RUN yum install -y centos-release-scl-rh && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
-ADD root /
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index b4888395..e1fbe1a5 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -14,21 +14,25 @@ ENV POSTGRESQL_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$SUMMARY" \
       io.k8s.display-name="PostgreSQL 9.5" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95"
-
-# Labels consumed by Red Hat build service
-LABEL name="rhscl/postgresql-95-rhel7" \
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="rhscl/postgresql-95-rhel7" \
       com.redhat.component="rh-postgresql95-docker" \
       version="9.5" \
-      release="1" \
-      architecture="x86_64"
+      release="1"
 
 EXPOSE 5432
 
-ADD root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
@@ -53,7 +57,7 @@ RUN yum install -y yum-utils gettext && \
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
-ADD root /
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable

From 96118054bd8a71c621602fad67ccb7dc3194ff33 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 18 Jul 2017 14:25:52 +0200
Subject: [PATCH 009/509] Use the same values for description and
 io.k8s.description

---
 9.4/Dockerfile       | 2 +-
 9.4/Dockerfile.rhel7 | 2 +-
 9.5/Dockerfile       | 2 +-
 9.5/Dockerfile.rhel7 | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index 195ea770..44a86609 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -21,7 +21,7 @@ create, run, maintain and access a PostgreSQL DBMS server."
 
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
-      io.k8s.description="$SUMMARY" \
+      io.k8s.description="$DESCRIPTION" \
       io.k8s.display-name="PostgreSQL 9.4" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index c0b6e047..25ac66e1 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -21,7 +21,7 @@ create, run, maintain and access a PostgreSQL DBMS server."
 
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
-      io.k8s.description="$SUMMARY" \
+      io.k8s.description="$DESCRIPTION" \
       io.k8s.display-name="PostgreSQL 9.4" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 1a1fb835..441191ee 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -21,7 +21,7 @@ create, run, maintain and access a PostgreSQL DBMS server."
 
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
-      io.k8s.description="$SUMMARY" \
+      io.k8s.description="$DESCRIPTION" \
       io.k8s.display-name="PostgreSQL 9.5" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index e1fbe1a5..08e43cfd 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -21,7 +21,7 @@ create, run, maintain and access a PostgreSQL DBMS server."
 
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
-      io.k8s.description="$SUMMARY" \
+      io.k8s.description="$DESCRIPTION" \
       io.k8s.display-name="PostgreSQL 9.5" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \

From 1f70bff487ecadfc0b8bca29059796fb1d709d12 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 27 Jul 2017 12:18:09 +0200
Subject: [PATCH 010/509] common: move to the latest version

- VERSION make variable is not used now
- help.1 is auto-generated (to mimic osbs behavior)
- ignore .*image-id files which are generated by build.sh
---
 .gitignore      |   2 +
 9.4/root/help.1 | 190 ------------------------------------------------
 9.5/root/help.1 | 190 ------------------------------------------------
 README.md       |  14 ++--
 common          |   2 +-
 5 files changed, 10 insertions(+), 388 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 9.4/root/help.1
 delete mode 100644 9.5/root/help.1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..3aba2f13
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.*image-id
+help.1
diff --git a/9.4/root/help.1 b/9.4/root/help.1
deleted file mode 100644
index b317b6d7..00000000
--- a/9.4/root/help.1
+++ /dev/null
@@ -1,190 +0,0 @@
-.\"t
-.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
-.\"
-.\"t
-.\" Automatically generated by Pandoc 1.16.0.2
-.\"
-.TH "POSTGRESQL\-94\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
-.hy
-.SH PostgreSQL Docker image
-.PP
-This repository contains Dockerfiles for PostgreSQL images for general
-usage and OpenShift.
-Users can choose between RHEL and CentOS based images.
-.SS Environment variables and volumes
-.PP
-The image recognizes the following environment variables that you can
-set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
-Docker run command.
-.PP
-.TS
-tab(@);
-lw(26.7n) lw(43.3n).
-T{
-Variable name
-T}@T{
-Description
-T}
-_
-T{
-\f[C]POSTGRESQL_USER\f[]
-T}@T{
-User name for PostgreSQL account to be created
-T}
-T{
-\f[C]POSTGRESQL_PASSWORD\f[]
-T}@T{
-Password for the user account
-T}
-T{
-\f[C]POSTGRESQL_DATABASE\f[]
-T}@T{
-Database name
-T}
-T{
-\f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
-T}@T{
-Password for the \f[C]postgres\f[] admin account (optional)
-T}
-.TE
-.PP
-The following environment variables influence the PostgreSQL
-configuration file.
-They are all optional.
-.PP
-.TS
-tab(@);
-lw(15.7n) lw(37.6n) lw(16.7n).
-T{
-Variable name
-T}@T{
-Description
-T}@T{
-Default
-T}
-_
-T{
-\f[C]POSTGRESQL_MAX_CONNECTIONS\f[]
-T}@T{
-The maximum number of client connections allowed
-T}@T{
-100
-T}
-T{
-\f[C]POSTGRESQL_MAX_PREPARED_TRANSACTIONS\f[]
-T}@T{
-Sets the maximum number of transactions that can be in the "prepared"
-state.
-If you are using prepared transactions, you will probably want this to
-be at least as large as max_connections
-T}@T{
-0
-T}
-T{
-\f[C]POSTGRESQL_SHARED_BUFFERS\f[]
-T}@T{
-Sets how much memory is dedicated to PostgreSQL to use for caching data
-T}@T{
-32M
-T}
-T{
-\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[]
-T}@T{
-Set to an estimate of how much memory is available for disk caching by
-the operating system and within the database itself
-T}@T{
-128M
-T}
-.TE
-.PP
-You can also set the following mount points by passing the
-\f[C]\-v\ /host:/container\f[] flag to Docker.
-.PP
-.TS
-tab(@);
-l l.
-T{
-Volume mount point
-T}@T{
-Description
-T}
-_
-T{
-\f[C]/var/lib/pgsql/data\f[]
-T}@T{
-PostgreSQL database cluster directory
-T}
-.TE
-.PP
-\f[B]Notice: When mouting a directory from the host into the container,
-ensure that the mounted directory has the appropriate permissions and
-that the owner and group of the directory matches the user UID or name
-which is running inside the container.\f[]
-.SS Usage
-.PP
-For this, we will assume that you are using the
-\f[C]openshift/postgresql\-92\-centos7\f[] image.
-If you want to set only the mandatory environment variables and not
-store the database in a host directory, execute the following command:
-.IP
-.nf
-\f[C]
-$\ docker\ run\ \-d\ \-\-name\ postgresql_database\ \-e\ POSTGRESQL_USER=user\ \-e\ POSTGRESQL_PASSWORD=pass\ \-e\ POSTGRESQL_DATABASE=db\ \-p\ 5432:5432\ openshift/postgresql\-92\-centos7
-\f[]
-.fi
-.PP
-This will create a container named \f[C]postgresql_database\f[] running
-PostgreSQL with database \f[C]db\f[] and user with credentials
-\f[C]user:pass\f[].
-Port 5432 will be exposed and mapped to the host.
-If you want your database to be persistent across container executions,
-also add a \f[C]\-v\ /host/db/path:/var/lib/pgsql/data\f[] argument.
-This will be the PostgreSQL database cluster directory.
-.PP
-If the database cluster directory is not initialized, the entrypoint
-script will first run
-\f[C]initdb\f[] (http://www.postgresql.org/docs/9.2/static/app-initdb.html)
-and setup necessary database users and passwords.
-After the database is initialized, or if it was already present,
-\f[C]postgres\f[] (http://www.postgresql.org/docs/9.2/static/app-postgres.html)
-is executed and will run as PID 1.
-You can stop the detached container by running
-\f[C]docker\ stop\ postgresql_database\f[].
-.SS PostgreSQL auto\-tuning
-.PP
-When the PostgreSQL image is run with the \f[C]\-\-memory\f[] parameter
-set and if there are no values provided for
-\f[C]POSTGRESQL_SHARED_BUFFERS\f[] and
-\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[] those values are automatically
-calculated based on the value provided in the \f[C]\-\-memory\f[]
-parameter.
-.PP
-The values are calculated based on the
-upstream (https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas.
-For the \f[C]shared_buffers\f[] we use 1/4 of given memory and for the
-\f[C]effective_cache_size\f[] we set the value to 1/2 of the given
-memory.
-.SS PostgreSQL admin account
-.PP
-The admin account \f[C]postgres\f[] has no password set by default, only
-allowing local connections.
-You can set it by setting the \f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
-environment variable when initializing your container.
-This will allow you to login to the \f[C]postgres\f[] account remotely.
-Local connections will still not require a password.
-.SS Changing passwords
-.PP
-Since passwords are part of the image configuration, the only supported
-method to change passwords for the database user
-(\f[C]POSTGRESQL_USER\f[]) and \f[C]postgres\f[] admin user is by
-changing the environment variables \f[C]POSTGRESQL_PASSWORD\f[] and
-\f[C]POSTGRESQL_ADMIN_PASSWORD\f[], respectively.
-.PP
-Changing database passwords through SQL statements or any way other than
-through the environment variables aforementioned will cause a mismatch
-between the values stored in the variables and the actual passwords.
-Whenever a database container starts it will reset the passwords to the
-values stored in the environment variables.
-.SH AUTHORS
-Red Hat.
diff --git a/9.5/root/help.1 b/9.5/root/help.1
deleted file mode 100644
index 89c84d93..00000000
--- a/9.5/root/help.1
+++ /dev/null
@@ -1,190 +0,0 @@
-.\"t
-.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
-.\"
-.\"t
-.\" Automatically generated by Pandoc 1.16.0.2
-.\"
-.TH "POSTGRESQL\-95\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
-.hy
-.SH PostgreSQL Docker image
-.PP
-This repository contains Dockerfiles for PostgreSQL images for general
-usage and OpenShift.
-Users can choose between RHEL and CentOS based images.
-.SS Environment variables and volumes
-.PP
-The image recognizes the following environment variables that you can
-set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
-Docker run command.
-.PP
-.TS
-tab(@);
-lw(26.7n) lw(43.3n).
-T{
-Variable name
-T}@T{
-Description
-T}
-_
-T{
-\f[C]POSTGRESQL_USER\f[]
-T}@T{
-User name for PostgreSQL account to be created
-T}
-T{
-\f[C]POSTGRESQL_PASSWORD\f[]
-T}@T{
-Password for the user account
-T}
-T{
-\f[C]POSTGRESQL_DATABASE\f[]
-T}@T{
-Database name
-T}
-T{
-\f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
-T}@T{
-Password for the \f[C]postgres\f[] admin account (optional)
-T}
-.TE
-.PP
-The following environment variables influence the PostgreSQL
-configuration file.
-They are all optional.
-.PP
-.TS
-tab(@);
-lw(15.7n) lw(37.6n) lw(16.7n).
-T{
-Variable name
-T}@T{
-Description
-T}@T{
-Default
-T}
-_
-T{
-\f[C]POSTGRESQL_MAX_CONNECTIONS\f[]
-T}@T{
-The maximum number of client connections allowed
-T}@T{
-100
-T}
-T{
-\f[C]POSTGRESQL_MAX_PREPARED_TRANSACTIONS\f[]
-T}@T{
-Sets the maximum number of transactions that can be in the "prepared"
-state.
-If you are using prepared transactions, you will probably want this to
-be at least as large as max_connections
-T}@T{
-0
-T}
-T{
-\f[C]POSTGRESQL_SHARED_BUFFERS\f[]
-T}@T{
-Sets how much memory is dedicated to PostgreSQL to use for caching data
-T}@T{
-32M
-T}
-T{
-\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[]
-T}@T{
-Set to an estimate of how much memory is available for disk caching by
-the operating system and within the database itself
-T}@T{
-128M
-T}
-.TE
-.PP
-You can also set the following mount points by passing the
-\f[C]\-v\ /host:/container\f[] flag to Docker.
-.PP
-.TS
-tab(@);
-l l.
-T{
-Volume mount point
-T}@T{
-Description
-T}
-_
-T{
-\f[C]/var/lib/pgsql/data\f[]
-T}@T{
-PostgreSQL database cluster directory
-T}
-.TE
-.PP
-\f[B]Notice: When mouting a directory from the host into the container,
-ensure that the mounted directory has the appropriate permissions and
-that the owner and group of the directory matches the user UID or name
-which is running inside the container.\f[]
-.SS Usage
-.PP
-For this, we will assume that you are using the
-\f[C]openshift/postgresql\-92\-centos7\f[] image.
-If you want to set only the mandatory environment variables and not
-store the database in a host directory, execute the following command:
-.IP
-.nf
-\f[C]
-$\ docker\ run\ \-d\ \-\-name\ postgresql_database\ \-e\ POSTGRESQL_USER=user\ \-e\ POSTGRESQL_PASSWORD=pass\ \-e\ POSTGRESQL_DATABASE=db\ \-p\ 5432:5432\ openshift/postgresql\-92\-centos7
-\f[]
-.fi
-.PP
-This will create a container named \f[C]postgresql_database\f[] running
-PostgreSQL with database \f[C]db\f[] and user with credentials
-\f[C]user:pass\f[].
-Port 5432 will be exposed and mapped to the host.
-If you want your database to be persistent across container executions,
-also add a \f[C]\-v\ /host/db/path:/var/lib/pgsql/data\f[] argument.
-This will be the PostgreSQL database cluster directory.
-.PP
-If the database cluster directory is not initialized, the entrypoint
-script will first run
-\f[C]initdb\f[] (http://www.postgresql.org/docs/9.2/static/app-initdb.html)
-and setup necessary database users and passwords.
-After the database is initialized, or if it was already present,
-\f[C]postgres\f[] (http://www.postgresql.org/docs/9.2/static/app-postgres.html)
-is executed and will run as PID 1.
-You can stop the detached container by running
-\f[C]docker\ stop\ postgresql_database\f[].
-.SS PostgreSQL auto\-tuning
-.PP
-When the PostgreSQL image is run with the \f[C]\-\-memory\f[] parameter
-set and if there are no values provided for
-\f[C]POSTGRESQL_SHARED_BUFFERS\f[] and
-\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[] those values are automatically
-calculated based on the value provided in the \f[C]\-\-memory\f[]
-parameter.
-.PP
-The values are calculated based on the
-upstream (https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas.
-For the \f[C]shared_buffers\f[] we use 1/4 of given memory and for the
-\f[C]effective_cache_size\f[] we set the value to 1/2 of the given
-memory.
-.SS PostgreSQL admin account
-.PP
-The admin account \f[C]postgres\f[] has no password set by default, only
-allowing local connections.
-You can set it by setting the \f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
-environment variable when initializing your container.
-This will allow you to login to the \f[C]postgres\f[] account remotely.
-Local connections will still not require a password.
-.SS Changing passwords
-.PP
-Since passwords are part of the image configuration, the only supported
-method to change passwords for the database user
-(\f[C]POSTGRESQL_USER\f[]) and \f[C]postgres\f[] admin user is by
-changing the environment variables \f[C]POSTGRESQL_PASSWORD\f[] and
-\f[C]POSTGRESQL_ADMIN_PASSWORD\f[], respectively.
-.PP
-Changing database passwords through SQL statements or any way other than
-through the environment variables aforementioned will cause a mismatch
-between the values stored in the variables and the actual passwords.
-Whenever a database container starts it will reset the passwords to the
-values stored in the environment variables.
-.SH AUTHORS
-Red Hat.
diff --git a/README.md b/README.md
index 212a2bdf..891750d7 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSION=9.5
+    $ make build TARGET=rhel7 VERSIONS=9.5
     ```
 
 *  **CentOS7 based image**
@@ -48,10 +48,10 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSION=9.5
+    $ make build TARGET=centos7 VERSIONS=9.5
     ```
 
-**Notice: By omitting the `VERSION` parameter, the build/test action will be performed
+**Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
 on all provided versions of PostgreSQL.**
 
 
@@ -79,20 +79,20 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSION=9.5
+    $ make test TARGET=rhel7 VERSIONS=9.5
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSION=9.5
+    $ make test TARGET=centos7 VERSIONS=9.5
     ```
 +By using the `TEST_CASE` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSION=9.5 TEST_CASE="run_general_tests run_replication_test"
+    $ make test VERSIONS=9.5 TEST_CASE="run_general_tests run_replication_test"
 
 
-**Notice: By omitting the `VERSION` parameter, the build/test action will be performed
+**Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
 on all provided versions of PostgreSQL.**
diff --git a/common b/common
index 6be43756..bc6fca59 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 6be437562875b731c8be34470ef35c9a1eecef16
+Subproject commit bc6fca590c2bdeb2641fca65021a249196211289

From b6482b97d244833df3d698af00832a6ab9305dd8 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 27 Jul 2017 12:37:35 +0200
Subject: [PATCH 011/509] Comply with sclorg/container-common-scripts#4 (1.
 step)

Move '9.2' into 'latest' to keep the whole commit history.
---
 {9.2 => latest}/Dockerfile                                        | 0
 {9.2 => latest}/Dockerfile.rhel7                                  | 0
 {9.2 => latest}/README.md                                         | 0
 {9.2 => latest}/cccp.yml                                          | 0
 {9.2 => latest}/root/help.1                                       | 0
 {9.2 => latest}/root/usr/bin/cgroup-limits                        | 0
 {9.2 => latest}/root/usr/bin/container-entrypoint                 | 0
 {9.2 => latest}/root/usr/bin/run-postgresql                       | 0
 {9.2 => latest}/root/usr/bin/run-postgresql-master                | 0
 {9.2 => latest}/root/usr/bin/run-postgresql-slave                 | 0
 {9.2 => latest}/root/usr/libexec/fix-permissions                  | 0
 .../root/usr/share/container-scripts/postgresql/README.md         | 0
 .../root/usr/share/container-scripts/postgresql/common.sh         | 0
 .../openshift-custom-postgresql-replication.conf.template         | 0
 .../postgresql/openshift-custom-postgresql.conf.template          | 0
 .../postgresql/openshift-custom-recovery.conf.template            | 0
 .../root/usr/share/container-scripts/postgresql/scl_enable        | 0
 {9.2 => latest}/test/run                                          | 0
 18 files changed, 0 insertions(+), 0 deletions(-)
 rename {9.2 => latest}/Dockerfile (100%)
 rename {9.2 => latest}/Dockerfile.rhel7 (100%)
 rename {9.2 => latest}/README.md (100%)
 rename {9.2 => latest}/cccp.yml (100%)
 rename {9.2 => latest}/root/help.1 (100%)
 rename {9.2 => latest}/root/usr/bin/cgroup-limits (100%)
 rename {9.2 => latest}/root/usr/bin/container-entrypoint (100%)
 rename {9.2 => latest}/root/usr/bin/run-postgresql (100%)
 rename {9.2 => latest}/root/usr/bin/run-postgresql-master (100%)
 rename {9.2 => latest}/root/usr/bin/run-postgresql-slave (100%)
 rename {9.2 => latest}/root/usr/libexec/fix-permissions (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/README.md (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/common.sh (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template (100%)
 rename {9.2 => latest}/root/usr/share/container-scripts/postgresql/scl_enable (100%)
 rename {9.2 => latest}/test/run (100%)

diff --git a/9.2/Dockerfile b/latest/Dockerfile
similarity index 100%
rename from 9.2/Dockerfile
rename to latest/Dockerfile
diff --git a/9.2/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
similarity index 100%
rename from 9.2/Dockerfile.rhel7
rename to latest/Dockerfile.rhel7
diff --git a/9.2/README.md b/latest/README.md
similarity index 100%
rename from 9.2/README.md
rename to latest/README.md
diff --git a/9.2/cccp.yml b/latest/cccp.yml
similarity index 100%
rename from 9.2/cccp.yml
rename to latest/cccp.yml
diff --git a/9.2/root/help.1 b/latest/root/help.1
similarity index 100%
rename from 9.2/root/help.1
rename to latest/root/help.1
diff --git a/9.2/root/usr/bin/cgroup-limits b/latest/root/usr/bin/cgroup-limits
similarity index 100%
rename from 9.2/root/usr/bin/cgroup-limits
rename to latest/root/usr/bin/cgroup-limits
diff --git a/9.2/root/usr/bin/container-entrypoint b/latest/root/usr/bin/container-entrypoint
similarity index 100%
rename from 9.2/root/usr/bin/container-entrypoint
rename to latest/root/usr/bin/container-entrypoint
diff --git a/9.2/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
similarity index 100%
rename from 9.2/root/usr/bin/run-postgresql
rename to latest/root/usr/bin/run-postgresql
diff --git a/9.2/root/usr/bin/run-postgresql-master b/latest/root/usr/bin/run-postgresql-master
similarity index 100%
rename from 9.2/root/usr/bin/run-postgresql-master
rename to latest/root/usr/bin/run-postgresql-master
diff --git a/9.2/root/usr/bin/run-postgresql-slave b/latest/root/usr/bin/run-postgresql-slave
similarity index 100%
rename from 9.2/root/usr/bin/run-postgresql-slave
rename to latest/root/usr/bin/run-postgresql-slave
diff --git a/9.2/root/usr/libexec/fix-permissions b/latest/root/usr/libexec/fix-permissions
similarity index 100%
rename from 9.2/root/usr/libexec/fix-permissions
rename to latest/root/usr/libexec/fix-permissions
diff --git a/9.2/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/README.md
rename to latest/root/usr/share/container-scripts/postgresql/README.md
diff --git a/9.2/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/common.sh
rename to latest/root/usr/share/container-scripts/postgresql/common.sh
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
rename to latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
rename to latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
rename to latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
diff --git a/9.2/root/usr/share/container-scripts/postgresql/scl_enable b/latest/root/usr/share/container-scripts/postgresql/scl_enable
similarity index 100%
rename from 9.2/root/usr/share/container-scripts/postgresql/scl_enable
rename to latest/root/usr/share/container-scripts/postgresql/scl_enable
diff --git a/9.2/test/run b/latest/test/run
similarity index 100%
rename from 9.2/test/run
rename to latest/test/run

From 078752e7aaefc54956bce8e5c06d52bfe565091f Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 27 Jul 2017 12:39:46 +0200
Subject: [PATCH 012/509] Comply with sclorg/container-common-scripts#4 (2.
 step)

Copy 'latest' into '9.2'.  We sacrifice git history of 9.2 to have
better history in latest.
---
 9.2/Dockerfile                                |  60 +++++
 9.2/Dockerfile.rhel7                          |  66 ++++++
 9.2/README.md                                 |   1 +
 9.2/cccp.yml                                  |   1 +
 9.2/root/help.1                               |  12 +
 9.2/root/usr/bin/cgroup-limits                |  92 ++++++++
 9.2/root/usr/bin/container-entrypoint         |   3 +
 9.2/root/usr/bin/run-postgresql               |  28 +++
 9.2/root/usr/bin/run-postgresql-master        |   5 +
 9.2/root/usr/bin/run-postgresql-slave         |  36 +++
 9.2/root/usr/libexec/fix-permissions          |   7 +
 .../container-scripts/postgresql/README.md    |   4 +
 .../container-scripts/postgresql/common.sh    | 220 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 ++
 .../openshift-custom-recovery.conf.template   |   9 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 9.2/test/run                                  |   1 +
 18 files changed, 576 insertions(+)
 create mode 100644 9.2/Dockerfile
 create mode 100644 9.2/Dockerfile.rhel7
 create mode 120000 9.2/README.md
 create mode 100644 9.2/cccp.yml
 create mode 100644 9.2/root/help.1
 create mode 100755 9.2/root/usr/bin/cgroup-limits
 create mode 100755 9.2/root/usr/bin/container-entrypoint
 create mode 100755 9.2/root/usr/bin/run-postgresql
 create mode 100755 9.2/root/usr/bin/run-postgresql-master
 create mode 100755 9.2/root/usr/bin/run-postgresql-slave
 create mode 100755 9.2/root/usr/libexec/fix-permissions
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 9.2/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 120000 9.2/test/run

diff --git a/9.2/Dockerfile b/9.2/Dockerfile
new file mode 100644
index 00000000..9aa7020e
--- /dev/null
+++ b/9.2/Dockerfile
@@ -0,0 +1,60 @@
+FROM centos:centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
+
+ENV POSTGRESQL_VERSION=9.2 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+      io.k8s.display-name="PostgreSQL 9.2" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql92"
+
+EXPOSE 5432
+
+ADD README.md /help.md
+ADD root /
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl && \
+    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=postgresql92
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/9.2/Dockerfile.rhel7 b/9.2/Dockerfile.rhel7
new file mode 100644
index 00000000..f274a90e
--- /dev/null
+++ b/9.2/Dockerfile.rhel7
@@ -0,0 +1,66 @@
+FROM rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=9.2 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
+      io.k8s.display-name="PostgreSQL 9.2" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql92"
+
+# Labels consumed by Red Hat build service
+LABEL name="openshift3/postgresql-92-rhel7" \
+      com.redhat.component="openshift-postgresql-docker" \
+      version="9.2" \
+      release="1" \
+      architecture="x86_64"
+
+EXPOSE 5432
+
+ADD README.md /help.md
+ADD root /
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y yum-utils && \
+    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-7-server-optional-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
+    yum install -y --disablerepo="epel" --setopt=tsflags=nodocs $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=postgresql92
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/9.2/README.md b/9.2/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/9.2/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.2/cccp.yml b/9.2/cccp.yml
new file mode 100644
index 00000000..96f9f25c
--- /dev/null
+++ b/9.2/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-92-centos7
diff --git a/9.2/root/help.1 b/9.2/root/help.1
new file mode 100644
index 00000000..3c74aa50
--- /dev/null
+++ b/9.2/root/help.1
@@ -0,0 +1,12 @@
+.\"t
+.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
+.\"
+.\" Automatically generated by Pandoc 1.16.0.2
+.\"
+.TH "POSTGRESQL\-92\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
+.hy
+.SH PostgreSQL Docker image
+.PP
+\f[B]The PostgreSQL 9.2 image is deprecated.\f[]
+.SH AUTHORS
+Red Hat.
diff --git a/9.2/root/usr/bin/cgroup-limits b/9.2/root/usr/bin/cgroup-limits
new file mode 100755
index 00000000..b9d4edc2
--- /dev/null
+++ b/9.2/root/usr/bin/cgroup-limits
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+"""
+Script for parsing cgroup information
+
+This script will read some limits from the cgroup system and parse
+them, printing out "VARIABLE=VALUE" on each line for every limit that is
+successfully read. Output of this script can be directly fed into
+bash's export command. Recommended usage from a bash script:
+
+    set -o errexit
+    export_vars=$(cgroup-limits) ; export $export_vars
+
+Variables currently supported:
+    MAX_MEMORY_LIMIT_IN_BYTES
+        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
+        currently constant value of 9223372036854775807.
+    MEMORY_LIMIT_IN_BYTES
+        Maximum amount of user memory in bytes. If this value is set
+        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
+        there is no limit set. The value is taken from
+        /sys/fs/cgroup/memory/memory.limit_in_bytes
+    NUMBER_OF_CORES
+        Number of detected CPU cores that can be used. This value is
+        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
+    NO_MEMORY_LIMIT
+        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
+        can act as if no memory limit was set. Undefined otherwise.
+"""
+
+from __future__ import print_function
+import sys
+
+
+def _read_file(path):
+    try:
+        with open(path, 'r') as f:
+            return f.read().strip()
+    except IOError:
+        return None
+
+
+def get_memory_limit():
+    """
+    Read memory limit, in bytes.
+    """
+
+    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
+    if limit is None or not limit.isdigit():
+        print("Warning: Can't detect memory limit from cgroups",
+              file=sys.stderr)
+        return None
+    return int(limit)
+
+
+def get_number_of_cores():
+    """
+    Read number of CPU cores.
+    """
+
+    core_count = 0
+
+    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
+    if line is None:
+        print("Warning: Can't detect number of CPU cores from cgroups",
+              file=sys.stderr)
+        return None
+
+    for group in line.split(','):
+        core_ids = list(map(int, group.split('-')))
+        if len(core_ids) == 2:
+            core_count += core_ids[1] - core_ids[0] + 1
+        else:
+            core_count += 1
+
+    return core_count
+
+
+if __name__ == "__main__":
+    env_vars = {
+        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
+        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
+        "NUMBER_OF_CORES": get_number_of_cores()
+    }
+
+    env_vars = {k: v for k, v in env_vars.items() if v is not None}
+
+    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
+        env_vars["NO_MEMORY_LIMIT"] = "true"
+
+    for key, value in env_vars.items():
+        print("{0}={1}".format(key, value))
diff --git a/9.2/root/usr/bin/container-entrypoint b/9.2/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/9.2/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/9.2/root/usr/bin/run-postgresql b/9.2/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..1c8de780
--- /dev/null
+++ b/9.2/root/usr/bin/run-postgresql
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  NEED_TO_CREATE_USERS=yes
+fi
+
+pg_ctl -w start -o "-h ''"
+if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
+  create_users
+fi
+set_passwords
+pg_ctl stop
+
+unset_env_vars
+exec postgres "$@"
diff --git a/9.2/root/usr/bin/run-postgresql-master b/9.2/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/9.2/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/9.2/root/usr/bin/run-postgresql-slave b/9.2/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..5d42d0d4
--- /dev/null
+++ b/9.2/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/recovery.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+exec postgres "$@"
diff --git a/9.2/root/usr/libexec/fix-permissions b/9.2/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..ebcdd3d4
--- /dev/null
+++ b/9.2/root/usr/libexec/fix-permissions
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Fix permissions on the given directory to allow group read/write of 
+# regular files and execute of directories.
+find "$1" -exec chown postgres {} \;
+find "$1" -exec chgrp 0 {} \;
+find "$1" -exec chmod g+rw {} \;
+find "$1" -type d -exec chmod g+x {} +
diff --git a/9.2/root/usr/share/container-scripts/postgresql/README.md b/9.2/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..f8f4176c
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,4 @@
+PostgreSQL Docker image
+=======================
+
+**The PostgreSQL 9.2 image is deprecated.**
\ No newline at end of file
diff --git a/9.2/root/usr/share/container-scripts/postgresql/common.sh b/9.2/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..9608bcc6
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,220 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
+psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+You must either specify the following environment variables:
+  POSTGRESQL_USER (regex: '$psql_identifier_regex')
+  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
+  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
+Or both.
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/openshift/postgresql.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
+    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
+    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  case ",$postinitdb_actions," in
+    *,admin_pass,*|*,simple_db,*) ;;
+    *) usage ;;
+  esac
+
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v ^postgres /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+function initialize_database() {
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/9.2/static/locale.html
+  LANG=${LANG:-en_US.utf8} initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+function set_passwords() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+  fi
+}
+
+function set_pgdata ()
+{
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    mkdir -p "${HOME}/data/userdata"
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  else 
+    # create a subdirectory that the user owns
+    mkdir -p "${HOME}/data/userdata"
+  fi
+  export PGDATA=$HOME/data/userdata
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..26d56693
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,9 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+standby_mode = on
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.2/root/usr/share/container-scripts/postgresql/scl_enable b/9.2/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/9.2/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.2/test/run b/9.2/test/run
new file mode 120000
index 00000000..6901150b
--- /dev/null
+++ b/9.2/test/run
@@ -0,0 +1 @@
+../../hack/run_test
\ No newline at end of file

From 6ebd08b40ff49ef3b02c52431ca6179226703b47 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 27 Jul 2017 12:44:35 +0200
Subject: [PATCH 013/509] Comply with sclorg/container-common-scripts#4 (3.
 step)

Copy related changes from 9.5 into latest, and replace the whole 9.5 with
symlink to latest.
---
 9.5                                           |   1 +
 9.5/Dockerfile                                |  70 ------
 9.5/Dockerfile.rhel7                          |  74 ------
 9.5/README.md                                 |   1 -
 9.5/cccp.yml                                  |   1 -
 9.5/root/usr/bin/cgroup-limits                |  92 --------
 9.5/root/usr/bin/container-entrypoint         |   3 -
 9.5/root/usr/bin/run-postgresql               |  28 ---
 9.5/root/usr/bin/run-postgresql-master        |   5 -
 9.5/root/usr/bin/run-postgresql-slave         |  36 ---
 9.5/root/usr/libexec/fix-permissions          |   7 -
 .../container-scripts/postgresql/README.md    |  98 --------
 .../container-scripts/postgresql/common.sh    | 220 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 --
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 9.5/test/run                                  |   1 -
 latest/Dockerfile                             |  34 ++-
 latest/Dockerfile.rhel7                       |  42 ++--
 latest/cccp.yml                               |   2 +-
 latest/root/help.1                            |  12 -
 .../container-scripts/postgresql/README.md    |  96 +++++++-
 .../container-scripts/postgresql/common.sh    |   2 +-
 24 files changed, 145 insertions(+), 720 deletions(-)
 create mode 120000 9.5
 delete mode 100644 9.5/Dockerfile
 delete mode 100644 9.5/Dockerfile.rhel7
 delete mode 120000 9.5/README.md
 delete mode 100644 9.5/cccp.yml
 delete mode 100755 9.5/root/usr/bin/cgroup-limits
 delete mode 100755 9.5/root/usr/bin/container-entrypoint
 delete mode 100755 9.5/root/usr/bin/run-postgresql
 delete mode 100755 9.5/root/usr/bin/run-postgresql-master
 delete mode 100755 9.5/root/usr/bin/run-postgresql-slave
 delete mode 100755 9.5/root/usr/libexec/fix-permissions
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 120000 9.5/test/run
 delete mode 100644 latest/root/help.1

diff --git a/9.5 b/9.5
new file mode 120000
index 00000000..b9bc2fdc
--- /dev/null
+++ b/9.5
@@ -0,0 +1 @@
+latest
\ No newline at end of file
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
deleted file mode 100644
index 441191ee..00000000
--- a/9.5/Dockerfile
+++ /dev/null
@@ -1,70 +0,0 @@
-FROM centos:centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="centos/postgresql-95-centos7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
-      release="1" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
-
-COPY root /
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
deleted file mode 100644
index 08e43cfd..00000000
--- a/9.5/Dockerfile.rhel7
+++ /dev/null
@@ -1,74 +0,0 @@
-FROM rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="rhscl/postgresql-95-rhel7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
-      release="1"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-7-server-optional-rpms && \
-    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
-    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
-
-COPY root /
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.5/README.md b/9.5/README.md
deleted file mode 120000
index d359f030..00000000
--- a/9.5/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.5/cccp.yml b/9.5/cccp.yml
deleted file mode 100644
index 03d18e29..00000000
--- a/9.5/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-95-centos7
diff --git a/9.5/root/usr/bin/cgroup-limits b/9.5/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/9.5/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))
diff --git a/9.5/root/usr/bin/container-entrypoint b/9.5/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/9.5/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
deleted file mode 100755
index 1c8de780..00000000
--- a/9.5/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  NEED_TO_CREATE_USERS=yes
-fi
-
-pg_ctl -w start -o "-h ''"
-if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
-  create_users
-fi
-set_passwords
-pg_ctl stop
-
-unset_env_vars
-exec postgres "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-master b/9.5/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/9.5/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-slave b/9.5/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index 5d42d0d4..00000000
--- a/9.5/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-exec postgres "$@"
diff --git a/9.5/root/usr/libexec/fix-permissions b/9.5/root/usr/libexec/fix-permissions
deleted file mode 100755
index ebcdd3d4..00000000
--- a/9.5/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index bdf5bf3f..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,98 +0,0 @@
-PostgreSQL Docker image
-=======================
-
-This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
-Users can choose between RHEL and CentOS based images.
-
-
-Environment variables and volumes
-----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-|    Variable name             |    Description                                 |
-| :--------------------------- | ---------------------------------------------- |
-|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
-|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
-|  `POSTGRESQL_DATABASE`       | Database name                                  |
-|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-|    Variable name              |    Description                                                          |    Default
-| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
-|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
-|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
-|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
-|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
-
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
-
-|  Volume mount point      | Description                           |
-| :----------------------- | ------------------------------------- |
-|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Usage
-----------------------
-
-For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
-
-PostgreSQL auto-tuning
---------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index ca58a0bb..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,220 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-You must either specify the following environment variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
-Or both.
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/openshift/postgresql.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  case ",$postinitdb_actions," in
-    *,admin_pass,*|*,simple_db,*) ;;
-    *) usage ;;
-  esac
-
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-function initialize_database() {
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.5/static/locale.html
-  LANG=${LANG:-en_US.utf8} initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-function set_passwords() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-  fi
-}
-
-function set_pgdata ()
-{
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    mkdir -p "${HOME}/data/userdata"
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  else 
-    # create a subdirectory that the user owns
-    mkdir -p "${HOME}/data/userdata"
-  fi
-  export PGDATA=$HOME/data/userdata
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.5/root/usr/share/container-scripts/postgresql/scl_enable b/9.5/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.5/test/run b/9.5/test/run
deleted file mode 120000
index 6901150b..00000000
--- a/9.5/test/run
+++ /dev/null
@@ -1 +0,0 @@
-../../hack/run_test
\ No newline at end of file
diff --git a/latest/Dockerfile b/latest/Dockerfile
index 9aa7020e..441191ee 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -10,27 +10,36 @@ FROM centos:centos7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
-
-ENV POSTGRESQL_VERSION=9.2 \
+ENV POSTGRESQL_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
-      io.k8s.display-name="PostgreSQL 9.2" \
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.5" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql92"
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="centos/postgresql-95-centos7" \
+      com.redhat.component="rh-postgresql95-docker" \
+      version="9.5" \
+      release="1" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
-ADD README.md /help.md
-ADD root /
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN yum install -y centos-release-scl && \
-    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
@@ -42,7 +51,9 @@ RUN yum install -y centos-release-scl && \
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=postgresql92
+    ENABLED_COLLECTIONS=rh-postgresql95
+
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -51,7 +62,6 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
 
-
 VOLUME ["/var/lib/pgsql/data"]
 
 USER 26
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index f274a90e..08e43cfd 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -10,35 +10,41 @@ FROM rhel7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-ENV POSTGRESQL_VERSION=9.2 \
+ENV POSTGRESQL_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
-      io.k8s.display-name="PostgreSQL 9.2" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql92"
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
 
-# Labels consumed by Red Hat build service
-LABEL name="openshift3/postgresql-92-rhel7" \
-      com.redhat.component="openshift-postgresql-docker" \
-      version="9.2" \
-      release="1" \
-      architecture="x86_64"
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.5" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="rhscl/postgresql-95-rhel7" \
+      com.redhat.component="rh-postgresql95-docker" \
+      version="9.5" \
+      release="1"
 
 EXPOSE 5432
 
-ADD README.md /help.md
-ADD root /
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN yum install -y yum-utils && \
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
-    yum install -y --disablerepo="epel" --setopt=tsflags=nodocs $INSTALL_PKGS && \
+    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
@@ -49,7 +55,9 @@ RUN yum install -y yum-utils && \
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=postgresql92
+    ENABLED_COLLECTIONS=rh-postgresql95
+
+COPY root /
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
diff --git a/latest/cccp.yml b/latest/cccp.yml
index 96f9f25c..03d18e29 100644
--- a/latest/cccp.yml
+++ b/latest/cccp.yml
@@ -1 +1 @@
-job-id: postgresql-92-centos7
+job-id: postgresql-95-centos7
diff --git a/latest/root/help.1 b/latest/root/help.1
deleted file mode 100644
index 3c74aa50..00000000
--- a/latest/root/help.1
+++ /dev/null
@@ -1,12 +0,0 @@
-.\"t
-.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
-.\"
-.\" Automatically generated by Pandoc 1.16.0.2
-.\"
-.TH "POSTGRESQL\-92\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
-.hy
-.SH PostgreSQL Docker image
-.PP
-\f[B]The PostgreSQL 9.2 image is deprecated.\f[]
-.SH AUTHORS
-Red Hat.
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index f8f4176c..bdf5bf3f 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -1,4 +1,98 @@
 PostgreSQL Docker image
 =======================
 
-**The PostgreSQL 9.2 image is deprecated.**
\ No newline at end of file
+This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
+Users can choose between RHEL and CentOS based images.
+
+
+Environment variables and volumes
+----------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+|    Variable name             |    Description                                 |
+| :--------------------------- | ---------------------------------------------- |
+|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
+|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
+|  `POSTGRESQL_DATABASE`       | Database name                                  |
+|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+|    Variable name              |    Description                                                          |    Default
+| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
+|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
+|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
+|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
+|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
+
+You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+
+|  Volume mount point      | Description                           |
+| :----------------------- | ------------------------------------- |
+|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Usage
+----------------------
+
+For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
+the PostgreSQL database cluster directory.
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`docker stop postgresql_database`.
+
+PostgreSQL auto-tuning
+--------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index 9608bcc6..ca58a0bb 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -134,7 +134,7 @@ function generate_passwd_file() {
 function initialize_database() {
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.2/static/locale.html
+  # http://www.postgresql.org/docs/9.5/static/locale.html
   LANG=${LANG:-en_US.utf8} initdb
 
   # PostgreSQL configuration.

From 3c9901472315bac057b83288b7fe118e5e7ab8d7 Mon Sep 17 00:00:00 2001
From: ficap <ficap@redhat.com>
Date: Thu, 10 Aug 2017 15:07:02 +0200
Subject: [PATCH 014/509] * fixed README.md according to new rules (#176)

* prototype of new README.md for version 9.5 according new rules

* typo fix

* added new link for RH Container Catalog, replaced old example with new one based on rhscl image

* added metadata for better manpages generation

* fixed README.md according to new rules
added link to RH container catalog
updated example with one based on rhel image
applied version changes in link urls
---
 .../container-scripts/postgresql/README.md    | 91 +++++++++++++------
 .../container-scripts/postgresql/README.md    | 91 +++++++++++++------
 2 files changed, 128 insertions(+), 54 deletions(-)

diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index bdf5bf3f..ebdbd30b 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -1,12 +1,56 @@
-PostgreSQL Docker image
-=======================
+% POSTGRESQL-94(1) Container Image Pages
+% SoftwareCollections.org
+% July 19, 2017
 
-This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
+PostgreSQL 9.4 SQL Database Server Docker image
+===============================================
+
+This container image includes PostgreSQL 9.4 SQL database server for OpenShift and general usage.
 Users can choose between RHEL and CentOS based images.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-94-rhel7)
+as registry.access.redhat.com/rhscl/postgresql-94-rhel7.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-94-centos7/)
+as centos/postgresql-94-centos7.
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-94-rhel7` image.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-94-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
+the PostgreSQL database cluster directory.
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/9.4/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.4/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`docker stop postgresql_database`.
+
 
 
 Environment variables and volumes
-----------------------------------
+---------------------------------
 
 The image recognizes the following environment variables that you can set during
 initialization by passing `-e VAR=VALUE` to the Docker run command.
@@ -37,29 +81,6 @@ You can also set the following mount points by passing the `-v /host:/container`
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Usage
-----------------------
-
-For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
 
 PostgreSQL auto-tuning
 --------------------
@@ -96,3 +117,19 @@ values stored in the variables and the actual passwords. Whenever a database
 container starts it will reset the passwords to the values stored in the
 environment variables.
 
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    docker logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
+for RHEL is called Dockerfile.rhel7.
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index bdf5bf3f..f6b0932f 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -1,12 +1,56 @@
-PostgreSQL Docker image
-=======================
+% POSTGRESQL-95(1) Container Image Pages
+% SoftwareCollections.org
+% July 18, 2017
 
-This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
+PostgreSQL 9.5 SQL Database Server Docker image
+===============================================
+
+This container image includes PostgreSQL 9.5 SQL database server for OpenShift and general usage.
 Users can choose between RHEL and CentOS based images.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-95-rhel7)
+as registry.access.redhat.com/rhscl/postgresql-95-rhel7.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-95-centos7/)
+as centos/postgresql-95-centos7.
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-95-rhel7` image.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
+the PostgreSQL database cluster directory.
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/9.5/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`docker stop postgresql_database`.
+
 
 
 Environment variables and volumes
-----------------------------------
+---------------------------------
 
 The image recognizes the following environment variables that you can set during
 initialization by passing `-e VAR=VALUE` to the Docker run command.
@@ -37,29 +81,6 @@ You can also set the following mount points by passing the `-v /host:/container`
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Usage
-----------------------
-
-For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
 
 PostgreSQL auto-tuning
 --------------------
@@ -96,3 +117,19 @@ values stored in the variables and the actual passwords. Whenever a database
 container starts it will reset the passwords to the values stored in the
 environment variables.
 
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    docker logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
+for RHEL is called Dockerfile.rhel7.

From b04ff67c527a892101ddb21e271c107429d38a3b Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 10 Aug 2017 11:11:47 +0200
Subject: [PATCH 015/509] Add postgresql version 9.6

---
 9.5/Dockerfile                                |  70 ++++++
 9.5/Dockerfile.rhel7                          |  75 ++++++
 9.5/README.md                                 |   1 +
 9.5/cccp.yml                                  |   1 +
 9.5/root/usr/bin/cgroup-limits                |  92 ++++++++
 9.5/root/usr/bin/container-entrypoint         |   3 +
 9.5/root/usr/bin/run-postgresql               |  28 +++
 9.5/root/usr/bin/run-postgresql-master        |   5 +
 9.5/root/usr/bin/run-postgresql-slave         |  36 +++
 9.5/root/usr/libexec/fix-permissions          |   7 +
 .../container-scripts/postgresql/README.md    |  98 ++++++++
 .../container-scripts/postgresql/common.sh    | 220 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 ++
 .../openshift-custom-recovery.conf.template   |   9 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 9.5/test/run                                  |   1 +
 9.5 => 9.6                                    |   0
 Makefile                                      |   2 +-
 latest/.exclude-centos7                       |   0
 latest/.exclude-rhel7                         |   0
 latest/Dockerfile                             |  16 +-
 latest/Dockerfile.rhel7                       |  16 +-
 latest/cccp.yml                               |   2 +-
 .../container-scripts/postgresql/README.md    |  22 +-
 .../container-scripts/postgresql/common.sh    |   2 +-
 26 files changed, 707 insertions(+), 30 deletions(-)
 create mode 100644 9.5/Dockerfile
 create mode 100644 9.5/Dockerfile.rhel7
 create mode 120000 9.5/README.md
 create mode 100644 9.5/cccp.yml
 create mode 100755 9.5/root/usr/bin/cgroup-limits
 create mode 100755 9.5/root/usr/bin/container-entrypoint
 create mode 100755 9.5/root/usr/bin/run-postgresql
 create mode 100755 9.5/root/usr/bin/run-postgresql-master
 create mode 100755 9.5/root/usr/bin/run-postgresql-slave
 create mode 100755 9.5/root/usr/libexec/fix-permissions
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 120000 9.5/test/run
 rename 9.5 => 9.6 (100%)
 create mode 100644 latest/.exclude-centos7
 create mode 100644 latest/.exclude-rhel7

diff --git a/9.5/Dockerfile b/9.5/Dockerfile
new file mode 100644
index 00000000..441191ee
--- /dev/null
+++ b/9.5/Dockerfile
@@ -0,0 +1,70 @@
+FROM centos:centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.5" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="centos/postgresql-95-centos7" \
+      com.redhat.component="rh-postgresql95-docker" \
+      version="9.5" \
+      release="1" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql95
+
+COPY root /
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
new file mode 100644
index 00000000..a31cf5b5
--- /dev/null
+++ b/9.5/Dockerfile.rhel7
@@ -0,0 +1,75 @@
+FROM rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.5" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
+      name="rhscl/postgresql-95-rhel7" \
+      com.redhat.component="rh-postgresql95-docker" \
+      version="9.5" \
+      release="1"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
+    yum install -y yum-utils gettext && \
+    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-7-server-optional-rpms && \
+    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql95
+
+COPY root /
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/9.5/README.md b/9.5/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/9.5/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.5/cccp.yml b/9.5/cccp.yml
new file mode 100644
index 00000000..03d18e29
--- /dev/null
+++ b/9.5/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-95-centos7
diff --git a/9.5/root/usr/bin/cgroup-limits b/9.5/root/usr/bin/cgroup-limits
new file mode 100755
index 00000000..b9d4edc2
--- /dev/null
+++ b/9.5/root/usr/bin/cgroup-limits
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+"""
+Script for parsing cgroup information
+
+This script will read some limits from the cgroup system and parse
+them, printing out "VARIABLE=VALUE" on each line for every limit that is
+successfully read. Output of this script can be directly fed into
+bash's export command. Recommended usage from a bash script:
+
+    set -o errexit
+    export_vars=$(cgroup-limits) ; export $export_vars
+
+Variables currently supported:
+    MAX_MEMORY_LIMIT_IN_BYTES
+        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
+        currently constant value of 9223372036854775807.
+    MEMORY_LIMIT_IN_BYTES
+        Maximum amount of user memory in bytes. If this value is set
+        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
+        there is no limit set. The value is taken from
+        /sys/fs/cgroup/memory/memory.limit_in_bytes
+    NUMBER_OF_CORES
+        Number of detected CPU cores that can be used. This value is
+        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
+    NO_MEMORY_LIMIT
+        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
+        can act as if no memory limit was set. Undefined otherwise.
+"""
+
+from __future__ import print_function
+import sys
+
+
+def _read_file(path):
+    try:
+        with open(path, 'r') as f:
+            return f.read().strip()
+    except IOError:
+        return None
+
+
+def get_memory_limit():
+    """
+    Read memory limit, in bytes.
+    """
+
+    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
+    if limit is None or not limit.isdigit():
+        print("Warning: Can't detect memory limit from cgroups",
+              file=sys.stderr)
+        return None
+    return int(limit)
+
+
+def get_number_of_cores():
+    """
+    Read number of CPU cores.
+    """
+
+    core_count = 0
+
+    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
+    if line is None:
+        print("Warning: Can't detect number of CPU cores from cgroups",
+              file=sys.stderr)
+        return None
+
+    for group in line.split(','):
+        core_ids = list(map(int, group.split('-')))
+        if len(core_ids) == 2:
+            core_count += core_ids[1] - core_ids[0] + 1
+        else:
+            core_count += 1
+
+    return core_count
+
+
+if __name__ == "__main__":
+    env_vars = {
+        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
+        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
+        "NUMBER_OF_CORES": get_number_of_cores()
+    }
+
+    env_vars = {k: v for k, v in env_vars.items() if v is not None}
+
+    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
+        env_vars["NO_MEMORY_LIMIT"] = "true"
+
+    for key, value in env_vars.items():
+        print("{0}={1}".format(key, value))
diff --git a/9.5/root/usr/bin/container-entrypoint b/9.5/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/9.5/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..1c8de780
--- /dev/null
+++ b/9.5/root/usr/bin/run-postgresql
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  NEED_TO_CREATE_USERS=yes
+fi
+
+pg_ctl -w start -o "-h ''"
+if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
+  create_users
+fi
+set_passwords
+pg_ctl stop
+
+unset_env_vars
+exec postgres "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-master b/9.5/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/9.5/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-slave b/9.5/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..5d42d0d4
--- /dev/null
+++ b/9.5/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/recovery.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+exec postgres "$@"
diff --git a/9.5/root/usr/libexec/fix-permissions b/9.5/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..ebcdd3d4
--- /dev/null
+++ b/9.5/root/usr/libexec/fix-permissions
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Fix permissions on the given directory to allow group read/write of 
+# regular files and execute of directories.
+find "$1" -exec chown postgres {} \;
+find "$1" -exec chgrp 0 {} \;
+find "$1" -exec chmod g+rw {} \;
+find "$1" -type d -exec chmod g+x {} +
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..bdf5bf3f
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,98 @@
+PostgreSQL Docker image
+=======================
+
+This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
+Users can choose between RHEL and CentOS based images.
+
+
+Environment variables and volumes
+----------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+|    Variable name             |    Description                                 |
+| :--------------------------- | ---------------------------------------------- |
+|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
+|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
+|  `POSTGRESQL_DATABASE`       | Database name                                  |
+|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+|    Variable name              |    Description                                                          |    Default
+| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
+|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
+|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
+|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
+|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
+
+You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+
+|  Volume mount point      | Description                           |
+| :----------------------- | ------------------------------------- |
+|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Usage
+----------------------
+
+For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
+the PostgreSQL database cluster directory.
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`docker stop postgresql_database`.
+
+PostgreSQL auto-tuning
+--------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..ca58a0bb
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,220 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
+psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+You must either specify the following environment variables:
+  POSTGRESQL_USER (regex: '$psql_identifier_regex')
+  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
+  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
+Or both.
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/openshift/postgresql.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
+    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
+    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  case ",$postinitdb_actions," in
+    *,admin_pass,*|*,simple_db,*) ;;
+    *) usage ;;
+  esac
+
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v ^postgres /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+function initialize_database() {
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/9.5/static/locale.html
+  LANG=${LANG:-en_US.utf8} initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+function set_passwords() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+  fi
+}
+
+function set_pgdata ()
+{
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    mkdir -p "${HOME}/data/userdata"
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  else 
+    # create a subdirectory that the user owns
+    mkdir -p "${HOME}/data/userdata"
+  fi
+  export PGDATA=$HOME/data/userdata
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..26d56693
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,9 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+standby_mode = on
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.5/root/usr/share/container-scripts/postgresql/scl_enable b/9.5/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.5/test/run b/9.5/test/run
new file mode 120000
index 00000000..6901150b
--- /dev/null
+++ b/9.5/test/run
@@ -0,0 +1 @@
+../../hack/run_test
\ No newline at end of file
diff --git a/9.5 b/9.6
similarity index 100%
rename from 9.5
rename to 9.6
diff --git a/Makefile b/Makefile
index 4632f68f..be6ebd75 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.4 9.5
+VERSIONS = 9.4 9.5 9.6
 OPENSHIFT_NAMESPACES = 9.2
 
 # HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
diff --git a/latest/.exclude-centos7 b/latest/.exclude-centos7
new file mode 100644
index 00000000..e69de29b
diff --git a/latest/.exclude-rhel7 b/latest/.exclude-rhel7
new file mode 100644
index 00000000..e69de29b
diff --git a/latest/Dockerfile b/latest/Dockerfile
index 441191ee..451b1794 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -10,7 +10,7 @@ FROM centos:centos7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-ENV POSTGRESQL_VERSION=9.5 \
+ENV POSTGRESQL_VERSION=9.6 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -22,12 +22,12 @@ create, run, maintain and access a PostgreSQL DBMS server."
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
       io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
+      io.k8s.display-name="PostgreSQL 9.6" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="centos/postgresql-95-centos7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
+      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
+      name="centos/postgresql-96-centos7" \
+      com.redhat.component="rh-postgresql96-docker" \
+      version="9.6" \
       release="1" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
@@ -39,7 +39,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
@@ -51,7 +51,7 @@ RUN yum install -y centos-release-scl-rh && \
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
+    ENABLED_COLLECTIONS=rh-postgresql96
 
 COPY root /
 
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 08e43cfd..323dded4 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -10,7 +10,7 @@ FROM rhel7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-ENV POSTGRESQL_VERSION=9.5 \
+ENV POSTGRESQL_VERSION=9.6 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -22,12 +22,12 @@ create, run, maintain and access a PostgreSQL DBMS server."
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
       io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
+      io.k8s.display-name="PostgreSQL 9.6" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="rhscl/postgresql-95-rhel7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
+      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
+      name="rhscl/postgresql-96-rhel7" \
+      com.redhat.component="rh-postgresql96-docker" \
+      version="9.6" \
       release="1"
 
 EXPOSE 5432
@@ -43,7 +43,7 @@ RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
@@ -55,7 +55,7 @@ RUN yum install -y yum-utils gettext && \
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
+    ENABLED_COLLECTIONS=rh-postgresql96
 
 COPY root /
 
diff --git a/latest/cccp.yml b/latest/cccp.yml
index 03d18e29..fb90f577 100644
--- a/latest/cccp.yml
+++ b/latest/cccp.yml
@@ -1 +1 @@
-job-id: postgresql-95-centos7
+job-id: postgresql-96-centos7
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index f6b0932f..7b5149fd 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -1,16 +1,16 @@
-% POSTGRESQL-95(1) Container Image Pages
+% POSTGRESQL-96(1) Container Image Pages
 % SoftwareCollections.org
 % July 18, 2017
 
-PostgreSQL 9.5 SQL Database Server Docker image
+PostgreSQL 9.6 SQL Database Server Docker image
 ===============================================
 
-This container image includes PostgreSQL 9.5 SQL database server for OpenShift and general usage.
+This container image includes PostgreSQL 9.6 SQL database server for OpenShift and general usage.
 Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-95-rhel7)
-as registry.access.redhat.com/rhscl/postgresql-95-rhel7.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-95-centos7/)
-as centos/postgresql-95-centos7.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7)
+as registry.access.redhat.com/rhscl/postgresql-96-rhel7.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-96-centos7/)
+as centos/postgresql-96-centos7.
 
 
 Description
@@ -26,12 +26,12 @@ You can find more information on the PostgreSQL project from the project Web sit
 Usage
 -----
 
-For this, we will assume that you are using the `rhscl/postgresql-95-rhel7` image.
+For this, we will assume that you are using the `rhscl/postgresql-96-rhel7` image.
 If you want to set only the mandatory environment variables and not store the database
 in a host directory, execute the following command:
 
 ```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7
 ```
 
 This will create a container named `postgresql_database` running PostgreSQL with
@@ -41,9 +41,9 @@ executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This wil
 the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.5/static/app-initdb.html)
+first run [`initdb`](http://www.postgresql.org/docs/9.6/static/app-initdb.html)
 and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/static/app-postgres.html)
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.6/static/app-postgres.html)
 is executed and will run as PID 1. You can stop the detached container by running
 `docker stop postgresql_database`.
 
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index ca58a0bb..73a3b00b 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -134,7 +134,7 @@ function generate_passwd_file() {
 function initialize_database() {
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.5/static/locale.html
+  # http://www.postgresql.org/docs/9.6/static/locale.html
   LANG=${LANG:-en_US.utf8} initdb
 
   # PostgreSQL configuration.

From 629c3ac4bb287fed2ec1505d38aaf8a563b4b888 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 10 Aug 2017 11:19:13 +0200
Subject: [PATCH 016/509] Rebase to newest container-common-scripts

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index bc6fca59..66bcdc21 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit bc6fca590c2bdeb2641fca65021a249196211289
+Subproject commit 66bcdc21586c5e8cdc9e0384fae0da0256f64001

From 27c5d74dc8b20ec2387f9d0ca70486b3a87af47a Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 10 Aug 2017 12:01:52 +0200
Subject: [PATCH 017/509] Make sure the rhscl repository gets enabled properly

Add workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
---
 9.4/Dockerfile.rhel7    | 6 +++++-
 9.5/Dockerfile.rhel7    | 5 ++++-
 latest/Dockerfile.rhel7 | 6 +++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index 25ac66e1..8840d387 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -39,7 +39,11 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-RUN yum install -y yum-utils gettext && \
+
+# We need to call 2 (!) yum commands before being able to enable repositories properly
+# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
+RUN yum repolist > /dev/null && \
+    yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index a31cf5b5..436949d5 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -39,7 +39,10 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-RUN yum install -y yum-utils gettext && \
+#
+# We need to call 2 (!) yum commands before being able to enable repositories properly
+# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
+RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 323dded4..f4b57474 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -39,7 +39,11 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-RUN yum install -y yum-utils gettext && \
+
+# We need to call 2 (!) yum commands before being able to enable repositories properly
+# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
+RUN yum repolist > /dev/null && \
+    yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \

From 8c2b6aad399e689b5539aacb64574deda50ad691 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 21 Aug 2017 10:43:35 +0200
Subject: [PATCH 018/509] Enable centos version 9.6 with testing rpms

---
 latest/.exclude-centos7 | 0
 latest/Dockerfile       | 2 ++
 2 files changed, 2 insertions(+)
 delete mode 100644 latest/.exclude-centos7

diff --git a/latest/.exclude-centos7 b/latest/.exclude-centos7
deleted file mode 100644
index e69de29b..00000000
diff --git a/latest/Dockerfile b/latest/Dockerfile
index 451b1794..9fdabbeb 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -39,6 +39,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl-rh && \
+    yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
+    echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From 8ab6d081a954c49f56e2fb8b201f0598f93bf26c Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 28 Aug 2017 13:20:37 +0200
Subject: [PATCH 019/509] Remove rhos3 repo from Dockerfile.rhel7

---
 9.4/Dockerfile.rhel7    | 1 -
 9.5/Dockerfile.rhel7    | 1 -
 latest/Dockerfile.rhel7 | 1 -
 3 files changed, 3 deletions(-)

diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index 8840d387..c384054c 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -46,7 +46,6 @@ RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 436949d5..18198f28 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -46,7 +46,6 @@ RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index f4b57474..6098a8c5 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -46,7 +46,6 @@ RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    yum-config-manager --enable rhel-7-server-ose-3.2-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From 023086b12ff1f069fdbb4665d1f11027ce55ac4b Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 28 Aug 2017 13:39:15 +0200
Subject: [PATCH 020/509] Disable all repositories before enabling some

---
 9.4/Dockerfile.rhel7    | 2 ++
 9.5/Dockerfile.rhel7    | 2 ++
 latest/Dockerfile.rhel7 | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index c384054c..ac1b1ae7 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -44,7 +44,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
 RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
+    yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 18198f28..6d13c23d 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -44,7 +44,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
 RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
+    yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 6098a8c5..03d0e6b0 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -44,7 +44,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
 RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
+    yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \

From 754096e159e276c089d474a3e855ed05c54941bb Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 29 Aug 2017 10:01:29 +0200
Subject: [PATCH 021/509] update common to latest master

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 66bcdc21..92c8e451 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 66bcdc21586c5e8cdc9e0384fae0da0256f64001
+Subproject commit 92c8e4519264f24c11182866abea660474f6ac96

From 0325f4c61e6336ed5d24db6bdfb557ddb3c89105 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 24 Aug 2017 15:46:28 +0200
Subject: [PATCH 022/509] upgrade: in-container upgrade with pg_upgrade

Fixes #172.
Complements #165.
---
 .gitignore                                    |   4 +-
 9.4/Dockerfile                                |   3 +-
 9.4/Dockerfile.rhel7                          |   5 +-
 9.4/root/usr/bin/run-postgresql               |  11 +-
 .../container-scripts/postgresql/README.md    |  36 +++
 .../container-scripts/postgresql/common.sh    | 171 ++++++++++++++-
 9.5/Dockerfile                                |   3 +-
 9.5/Dockerfile.rhel7                          |   5 +-
 9.5/root/usr/bin/run-postgresql               |  11 +-
 .../container-scripts/postgresql/README.md    |  35 +++
 .../container-scripts/postgresql/common.sh    | 171 ++++++++++++++-
 Makefile                                      |   4 +
 hack/pagila.sh                                |  36 +++
 hack/run_test                                 |  19 +-
 hack/run_upgrade_test                         | 206 ++++++++++++++++++
 latest/Dockerfile                             |   3 +-
 latest/Dockerfile.rhel7                       |   3 +-
 latest/root/usr/bin/run-postgresql            |  11 +-
 .../container-scripts/postgresql/README.md    |  35 +++
 .../container-scripts/postgresql/common.sh    | 171 ++++++++++++++-
 20 files changed, 918 insertions(+), 25 deletions(-)
 create mode 100755 hack/pagila.sh
 create mode 100755 hack/run_upgrade_test

diff --git a/.gitignore b/.gitignore
index 3aba2f13..11e45256 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-.*image-id
+.*image-id*
 help.1
+/pagila*.rpm
+/postgresql-container-pagila.sql
diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index 44a86609..cc76b9e1 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -11,6 +11,7 @@ FROM centos:centos7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.4 \
+    POSTGRESQL_PREV_VERSION=9.2 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -39,7 +40,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index ac1b1ae7..c3a06ee5 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -11,6 +11,7 @@ FROM rhel7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.4 \
+    POSTGRESQL_PREV_VERSION=9.2 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -48,8 +49,8 @@ RUN yum repolist > /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper" && \
-    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
index 1c8de780..85256d19 100755
--- a/9.4/root/usr/bin/run-postgresql
+++ b/9.4/root/usr/bin/run-postgresql
@@ -12,14 +12,19 @@ check_env_vars
 generate_passwd_file
 generate_postgresql_config
 
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
 if [ ! -f "$PGDATA/postgresql.conf" ]; then
   initialize_database
-  NEED_TO_CREATE_USERS=yes
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
 fi
 
 pg_ctl -w start -o "-h ''"
-if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
-  create_users
+if $PG_INITIALIZED ; then
+    create_users
 fi
 set_passwords
 pg_ctl stop
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index ebdbd30b..c340430c 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -118,6 +118,42 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 9.2 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+|    Variable value  |    Description                                 |
+| :----------------- | ---------------------------------------------- |
+|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
+|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
 Troubleshooting
 ---------------
 At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index f107047f..ca6ff681 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -131,11 +131,16 @@ function generate_passwd_file() {
   export NSS_WRAPPER_GROUP=/etc/group
 }
 
-function initialize_database() {
+initdb_wrapper ()
+{
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
   # http://www.postgresql.org/docs/9.4/static/locale.html
-  LANG=${LANG:-en_US.utf8} initdb
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
 
   # PostgreSQL configuration.
   cat >> "$PGDATA/postgresql.conf" <<EOF
@@ -218,3 +223,165 @@ function wait_for_postgresql_master() {
     sleep 1
   done
 }
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 441191ee..61054fe4 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -11,6 +11,7 @@ FROM centos:centos7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.5 \
+    POSTGRESQL_PREV_VERSION=9.4 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -39,7 +40,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper rh-postgresql94-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 6d13c23d..7d55d914 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -11,6 +11,7 @@ FROM rhel7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.5 \
+    POSTGRESQL_PREV_VERSION=9.4 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -48,8 +49,8 @@ RUN yum repolist > /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper" && \
-    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper rh-postgresql94-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
index 1c8de780..85256d19 100755
--- a/9.5/root/usr/bin/run-postgresql
+++ b/9.5/root/usr/bin/run-postgresql
@@ -12,14 +12,19 @@ check_env_vars
 generate_passwd_file
 generate_postgresql_config
 
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
 if [ ! -f "$PGDATA/postgresql.conf" ]; then
   initialize_database
-  NEED_TO_CREATE_USERS=yes
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
 fi
 
 pg_ctl -w start -o "-h ''"
-if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
-  create_users
+if $PG_INITIALIZED ; then
+    create_users
 fi
 set_passwords
 pg_ctl stop
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index bdf5bf3f..5b5967bb 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -96,3 +96,38 @@ values stored in the variables and the actual passwords. Whenever a database
 container starts it will reset the passwords to the values stored in the
 environment variables.
 
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 9.4 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+|    Variable value  |    Description                                 |
+| :----------------- | ---------------------------------------------- |
+|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
+|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index ca58a0bb..f3b67522 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -131,11 +131,16 @@ function generate_passwd_file() {
   export NSS_WRAPPER_GROUP=/etc/group
 }
 
-function initialize_database() {
+initdb_wrapper ()
+{
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
   # http://www.postgresql.org/docs/9.5/static/locale.html
-  LANG=${LANG:-en_US.utf8} initdb
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
 
   # PostgreSQL configuration.
   cat >> "$PGDATA/postgresql.conf" <<EOF
@@ -218,3 +223,165 @@ function wait_for_postgresql_master() {
     sleep 1
   done
 }
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
diff --git a/Makefile b/Makefile
index be6ebd75..967c26fc 100644
--- a/Makefile
+++ b/Makefile
@@ -8,3 +8,7 @@ OPENSHIFT_NAMESPACES = 9.2
 .PHONY: $(shell test -f common/common.mk || echo >&2 'Please do "git submodule update --init" first.')
 
 include common/common.mk
+
+# Additional upgrade tests.  Not hooked into CI ATM.
+upgrade-tests: $(VERSIONS)
+	hack/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
diff --git a/hack/pagila.sh b/hack/pagila.sh
new file mode 100755
index 00000000..fca2f1ba
--- /dev/null
+++ b/hack/pagila.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+set -e
+
+die() { echo "$*" >&2 ; exit 1; }
+
+test -z "$CID" && die "Please specify \$CID variable"
+test -d common || die "Please run me from git root directory"
+
+pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/p/
+pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
+pagila=$pagila_mirror$pagila_base
+pagila_file="$PWD/postgresql-container-pagila.sql"
+pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae802701
+
+if test ! -f "$pagila_file"; then
+    # TODO: better avoid race-conditions
+    touch "$pagila_file"
+
+    ( set -o pipefail
+      curl -s "$pagila" > "$pagila_base"
+      for file in ./usr/share/pagila/pagila-schema.sql \
+          ./usr/share/pagila/pagila-data.sql \
+          ./usr/share/pagila/pagila-insert-data.sql ; \
+      do
+        rpm2cpio "$pagila_base" | cpio --extract --to-stdout "$file"
+      done >"$pagila_file"
+    )
+fi
+
+case $(sha256sum "$pagila_file") in
+"$pagila_sha256sum"*) ;;
+*) false ;;
+esac
+
+docker exec -i "$CID" container-entrypoint psql -tA < "$pagila_file" &>/dev/null
diff --git a/hack/run_test b/hack/run_test
index f0b8e1f9..09d7d7e1 100755
--- a/hack/run_test
+++ b/hack/run_test
@@ -10,12 +10,14 @@ set -exo nounset
 shopt -s nullglob
 
 TEST_LIST="\
+run_upgrade_test
 run_container_creation_tests
 run_general_tests
 run_change_password_test
 run_replication_test
 run_master_restart_test
-run_doc_test"
+run_doc_test
+"
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
 test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
@@ -499,6 +501,21 @@ $volume_options
   echo "  Success!"
 }
 
+run_upgrade_test ()
+{
+    local upgrade_path="none 9.2 9.4 9.5 9.6 none" prev= act=
+    for act in $upgrade_path; do
+        if test "$act" = $VERSION; then
+            break
+        fi
+        prev=$act
+    done
+    test "$prev" != none
+
+    # TODO: We run this script from $VERSION directory, through test/run symlink.
+    (cd .. ; hack/run_upgrade_test "$prev:remote" "$VERSION:local")
+}
+
 run_doc_test() {
   local tmpdir=$(mktemp -d)
   local f
diff --git a/hack/run_upgrade_test b/hack/run_upgrade_test
new file mode 100755
index 00000000..50aaf0bc
--- /dev/null
+++ b/hack/run_upgrade_test
@@ -0,0 +1,206 @@
+#! /bin/bash
+
+set -e
+
+DEBUG=false
+
+info  () { echo >&2 " * $*" ; }
+debug () { ! ${DEBUG} || echo >&2 " ~ $*" ; }
+error () { echo >&2 "ERROR: $*" ; false ; }
+
+ADMIN_PASSWORD=redhat
+
+STEPS=( "$@" )
+: ${OS=centos7}
+
+get_image_id ()
+{
+    local old_IFS=$IFS
+    local result
+    IFS=:
+    set -- $1
+    case $2 in
+        local)
+            echo "$(cat "$1"/.image-id)"
+            ;;
+        remote)
+            local version=${1//\./}
+            case $OS in
+            rhel7)
+                ns=rhscl
+                if test "$version" -le 92; then
+                    ns=openshift3
+                fi
+                image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7
+                ;;
+            centos7)
+                ns=centos
+                if test "$version" -le 92; then
+                    ns=openshift
+                fi
+                local image=docker.io/$ns/postgresql-${1//\./}-centos7
+                ;;
+            esac
+            docker pull "$image" >/dev/null
+            echo "$image"
+            ;;
+    esac
+    IFS=$old_IFS
+}
+
+quote_args ()
+{
+    quote_args_result=
+    local space=
+    for arg; do
+        quote_args_result+="$space$(printf "%q" "$arg")"
+        space=' '
+    done
+}
+
+quote_args_print ()
+{
+    quote_args "$@"
+    echo "$quote_args_result"
+}
+
+# background_container IMAGE DOCKER_ARGS CMD
+background_container ()
+{
+    CID=$(eval "docker run -d $2 $1 $3")
+    test -n "$CID"
+}
+
+# run_server DATADIR IMAGE_ID DOCKER_ARGS
+run_server ()
+{
+    local datadir=$1
+    local image_id=$2
+    local docker_args=$(quote_args_print -e POSTGRESQL_ADMIN_PASSWORD="$ADMIN_PASSWORD")
+    docker_args+=' '$(quote_args_print -v "$datadir:/var/lib/pgsql/data:Z")
+    docker_args+=" $3"
+    background_container "$image_id" "$docker_args"
+}
+
+# wait_for_postgres CID
+wait_for_postgres ()
+{
+    local cid=$1
+    local counter=0
+
+    debug "Waiting for PG server to come up in $cid container"
+    while test $counter -lt 30
+    do
+        # the "-h localhost" is crucial here as the container runs postgresql
+        # server twice and we don't want to connect to the first process (see
+        # run-postgresql script)
+        output=$(docker exec -i "$cid" bash -c \
+            "psql -h localhost -tA -c 'select 1;' 2>/dev/null || :")
+        case $output in
+        1*) return ;;
+        "") ;;
+        *) echo "$output" ; false ;;
+        esac
+        sleep 1
+        counter=$(( counter + 1 ))
+    done
+}
+
+
+data_empty_create ()
+{
+    docker exec -i "$CID" container-entrypoint psql &>/dev/null <<EOF
+create table blah (id int);
+insert into blah values (1), (2), (3);
+EOF
+}
+
+data_empty_check ()
+{
+    debug "doing empty check"
+    local exp_output='1
+2
+3'
+    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+select * from blah order by id;
+EOF
+)
+    test "$exp_output" = "$output" || error "Unexpected output '$output'"
+}
+
+data_pagila_create ()
+{
+    debug "initializing pagila database"
+    CID="$CID" ./hack/pagila.sh
+}
+
+data_pagila_check ()
+{
+    debug "doing pagila check"
+    local exp_output='28
+16
+2'
+    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+select count(*) from information_schema.tables where table_schema = 'public';
+select count(*) from information_schema.triggers;
+select count(*) from staff;
+EOF
+)
+    test "$exp_output" = "$output" \
+        || error "Unexpected output: '$output', expected: '$exp_output'"
+}
+
+
+# init_datadir IMAGE_ID dataspec
+# ------------------------------
+init_datadir ()
+{
+    local image_id=$1
+    DATADIR=$(mktemp -d)
+    setfacl -m u:26:rwx "$DATADIR"
+    run_server "$DATADIR" "$image_id"
+    wait_for_postgres "$CID"
+
+    eval "data_$2_create"
+    eval "data_$2_check"
+
+    docker stop "$CID" >/dev/null
+    docker rm -f "$CID" >/dev/null
+}
+
+
+# check_upgrade_path {hardlink|copy} dataspec
+assert_upgrade_succeeds ()
+{
+    info "Initializing datadir with $VERSION_FROM PostgreSQL"
+    local INIT_IMAGE=$(get_image_id "$VERSION_FROM")
+    local dataspec=$2
+    init_datadir "$INIT_IMAGE" "$dataspec"
+
+    info "Running upgrade '$1/$dataspec'"
+
+    for upgrade_to in "${UPGRADE_PATH[@]}"; do
+        info "Upgrading to $upgrade_to"
+        UPGRADE_IMAGE=$(get_image_id "$upgrade_to")
+        run_server "$DATADIR" "$UPGRADE_IMAGE" "-e POSTGRESQL_UPGRADE=$1"
+        wait_for_postgres "$CID"
+        eval "data_${dataspec}_check"
+        debug "the upgrading container of version '$upgrade_to' responded"
+        docker stop "$CID" >/dev/null
+        docker rm -f "$CID" >/dev/null
+
+        run_server "$DATADIR" "$UPGRADE_IMAGE"
+        wait_for_postgres "$CID"
+        eval "data_${dataspec}_check"
+        debug "restarted server of version '$upgrade_to' responded"
+        docker stop "$CID" >/dev/null
+        docker rm -f "$CID" >/dev/null
+    done
+}
+
+VERSION_FROM=$1 ; shift
+UPGRADE_PATH=( "$@" )
+for data in empty pagila; do
+    assert_upgrade_succeeds hardlink "$data"
+    assert_upgrade_succeeds copy "$data"
+done
diff --git a/latest/Dockerfile b/latest/Dockerfile
index 9fdabbeb..d5e02864 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -11,6 +11,7 @@ FROM centos:centos7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -41,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum install -y centos-release-scl-rh && \
     yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
     echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 03d0e6b0..cef4c546 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -11,6 +11,7 @@ FROM rhel7
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres
 
@@ -48,7 +49,7 @@ RUN yum repolist > /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \
     yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
index 1c8de780..85256d19 100755
--- a/latest/root/usr/bin/run-postgresql
+++ b/latest/root/usr/bin/run-postgresql
@@ -12,14 +12,19 @@ check_env_vars
 generate_passwd_file
 generate_postgresql_config
 
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
 if [ ! -f "$PGDATA/postgresql.conf" ]; then
   initialize_database
-  NEED_TO_CREATE_USERS=yes
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
 fi
 
 pg_ctl -w start -o "-h ''"
-if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
-  create_users
+if $PG_INITIALIZED ; then
+    create_users
 fi
 set_passwords
 pg_ctl stop
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 7b5149fd..00ee355f 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -117,6 +117,41 @@ values stored in the variables and the actual passwords. Whenever a database
 container starts it will reset the passwords to the values stored in the
 environment variables.
 
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 9.5 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+|    Variable value  |    Description                                 |
+| :----------------- | ---------------------------------------------- |
+|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
+|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
 
 Troubleshooting
 ---------------
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index 73a3b00b..ea756c63 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -131,11 +131,16 @@ function generate_passwd_file() {
   export NSS_WRAPPER_GROUP=/etc/group
 }
 
-function initialize_database() {
+initdb_wrapper ()
+{
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
   # http://www.postgresql.org/docs/9.6/static/locale.html
-  LANG=${LANG:-en_US.utf8} initdb
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
 
   # PostgreSQL configuration.
   cat >> "$PGDATA/postgresql.conf" <<EOF
@@ -218,3 +223,165 @@ function wait_for_postgresql_master() {
     sleep 1
   done
 }
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}

From 4a70f9f52a196d2e07e5fc5db07e0673d1fb9ba8 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 15 Sep 2017 00:09:24 +0200
Subject: [PATCH 023/509] Improve README.md in root

---
 .../usr/share/container-scripts/postgresql/common.sh   |  2 +-
 .../usr/share/container-scripts/postgresql/README.md   |  8 ++++----
 .../usr/share/container-scripts/postgresql/common.sh   |  2 +-
 README.md                                              | 10 ++++++++--
 .../usr/share/container-scripts/postgresql/common.sh   |  2 +-
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index ca6ff681..04a62128 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -50,7 +50,7 @@ Optional settings:
   POSTGRESQL_SHARED_BUFFERS (default: 32MB)
 
 For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/openshift/postgresql.
+within the container or visit https://github.com/sclorg/postgresql-container.
 EOF
   exit 1
 }
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index 5b5967bb..896cd6a7 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -40,12 +40,12 @@ matches the user UID or name which is running inside the container.**
 Usage
 ----------------------
 
-For this, we will assume that you are using the `openshift/postgresql-92-centos7` image.
+For this, we will assume that you are using the `rhscl/postgresql-95-rhel7` image.
 If you want to set only the mandatory environment variables and not store the database
 in a host directory, execute the following command:
 
 ```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 openshift/postgresql-92-centos7
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7
 ```
 
 This will create a container named `postgresql_database` running PostgreSQL with
@@ -55,9 +55,9 @@ executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This wil
 the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.2/static/app-initdb.html)
+first run [`initdb`](http://www.postgresql.org/docs/9.5/static/app-initdb.html)
 and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.2/static/app-postgres.html)
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/static/app-postgres.html)
 is executed and will run as PID 1. You can stop the detached container by running
 `docker stop postgresql_database`.
 
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index f3b67522..29b64e59 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -50,7 +50,7 @@ Optional settings:
   POSTGRESQL_SHARED_BUFFERS (default: 32MB)
 
 For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/openshift/postgresql.
+within the container or visit https://github.com/sclorg/postgresql-container.
 EOF
   exit 1
 }
diff --git a/README.md b/README.md
index 891750d7..914daf45 100644
--- a/README.md
+++ b/README.md
@@ -7,11 +7,17 @@ Users can choose between RHEL and CentOS based images.
 For more information about using these images with OpenShift, please see the
 official [OpenShift Documentation](https://docs.openshift.org/latest/using_images/db_images/postgresql.html).
 
+For more information about contributing, see
+[the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).
+For more information about concepts used in these docker images, see the
+[Landing page](https://github.com/sclorg/welcome).
+
+
 Versions
 ---------------
 PostgreSQL versions currently provided are:
-* postgresql-9.4
-* postgresql-9.5
+* [postgresql-9.4](9.4)
+* [postgresql-9.5](9.5)
 
 RHEL versions currently supported are:
 * RHEL7
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index ea756c63..f5e6f020 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -50,7 +50,7 @@ Optional settings:
   POSTGRESQL_SHARED_BUFFERS (default: 32MB)
 
 For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/openshift/postgresql.
+within the container or visit https://github.com/sclorg/postgresql-container.
 EOF
   exit 1
 }

From 14b85768d6d0ade1d81b2218cd6b8d33858c8fd1 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 13 Mar 2017 19:32:38 +0100
Subject: [PATCH 024/509] migration: support for data import from the outside

Fixes: #165
Complements: #172 (commit 0325f4c61e6336ed5d24)
---
 9.4/root/usr/bin/run-postgresql               |   1 +
 .../container-scripts/postgresql/README.md    |  58 ++++++++
 .../container-scripts/postgresql/common.sh    |  38 ++++-
 9.5/root/usr/bin/run-postgresql               |   1 +
 .../container-scripts/postgresql/README.md    |  58 ++++++++
 .../container-scripts/postgresql/common.sh    |  38 ++++-
 hack/run_migration_test                       |  56 ++++++++
 hack/run_test                                 |  15 ++
 hack/run_upgrade_test                         | 111 +-------------
 hack/test_lib                                 | 135 ++++++++++++++++++
 latest/root/usr/bin/run-postgresql            |   1 +
 .../container-scripts/postgresql/README.md    |  58 ++++++++
 .../container-scripts/postgresql/common.sh    |  38 ++++-
 13 files changed, 486 insertions(+), 122 deletions(-)
 create mode 100755 hack/run_migration_test
 create mode 100644 hack/test_lib

diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
index 85256d19..af6ac4a1 100755
--- a/9.4/root/usr/bin/run-postgresql
+++ b/9.4/root/usr/bin/run-postgresql
@@ -24,6 +24,7 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    migrate_db
     create_users
 fi
 set_passwords
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index c340430c..8a44593a 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -62,6 +62,14 @@ initialization by passing `-e VAR=VALUE` to the Docker run command.
 |  `POSTGRESQL_DATABASE`       | Database name                                  |
 |  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
 
+Alternatively, the following options are related to migration scenario:
+
+|    Variable name                       |    Description                         |
+| :------------------------------------- | -------------------------------------- |
+|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
+|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
+|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
+
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 |    Variable name              |    Description                                                          |    Default
@@ -82,6 +90,56 @@ directory has the appropriate permissions and that the owner and group of the di
 matches the user UID or name which is running inside the container.**
 
 
+Data migration
+----------------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ docker run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
 PostgreSQL auto-tuning
 --------------------
 
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index 04a62128..177cfe4e 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -37,13 +37,21 @@ function usage() {
   fi
 
   cat >&2 <<EOF
-You must either specify the following environment variables:
+For general container run, you must either specify the following environment
+variables:
   POSTGRESQL_USER (regex: '$psql_identifier_regex')
   POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
   POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
 Or the following environment variable:
   POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
 Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
 Optional settings:
   POSTGRESQL_MAX_CONNECTIONS (default: 100)
   POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
@@ -72,11 +80,16 @@ function check_env_vars() {
     postinitdb_actions+=",admin_pass"
   fi
 
-  case ",$postinitdb_actions," in
-    *,admin_pass,*|*,simple_db,*) ;;
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
     *) usage ;;
   esac
-
 }
 
 # Make sure env variables don't propagate to PostgreSQL process.
@@ -192,6 +205,23 @@ function set_passwords() {
   fi
 }
 
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
 function set_pgdata ()
 {
   # backwards compatibility case, we used to put the data here,
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
index 85256d19..af6ac4a1 100755
--- a/9.5/root/usr/bin/run-postgresql
+++ b/9.5/root/usr/bin/run-postgresql
@@ -24,6 +24,7 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    migrate_db
     create_users
 fi
 set_passwords
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index 896cd6a7..2e520635 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -18,6 +18,14 @@ initialization by passing `-e VAR=VALUE` to the Docker run command.
 |  `POSTGRESQL_DATABASE`       | Database name                                  |
 |  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
 
+Alternatively, the following options are related to migration scenario:
+
+|    Variable name                       |    Description                         |
+| :------------------------------------- | -------------------------------------- |
+|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
+|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
+|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
+
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 |    Variable name              |    Description                                                          |    Default
@@ -61,6 +69,56 @@ or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/st
 is executed and will run as PID 1. You can stop the detached container by running
 `docker stop postgresql_database`.
 
+Data migration
+----------------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ docker run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
 PostgreSQL auto-tuning
 --------------------
 
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index 29b64e59..db37220a 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -37,13 +37,21 @@ function usage() {
   fi
 
   cat >&2 <<EOF
-You must either specify the following environment variables:
+For general container run, you must either specify the following environment
+variables:
   POSTGRESQL_USER (regex: '$psql_identifier_regex')
   POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
   POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
 Or the following environment variable:
   POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
 Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
 Optional settings:
   POSTGRESQL_MAX_CONNECTIONS (default: 100)
   POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
@@ -72,11 +80,16 @@ function check_env_vars() {
     postinitdb_actions+=",admin_pass"
   fi
 
-  case ",$postinitdb_actions," in
-    *,admin_pass,*|*,simple_db,*) ;;
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
     *) usage ;;
   esac
-
 }
 
 # Make sure env variables don't propagate to PostgreSQL process.
@@ -192,6 +205,23 @@ function set_passwords() {
   fi
 }
 
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
 function set_pgdata ()
 {
   # backwards compatibility case, we used to put the data here,
diff --git a/hack/run_migration_test b/hack/run_migration_test
new file mode 100755
index 00000000..82950a4f
--- /dev/null
+++ b/hack/run_migration_test
@@ -0,0 +1,56 @@
+#! /bin/bash
+
+set -e
+. hack/test_lib
+ADMIN_PASSWORD=redhat
+
+test $# -eq 2 || error "two args expected: $0 FROM TO"
+
+cleanup()
+{
+    set +e
+    set -- $container_from $container_to
+    if test $# -gt 0; then
+        docker stop "$@" >/dev/null
+        docker rm -f "$@"
+    fi
+}
+trap cleanup EXIT
+
+from=$1
+to=$2
+image_from=$(get_image_id "$from")
+image_to=$(get_image_id "$to")
+
+assert_migration_succeeds ()
+{
+    info "starting PostgreSQL server v$from"
+    container_from=$(docker run -e POSTGRESQL_ADMIN_PASSWORD="$ADMIN_PASSWORD" -d "$image_from")
+    wait_for_postgres "$container_from"
+
+    eval "CID=\$container_from data_${1}_create"
+    eval "CID=\$container_from data_${1}_check"
+
+    ip=$(container_ip "$container_from")
+
+    info "starting new PostgreSQL server v$to with migration options"
+    container_to=$(docker run \
+        -e POSTGRESQL_MIGRATION_REMOTE_HOST="$ip" \
+        -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD="$ADMIN_PASSWORD" \
+        -d "$image_to")
+
+    # Prolong a waiting time here a bit since both dump and restore is done in
+    # uncertain environment (usually both is done on the same hardware).
+    wait_for_postgres "$container_to" 100
+
+    info "check that the migration passed"
+    eval "CID=\$container_to data_${1}_check"
+
+    docker stop "$container_from"
+    docker rm -f "$container_from"
+    docker stop "$container_to"
+    docker rm -f "$container_to"
+    container_from= container_to=
+}
+
+assert_migration_succeeds pagila
diff --git a/hack/run_test b/hack/run_test
index 09d7d7e1..c99eb6c8 100755
--- a/hack/run_test
+++ b/hack/run_test
@@ -9,8 +9,11 @@
 set -exo nounset
 shopt -s nullglob
 
+. ../hack/test_lib
+
 TEST_LIST="\
 run_upgrade_test
+run_migration_test
 run_container_creation_tests
 run_general_tests
 run_change_password_test
@@ -516,6 +519,18 @@ run_upgrade_test ()
     (cd .. ; hack/run_upgrade_test "$prev:remote" "$VERSION:local")
 }
 
+run_migration_test ()
+{
+    local from_version
+    local upgrade_path="9.2 9.4 9.5 9.6"
+
+    for from_version in $upgrade_path; do
+        test $(version2number $from_version) -le $(version2number "$VERSION") \
+            || break
+        (cd .. ; hack/run_migration_test $from_version:remote $VERSION:local)
+    done
+}
+
 run_doc_test() {
   local tmpdir=$(mktemp -d)
   local f
diff --git a/hack/run_upgrade_test b/hack/run_upgrade_test
index 50aaf0bc..232a3e13 100755
--- a/hack/run_upgrade_test
+++ b/hack/run_upgrade_test
@@ -2,51 +2,11 @@
 
 set -e
 
-DEBUG=false
-
-info  () { echo >&2 " * $*" ; }
-debug () { ! ${DEBUG} || echo >&2 " ~ $*" ; }
-error () { echo >&2 "ERROR: $*" ; false ; }
+. hack/test_lib
 
 ADMIN_PASSWORD=redhat
 
 STEPS=( "$@" )
-: ${OS=centos7}
-
-get_image_id ()
-{
-    local old_IFS=$IFS
-    local result
-    IFS=:
-    set -- $1
-    case $2 in
-        local)
-            echo "$(cat "$1"/.image-id)"
-            ;;
-        remote)
-            local version=${1//\./}
-            case $OS in
-            rhel7)
-                ns=rhscl
-                if test "$version" -le 92; then
-                    ns=openshift3
-                fi
-                image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7
-                ;;
-            centos7)
-                ns=centos
-                if test "$version" -le 92; then
-                    ns=openshift
-                fi
-                local image=docker.io/$ns/postgresql-${1//\./}-centos7
-                ;;
-            esac
-            docker pull "$image" >/dev/null
-            echo "$image"
-            ;;
-    esac
-    IFS=$old_IFS
-}
 
 quote_args ()
 {
@@ -82,75 +42,6 @@ run_server ()
     background_container "$image_id" "$docker_args"
 }
 
-# wait_for_postgres CID
-wait_for_postgres ()
-{
-    local cid=$1
-    local counter=0
-
-    debug "Waiting for PG server to come up in $cid container"
-    while test $counter -lt 30
-    do
-        # the "-h localhost" is crucial here as the container runs postgresql
-        # server twice and we don't want to connect to the first process (see
-        # run-postgresql script)
-        output=$(docker exec -i "$cid" bash -c \
-            "psql -h localhost -tA -c 'select 1;' 2>/dev/null || :")
-        case $output in
-        1*) return ;;
-        "") ;;
-        *) echo "$output" ; false ;;
-        esac
-        sleep 1
-        counter=$(( counter + 1 ))
-    done
-}
-
-
-data_empty_create ()
-{
-    docker exec -i "$CID" container-entrypoint psql &>/dev/null <<EOF
-create table blah (id int);
-insert into blah values (1), (2), (3);
-EOF
-}
-
-data_empty_check ()
-{
-    debug "doing empty check"
-    local exp_output='1
-2
-3'
-    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
-select * from blah order by id;
-EOF
-)
-    test "$exp_output" = "$output" || error "Unexpected output '$output'"
-}
-
-data_pagila_create ()
-{
-    debug "initializing pagila database"
-    CID="$CID" ./hack/pagila.sh
-}
-
-data_pagila_check ()
-{
-    debug "doing pagila check"
-    local exp_output='28
-16
-2'
-    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
-select count(*) from information_schema.tables where table_schema = 'public';
-select count(*) from information_schema.triggers;
-select count(*) from staff;
-EOF
-)
-    test "$exp_output" = "$output" \
-        || error "Unexpected output: '$output', expected: '$exp_output'"
-}
-
-
 # init_datadir IMAGE_ID dataspec
 # ------------------------------
 init_datadir ()
diff --git a/hack/test_lib b/hack/test_lib
new file mode 100644
index 00000000..eee5703e
--- /dev/null
+++ b/hack/test_lib
@@ -0,0 +1,135 @@
+: ${OS=centos7}
+DEBUG=false
+
+info  () { echo >&2 " * $*" ; }
+debug () { ! ${DEBUG} || echo >&2 " ~ $*" ; }
+error () { echo >&2 "ERROR: $*" ; false ; }
+
+get_image_id ()
+{
+    local old_IFS=$IFS
+    local result
+    IFS=:
+    set -- $1
+    case $2 in
+        local)
+            echo "$(cat "$1"/.image-id)"
+            ;;
+        remote)
+            local version=${1//\./}
+            case $OS in
+            rhel7)
+                ns=rhscl
+                if test "$version" -le 92; then
+                    ns=openshift3
+                fi
+                image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7
+                ;;
+            centos7)
+                ns=centos
+                if test "$version" -le 92; then
+                    ns=openshift
+                fi
+                local image=docker.io/$ns/postgresql-${1//\./}-centos7
+                ;;
+            esac
+            docker pull "$image" >/dev/null
+            echo "$image"
+            ;;
+    esac
+    IFS=$old_IFS
+}
+
+data_pagila_create ()
+{
+    debug "initializing pagila database"
+    CID="$CID" ./hack/pagila.sh
+}
+
+data_pagila_check ()
+{
+    debug "doing pagila check"
+    local exp_output='28
+16
+2'
+    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+select count(*) from information_schema.tables where table_schema = 'public';
+select count(*) from information_schema.triggers;
+select count(*) from staff;
+EOF
+)
+    test "$exp_output" = "$output" \
+        || error "Unexpected output: '$output', expected: '$exp_output'"
+}
+
+data_empty_create ()
+{
+    docker exec -i "$CID" container-entrypoint psql &>/dev/null <<EOF
+create table blah (id int);
+insert into blah values (1), (2), (3);
+EOF
+}
+
+data_empty_check ()
+{
+    debug "doing empty check"
+    local exp_output='1
+2
+3'
+    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+select * from blah order by id;
+EOF
+)
+    test "$exp_output" = "$output" || error "Unexpected output '$output'"
+}
+
+# wait_for_postgres CID
+wait_for_postgres ()
+{
+    local cid=$1
+    local stop_after=${2-30}
+    local counter=0
+
+    debug "Waiting for PG server to come up in $cid container"
+    while test $counter -lt "$stop_after"
+    do
+        # the "-h localhost" is crucial here as the container runs postgresql
+        # server twice and we don't want to connect to the first process (see
+        # run-postgresql script)
+        output=$(docker exec -i "$cid" bash -c \
+            "psql -h localhost -tA -c 'select 1;' 2>/dev/null || :")
+        case $output in
+        1*) return ;;
+        "") ;;
+        *) echo "$output" ; false ;;
+        esac
+        sleep 1
+        counter=$(( counter + 1 ))
+    done
+}
+
+
+# version2number VERSION [DEPTH] [WIDTH]
+# --------------------------------------
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# container_ip CONTAINER_ID
+# -------------------------
+container_ip()
+{
+  docker inspect --format='{{.NetworkSettings.IPAddress}}' "$1"
+}
+
+# vi: set ft=sh
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
index 85256d19..af6ac4a1 100755
--- a/latest/root/usr/bin/run-postgresql
+++ b/latest/root/usr/bin/run-postgresql
@@ -24,6 +24,7 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    migrate_db
     create_users
 fi
 set_passwords
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 00ee355f..b09cec59 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -62,6 +62,14 @@ initialization by passing `-e VAR=VALUE` to the Docker run command.
 |  `POSTGRESQL_DATABASE`       | Database name                                  |
 |  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
 
+Alternatively, the following options are related to migration scenario:
+
+|    Variable name                       |    Description                         |
+| :------------------------------------- | -------------------------------------- |
+|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
+|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
+|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
+
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 |    Variable name              |    Description                                                          |    Default
@@ -82,6 +90,56 @@ directory has the appropriate permissions and that the owner and group of the di
 matches the user UID or name which is running inside the container.**
 
 
+Data migration
+----------------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ docker run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
 PostgreSQL auto-tuning
 --------------------
 
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index f5e6f020..d4b2f501 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -37,13 +37,21 @@ function usage() {
   fi
 
   cat >&2 <<EOF
-You must either specify the following environment variables:
+For general container run, you must either specify the following environment
+variables:
   POSTGRESQL_USER (regex: '$psql_identifier_regex')
   POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
   POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
 Or the following environment variable:
   POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
 Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
 Optional settings:
   POSTGRESQL_MAX_CONNECTIONS (default: 100)
   POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
@@ -72,11 +80,16 @@ function check_env_vars() {
     postinitdb_actions+=",admin_pass"
   fi
 
-  case ",$postinitdb_actions," in
-    *,admin_pass,*|*,simple_db,*) ;;
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
     *) usage ;;
   esac
-
 }
 
 # Make sure env variables don't propagate to PostgreSQL process.
@@ -192,6 +205,23 @@ function set_passwords() {
   fi
 }
 
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
 function set_pgdata ()
 {
   # backwards compatibility case, we used to put the data here,

From 0a96fd79b7fc7f36031b9c087f548cd52b8d9362 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 26 Sep 2017 09:04:56 +0200
Subject: [PATCH 025/509] test: Rename `hack` to `test`

Since `hack` at this point only contains scripts/libraries used for testing
of the image it no longer makes sense to call the folder `hack`.
Modify all existing links pointing to the folder accordingly.
---
 9.2/test/run                      | 2 +-
 9.4/test/run                      | 2 +-
 9.5/test/run                      | 2 +-
 Makefile                          | 2 +-
 latest/test/run                   | 2 +-
 {hack => test}/pagila.sh          | 0
 {hack => test}/run_migration_test | 2 +-
 {hack => test}/run_test           | 6 +++---
 {hack => test}/run_upgrade_test   | 2 +-
 {hack => test}/test_lib           | 2 +-
 10 files changed, 11 insertions(+), 11 deletions(-)
 rename {hack => test}/pagila.sh (100%)
 rename {hack => test}/run_migration_test (98%)
 rename {hack => test}/run_test (99%)
 rename {hack => test}/run_upgrade_test (99%)
 rename {hack => test}/test_lib (99%)

diff --git a/9.2/test/run b/9.2/test/run
index 6901150b..1a3b6c92 120000
--- a/9.2/test/run
+++ b/9.2/test/run
@@ -1 +1 @@
-../../hack/run_test
\ No newline at end of file
+../../test/run_test
\ No newline at end of file
diff --git a/9.4/test/run b/9.4/test/run
index 6901150b..1a3b6c92 120000
--- a/9.4/test/run
+++ b/9.4/test/run
@@ -1 +1 @@
-../../hack/run_test
\ No newline at end of file
+../../test/run_test
\ No newline at end of file
diff --git a/9.5/test/run b/9.5/test/run
index 6901150b..1a3b6c92 120000
--- a/9.5/test/run
+++ b/9.5/test/run
@@ -1 +1 @@
-../../hack/run_test
\ No newline at end of file
+../../test/run_test
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 967c26fc..6c25c29e 100644
--- a/Makefile
+++ b/Makefile
@@ -11,4 +11,4 @@ include common/common.mk
 
 # Additional upgrade tests.  Not hooked into CI ATM.
 upgrade-tests: $(VERSIONS)
-	hack/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
+	test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
diff --git a/latest/test/run b/latest/test/run
index 6901150b..1a3b6c92 120000
--- a/latest/test/run
+++ b/latest/test/run
@@ -1 +1 @@
-../../hack/run_test
\ No newline at end of file
+../../test/run_test
\ No newline at end of file
diff --git a/hack/pagila.sh b/test/pagila.sh
similarity index 100%
rename from hack/pagila.sh
rename to test/pagila.sh
diff --git a/hack/run_migration_test b/test/run_migration_test
similarity index 98%
rename from hack/run_migration_test
rename to test/run_migration_test
index 82950a4f..4067acd8 100755
--- a/hack/run_migration_test
+++ b/test/run_migration_test
@@ -1,7 +1,7 @@
 #! /bin/bash
 
 set -e
-. hack/test_lib
+. test/test_lib
 ADMIN_PASSWORD=redhat
 
 test $# -eq 2 || error "two args expected: $0 FROM TO"
diff --git a/hack/run_test b/test/run_test
similarity index 99%
rename from hack/run_test
rename to test/run_test
index c99eb6c8..a4df5fb0 100755
--- a/hack/run_test
+++ b/test/run_test
@@ -9,7 +9,7 @@
 set -exo nounset
 shopt -s nullglob
 
-. ../hack/test_lib
+. ../test/test_lib
 
 TEST_LIST="\
 run_upgrade_test
@@ -516,7 +516,7 @@ run_upgrade_test ()
     test "$prev" != none
 
     # TODO: We run this script from $VERSION directory, through test/run symlink.
-    (cd .. ; hack/run_upgrade_test "$prev:remote" "$VERSION:local")
+    (cd .. ; test/run_upgrade_test "$prev:remote" "$VERSION:local")
 }
 
 run_migration_test ()
@@ -527,7 +527,7 @@ run_migration_test ()
     for from_version in $upgrade_path; do
         test $(version2number $from_version) -le $(version2number "$VERSION") \
             || break
-        (cd .. ; hack/run_migration_test $from_version:remote $VERSION:local)
+        (cd .. ; test/run_migration_test $from_version:remote $VERSION:local)
     done
 }
 
diff --git a/hack/run_upgrade_test b/test/run_upgrade_test
similarity index 99%
rename from hack/run_upgrade_test
rename to test/run_upgrade_test
index 232a3e13..cfa47932 100755
--- a/hack/run_upgrade_test
+++ b/test/run_upgrade_test
@@ -2,7 +2,7 @@
 
 set -e
 
-. hack/test_lib
+. test/test_lib
 
 ADMIN_PASSWORD=redhat
 
diff --git a/hack/test_lib b/test/test_lib
similarity index 99%
rename from hack/test_lib
rename to test/test_lib
index eee5703e..fb16e339 100644
--- a/hack/test_lib
+++ b/test/test_lib
@@ -43,7 +43,7 @@ get_image_id ()
 data_pagila_create ()
 {
     debug "initializing pagila database"
-    CID="$CID" ./hack/pagila.sh
+    CID="$CID" ./test/pagila.sh
 }
 
 data_pagila_check ()

From 4b78dd69b02614928090e1be23dcf91d95e9251e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 26 Sep 2017 10:40:24 +0200
Subject: [PATCH 026/509] test: Make sure the tests can be run even when
 isolated

---
 9.2/test        | 1 +
 9.2/test/run    | 1 -
 9.4/test        | 1 +
 9.4/test/run    | 1 -
 9.5/test        | 1 +
 9.5/test/run    | 1 -
 latest/test     | 1 +
 latest/test/run | 1 -
 test/pagila.sh  | 2 +-
 test/run        | 1 +
 test/run_test   | 6 +++---
 test/test_lib   | 3 ++-
 12 files changed, 11 insertions(+), 9 deletions(-)
 create mode 120000 9.2/test
 delete mode 120000 9.2/test/run
 create mode 120000 9.4/test
 delete mode 120000 9.4/test/run
 create mode 120000 9.5/test
 delete mode 120000 9.5/test/run
 create mode 120000 latest/test
 delete mode 120000 latest/test/run
 create mode 120000 test/run

diff --git a/9.2/test b/9.2/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/9.2/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/9.2/test/run b/9.2/test/run
deleted file mode 120000
index 1a3b6c92..00000000
--- a/9.2/test/run
+++ /dev/null
@@ -1 +0,0 @@
-../../test/run_test
\ No newline at end of file
diff --git a/9.4/test b/9.4/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/9.4/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/9.4/test/run b/9.4/test/run
deleted file mode 120000
index 1a3b6c92..00000000
--- a/9.4/test/run
+++ /dev/null
@@ -1 +0,0 @@
-../../test/run_test
\ No newline at end of file
diff --git a/9.5/test b/9.5/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/9.5/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/9.5/test/run b/9.5/test/run
deleted file mode 120000
index 1a3b6c92..00000000
--- a/9.5/test/run
+++ /dev/null
@@ -1 +0,0 @@
-../../test/run_test
\ No newline at end of file
diff --git a/latest/test b/latest/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/latest/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/latest/test/run b/latest/test/run
deleted file mode 120000
index 1a3b6c92..00000000
--- a/latest/test/run
+++ /dev/null
@@ -1 +0,0 @@
-../../test/run_test
\ No newline at end of file
diff --git a/test/pagila.sh b/test/pagila.sh
index fca2f1ba..0f623b17 100755
--- a/test/pagila.sh
+++ b/test/pagila.sh
@@ -5,7 +5,7 @@ set -e
 die() { echo "$*" >&2 ; exit 1; }
 
 test -z "$CID" && die "Please specify \$CID variable"
-test -d common || die "Please run me from git root directory"
+# test -d common || die "Please run me from git root directory"
 
 pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/p/
 pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
diff --git a/test/run b/test/run
new file mode 120000
index 00000000..653222bc
--- /dev/null
+++ b/test/run
@@ -0,0 +1 @@
+run_test
\ No newline at end of file
diff --git a/test/run_test b/test/run_test
index a4df5fb0..e1b87632 100755
--- a/test/run_test
+++ b/test/run_test
@@ -9,7 +9,7 @@
 set -exo nounset
 shopt -s nullglob
 
-. ../test/test_lib
+. test/test_lib
 
 TEST_LIST="\
 run_upgrade_test
@@ -516,7 +516,7 @@ run_upgrade_test ()
     test "$prev" != none
 
     # TODO: We run this script from $VERSION directory, through test/run symlink.
-    (cd .. ; test/run_upgrade_test "$prev:remote" "$VERSION:local")
+    test/run_upgrade_test "$prev:remote" "$VERSION:local"
 }
 
 run_migration_test ()
@@ -527,7 +527,7 @@ run_migration_test ()
     for from_version in $upgrade_path; do
         test $(version2number $from_version) -le $(version2number "$VERSION") \
             || break
-        (cd .. ; test/run_migration_test $from_version:remote $VERSION:local)
+        test/run_migration_test $from_version:remote $VERSION:local
     done
 }
 
diff --git a/test/test_lib b/test/test_lib
index fb16e339..63b5120d 100644
--- a/test/test_lib
+++ b/test/test_lib
@@ -13,7 +13,8 @@ get_image_id ()
     set -- $1
     case $2 in
         local)
-            echo "$(cat "$1"/.image-id)"
+            # Default to $IMAGE_NAME if it is set since .image-id might not exist
+            echo ${IMAGE_NAME-$(cat "$1"/.image-id)}
             ;;
         remote)
             local version=${1//\./}

From 7d29b0f7d2af4e6a4b7458b5c10afd2becbbbe1d Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 4 Oct 2017 12:40:58 +0200
Subject: [PATCH 027/509] rhel7: Build 9.6 with beta packages

set version label to 1, remove release label completely
---
 latest/.exclude-rhel7   | 0
 latest/Dockerfile.rhel7 | 4 ++--
 2 files changed, 2 insertions(+), 2 deletions(-)
 delete mode 100644 latest/.exclude-rhel7

diff --git a/latest/.exclude-rhel7 b/latest/.exclude-rhel7
deleted file mode 100644
index e69de29b..00000000
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index cef4c546..575a3879 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -28,8 +28,7 @@ LABEL summary=$SUMMARY \
       io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
       name="rhscl/postgresql-96-rhel7" \
       com.redhat.component="rh-postgresql96-docker" \
-      version="9.6" \
-      release="1"
+      version="1"
 
 EXPOSE 5432
 
@@ -47,6 +46,7 @@ RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+    yum-config-manager --enable rhel-server-rhscl-7-beta-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \

From a104890428223ed8f24eca0ed51a7b273fd489c2 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 5 Oct 2017 09:50:46 +0200
Subject: [PATCH 028/509] tests: Do not test migration from $VERSION:remote to
 $VERSION:local

Add another check to make sure $OS is defined
---
 test/run_test | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index e1b87632..972f3e5a 100755
--- a/test/run_test
+++ b/test/run_test
@@ -25,6 +25,7 @@ run_doc_test
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
 test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
+test -n "${OS-}" || false 'make sure $OS is defined'
 
 CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
@@ -525,7 +526,8 @@ run_migration_test ()
     local upgrade_path="9.2 9.4 9.5 9.6"
 
     for from_version in $upgrade_path; do
-        test $(version2number $from_version) -le $(version2number "$VERSION") \
+        # Do not test migration from $VERSION:remote to $VERSION:local
+        test $(version2number $from_version) -lt $(version2number "$VERSION") \
             || break
         test/run_migration_test $from_version:remote $VERSION:local
     done

From b4ef66f0a0a6970430b370958e7811ced3cafe6d Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 11 Oct 2017 16:05:22 +0200
Subject: [PATCH 029/509] Do not use tables in README.md (#185)

* Do not use tables in README.md

The reasons to not use tables in man page are:
* tables are hard to keep readable in plaintext
* tables don't look nice when rendered and long variables or complicated default value are used
* go-md2man does not convert tables into man page format in versions that are mostly used

Using two spaces in the end of the line with variable name

Making the variables bold may improve readability on github

* Do changes in README from #176 also in README.md in 9.5.

* Convert also table with upgrade options

* Remove help header and reformat migration table
---
 .../container-scripts/postgresql/README.md    |  70 +++++----
 .../container-scripts/postgresql/README.md    | 142 ++++++++++++------
 .../container-scripts/postgresql/README.md    |  71 +++++----
 3 files changed, 182 insertions(+), 101 deletions(-)

diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index 8a44593a..3546c0d7 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -1,7 +1,3 @@
-% POSTGRESQL-94(1) Container Image Pages
-% SoftwareCollections.org
-% July 19, 2017
-
 PostgreSQL 9.4 SQL Database Server Docker image
 ===============================================
 
@@ -55,35 +51,51 @@ Environment variables and volumes
 The image recognizes the following environment variables that you can set during
 initialization by passing `-e VAR=VALUE` to the Docker run command.
 
-|    Variable name             |    Description                                 |
-| :--------------------------- | ---------------------------------------------- |
-|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
-|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
-|  `POSTGRESQL_DATABASE`       | Database name                                  |
-|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
 
 Alternatively, the following options are related to migration scenario:
 
-|    Variable name                       |    Description                         |
-| :------------------------------------- | -------------------------------------- |
-|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
-|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
-|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
-|    Variable name              |    Description                                                          |    Default
-| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
-|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
-|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
-|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
-|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
 
 You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
 
-|  Volume mount point      | Description                           |
-| :----------------------- | ------------------------------------- |
-|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -202,10 +214,12 @@ approach -- it starts both old and new PostgreSQL servers (within container) and
 datadir.  This operation requires a lot of data files copying, so you can decide
 what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
 
-|    Variable value  |    Description                                 |
-| :----------------- | ---------------------------------------------- |
-|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
-|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
 
 Note that because we copy data directory, you need to make sure that you have
 enough space for the copy;  upgrade failure because of not enough space might
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index 2e520635..d4d41e1d 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -1,52 +1,26 @@
-PostgreSQL Docker image
-=======================
+PostgreSQL 9.5 SQL Database Server Docker image
+===============================================
 
-This repository contains Dockerfiles for PostgreSQL images for general usage and OpenShift.
+This container image includes PostgreSQL 9.5 SQL database server for OpenShift and general usage.
 Users can choose between RHEL and CentOS based images.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-95-rhel7)
+as registry.access.redhat.com/rhscl/postgresql-95-rhel7.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-95-centos7/)
+as centos/postgresql-95-centos7.
 
 
-Environment variables and volumes
-----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+Description
+-----------
 
-|    Variable name             |    Description                                 |
-| :--------------------------- | ---------------------------------------------- |
-|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
-|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
-|  `POSTGRESQL_DATABASE`       | Database name                                  |
-|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
 
-Alternatively, the following options are related to migration scenario:
-
-|    Variable name                       |    Description                         |
-| :------------------------------------- | -------------------------------------- |
-|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
-|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
-|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-|    Variable name              |    Description                                                          |    Default
-| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
-|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
-|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
-|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
-|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
-
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
-
-|  Volume mount point      | Description                           |
-| :----------------------- | ------------------------------------- |
-|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
 
 Usage
-----------------------
+-----
 
 For this, we will assume that you are using the `rhscl/postgresql-95-rhel7` image.
 If you want to set only the mandatory environment variables and not store the database
@@ -69,6 +43,65 @@ or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/st
 is executed and will run as PID 1. You can stop the detached container by running
 `docker stop postgresql_database`.
 
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+
 Data migration
 ----------------------
 
@@ -181,11 +214,30 @@ approach -- it starts both old and new PostgreSQL servers (within container) and
 datadir.  This operation requires a lot of data files copying, so you can decide
 what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
 
-|    Variable value  |    Description                                 |
-| :----------------- | ---------------------------------------------- |
-|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
-|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
 
 Note that because we copy data directory, you need to make sure that you have
 enough space for the copy;  upgrade failure because of not enough space might
 lead to data loss.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    docker logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
+for RHEL is called Dockerfile.rhel7.
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index b09cec59..6f24448b 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -1,7 +1,3 @@
-% POSTGRESQL-96(1) Container Image Pages
-% SoftwareCollections.org
-% July 18, 2017
-
 PostgreSQL 9.6 SQL Database Server Docker image
 ===============================================
 
@@ -55,35 +51,51 @@ Environment variables and volumes
 The image recognizes the following environment variables that you can set during
 initialization by passing `-e VAR=VALUE` to the Docker run command.
 
-|    Variable name             |    Description                                 |
-| :--------------------------- | ---------------------------------------------- |
-|  `POSTGRESQL_USER`           | User name for PostgreSQL account to be created |
-|  `POSTGRESQL_PASSWORD`       | Password for the user account                  |
-|  `POSTGRESQL_DATABASE`       | Database name                                  |
-|  `POSTGRESQL_ADMIN_PASSWORD` | Password for the `postgres` admin account (optional)     |
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
 
 Alternatively, the following options are related to migration scenario:
 
-|    Variable name                       |    Description                         |
-| :------------------------------------- | -------------------------------------- |
-|  `POSTGRESQL_MIGRATION_REMOTE_HOST`    | Hostname/IP to migrate from            |
-|  `POSTGRESQL_MIGRATION_ADMIN_PASSWORD` | Password for the remote 'postgres' admin user |
-|  `POSTGRESQL_MIGRATION_IGNORE_ERRORS`  | Set to 'yes' to ignore sql import errors (optional, default 'no') |
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
-|    Variable name              |    Description                                                          |    Default
-| :---------------------------- | ----------------------------------------------------------------------- | -------------------------------
-|  `POSTGRESQL_MAX_CONNECTIONS` | The maximum number of client connections allowed |  100
-|  `POSTGRESQL_MAX_PREPARED_TRANSACTIONS` | Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections |  0
-|  `POSTGRESQL_SHARED_BUFFERS`  | Sets how much memory is dedicated to PostgreSQL to use for caching data |  32M
-|  `POSTGRESQL_EFFECTIVE_CACHE_SIZE`  | Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself |  128M
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
 
 You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
 
-|  Volume mount point      | Description                           |
-| :----------------------- | ------------------------------------- |
-|  `/var/lib/pgsql/data`   | PostgreSQL database cluster directory |
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -175,6 +187,7 @@ values stored in the variables and the actual passwords. Whenever a database
 container starts it will reset the passwords to the values stored in the
 environment variables.
 
+
 Upgrading database (by switching to newer PostgreSQL image version)
 -------------------------------------------------------------------
 
@@ -201,10 +214,12 @@ approach -- it starts both old and new PostgreSQL servers (within container) and
 datadir.  This operation requires a lot of data files copying, so you can decide
 what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
 
-|    Variable value  |    Description                                 |
-| :----------------- | ---------------------------------------------- |
-|  `copy`            | The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure. |
-|  `hardlink`        | Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure. |
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
 
 Note that because we copy data directory, you need to make sure that you have
 enough space for the copy;  upgrade failure because of not enough space might

From ccdcb66b5de82da9ffbae54250e4e9a9bf21fbaf Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Thu, 12 Oct 2017 10:40:00 +0200
Subject: [PATCH 030/509] Add templates from openshift/origin. (#188)

* Add templates from openshift/origin.

* Update common commit.

* Add symlink to test-lib-openshift.sh in test dir
---
 common                                       |   2 +-
 examples/postgresql-ephemeral-template.json  | 253 +++++++++++++++++
 examples/postgresql-persistent-template.json | 277 +++++++++++++++++++
 test/test-lib-openshift.sh                   |   1 +
 4 files changed, 532 insertions(+), 1 deletion(-)
 create mode 100644 examples/postgresql-ephemeral-template.json
 create mode 100644 examples/postgresql-persistent-template.json
 create mode 120000 test/test-lib-openshift.sh

diff --git a/common b/common
index 92c8e451..a8d2885d 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 92c8e4519264f24c11182866abea660474f6ac96
+Subproject commit a8d2885de09982496ffd7dd3e9a06296bd95e040
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
new file mode 100644
index 00000000..849c9d83
--- /dev/null
+++ b/examples/postgresql-ephemeral-template.json
@@ -0,0 +1,253 @@
+{
+  "kind": "Template",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql-ephemeral",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL (Ephemeral)",
+      "description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
+      "iconClass": "icon-postgresql",
+      "tags": "database,postgresql",
+      "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is not stored on persistent storage, so any restart of the service will result in all data being lost.  The database name, username, and password are chosen via parameters when provisioning this service.",
+      "template.openshift.io/provider-display-name": "Red Hat, Inc.",
+      "template.openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "template.openshift.io/support-url": "https://access.redhat.com"
+    }
+  },
+  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
+  "labels": {
+    "template": "postgresql-ephemeral-template"
+  },
+  "objects": [
+    {
+      "kind": "Secret",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.openshift.io/expose-username": "{.data['database-user']}",
+          "template.openshift.io/expose-password": "{.data['database-password']}",
+          "template.openshift.io/expose-database_name": "{.data['database-name']}"
+        }
+      },
+      "stringData" : {
+        "database-user" : "${POSTGRESQL_USER}",
+        "database-password" : "${POSTGRESQL_PASSWORD}",
+        "database-name" : "${POSTGRESQL_DATABASE}"
+      }
+    },
+    {
+      "kind": "Service",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.openshift.io/expose-uri": "postgres://{.spec.clusterIP}:{.spec.ports[?(.name==\"postgresql\")].port}"
+        }
+      },
+      "spec": {
+        "ports": [
+          {
+            "name": "postgresql",
+            "protocol": "TCP",
+            "port": 5432,
+            "targetPort": 5432,
+            "nodePort": 0
+          }
+        ],
+        "selector": {
+          "name": "${DATABASE_SERVICE_NAME}"
+        },
+        "type": "ClusterIP",
+        "sessionAffinity": "None"
+      },
+      "status": {
+        "loadBalancer": {}
+      }
+    },
+    {
+      "kind": "DeploymentConfig",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.alpha.openshift.io/wait-for-ready": "true"
+        }
+      },
+      "spec": {
+        "strategy": {
+          "type": "Recreate"
+        },
+        "triggers": [
+          {
+            "type": "ImageChange",
+            "imageChangeParams": {
+              "automatic": true,
+              "containerNames": [
+                "postgresql"
+              ],
+              "from": {
+                "kind": "ImageStreamTag",
+                "name": "postgresql:${POSTGRESQL_VERSION}",
+                "namespace": "${NAMESPACE}"
+              },
+              "lastTriggeredImage": ""
+            }
+          },
+          {
+            "type": "ConfigChange"
+          }
+        ],
+        "replicas": 1,
+        "selector": {
+          "name": "${DATABASE_SERVICE_NAME}"
+        },
+        "template": {
+          "metadata": {
+            "labels": {
+              "name": "${DATABASE_SERVICE_NAME}"
+            }
+          },
+          "spec": {
+            "containers": [
+              {
+                "name": "postgresql",
+                "image": " ",
+                "ports": [
+                  {
+                    "containerPort": 5432,
+                    "protocol": "TCP"
+                  }
+                ],
+                "readinessProbe": {
+                  "timeoutSeconds": 1,
+                  "initialDelaySeconds": 5,
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                  }
+                },
+                "livenessProbe": {
+                  "timeoutSeconds": 1,
+                  "initialDelaySeconds": 30,
+                  "tcpSocket": {
+                    "port": 5432
+                  }
+                },
+                "env": [
+                  {
+                    "name": "POSTGRESQL_USER",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-user"
+                      }
+                    }
+                  },
+                  {
+                    "name": "POSTGRESQL_PASSWORD",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-password"
+                      }
+                    }
+                  },
+                  {
+                    "name": "POSTGRESQL_DATABASE",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-name"
+                      }
+                    }
+                  }
+                ],
+                "resources": {
+                  "limits": {
+                    "memory": "${MEMORY_LIMIT}"
+                  }
+                },
+                "volumeMounts": [
+                  {
+                    "name": "${DATABASE_SERVICE_NAME}-data",
+                    "mountPath": "/var/lib/pgsql/data"
+                  }
+                ],
+                "terminationMessagePath": "/dev/termination-log",
+                "imagePullPolicy": "IfNotPresent",
+                "capabilities": {},
+                "securityContext": {
+                  "capabilities": {},
+                  "privileged": false
+                }
+              }
+            ],
+            "volumes": [
+              {
+                "name": "${DATABASE_SERVICE_NAME}-data",
+                "emptyDir": {
+                  "medium": ""
+                }
+              }
+            ],
+            "restartPolicy": "Always",
+            "dnsPolicy": "ClusterFirst"
+          }
+        }
+      },
+      "status": {}
+    }
+  ],
+  "parameters": [
+    {
+      "name": "MEMORY_LIMIT",
+      "displayName": "Memory Limit",
+      "description": "Maximum amount of memory the container can use.",
+      "value": "512Mi",
+      "required": true
+    },
+    {
+      "name": "NAMESPACE",
+      "displayName": "Namespace",
+      "description": "The OpenShift Namespace where the ImageStream resides.",
+      "value": "openshift"
+    },
+    {
+      "name": "DATABASE_SERVICE_NAME",
+      "displayName": "Database Service Name",
+      "description": "The name of the OpenShift Service exposed for the database.",
+      "value": "postgresql",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_USER",
+      "displayName": "PostgreSQL Connection Username",
+      "description": "Username for PostgreSQL user that will be used for accessing the database.",
+      "generate": "expression",
+      "from": "user[A-Z0-9]{3}",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_PASSWORD",
+      "displayName": "PostgreSQL Connection Password",
+      "description": "Password for the PostgreSQL connection user.",
+      "generate": "expression",
+      "from": "[a-zA-Z0-9]{16}",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_DATABASE",
+      "displayName": "PostgreSQL Database Name",
+      "description": "Name of the PostgreSQL database accessed.",
+      "value": "sampledb",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_VERSION",
+      "displayName": "Version of PostgreSQL Image",
+      "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
+      "value": "9.5",
+      "required": true
+    }
+  ]
+}
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
new file mode 100644
index 00000000..b622baa0
--- /dev/null
+++ b/examples/postgresql-persistent-template.json
@@ -0,0 +1,277 @@
+{
+  "kind": "Template",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql-persistent",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL (Persistent)",
+      "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
+      "iconClass": "icon-postgresql",
+      "tags": "database,postgresql",
+      "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is stored on persistent storage.  The database name, username, and password are chosen via parameters when provisioning this service.",
+      "template.openshift.io/provider-display-name": "Red Hat, Inc.",
+      "template.openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "template.openshift.io/support-url": "https://access.redhat.com"
+    }
+  },
+  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
+  "labels": {
+    "template": "postgresql-persistent-template"
+  },
+  "objects": [
+    {
+      "kind": "Secret",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.openshift.io/expose-username": "{.data['database-user']}",
+          "template.openshift.io/expose-password": "{.data['database-password']}",
+          "template.openshift.io/expose-database_name": "{.data['database-name']}"
+        }
+      },
+      "stringData" : {
+        "database-user" : "${POSTGRESQL_USER}",
+        "database-password" : "${POSTGRESQL_PASSWORD}",
+        "database-name" : "${POSTGRESQL_DATABASE}"
+      }
+    },
+    {
+      "kind": "Service",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.openshift.io/expose-uri": "postgres://{.spec.clusterIP}:{.spec.ports[?(.name==\"postgresql\")].port}"
+        }
+      },
+      "spec": {
+        "ports": [
+          {
+            "name": "postgresql",
+            "protocol": "TCP",
+            "port": 5432,
+            "targetPort": 5432,
+            "nodePort": 0
+          }
+        ],
+        "selector": {
+          "name": "${DATABASE_SERVICE_NAME}"
+        },
+        "type": "ClusterIP",
+        "sessionAffinity": "None"
+      },
+      "status": {
+        "loadBalancer": {}
+      }
+    },
+    {
+      "kind": "PersistentVolumeClaim",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}"
+      },
+      "spec": {
+        "accessModes": [
+          "ReadWriteOnce"
+        ],
+        "resources": {
+          "requests": {
+            "storage": "${VOLUME_CAPACITY}"
+          }
+        }
+      }
+    },
+    {
+      "kind": "DeploymentConfig",
+      "apiVersion": "v1",
+      "metadata": {
+        "name": "${DATABASE_SERVICE_NAME}",
+        "annotations": {
+          "template.alpha.openshift.io/wait-for-ready": "true"
+        }
+      },
+      "spec": {
+        "strategy": {
+          "type": "Recreate"
+        },
+        "triggers": [
+          {
+            "type": "ImageChange",
+            "imageChangeParams": {
+              "automatic": true,
+              "containerNames": [
+                "postgresql"
+              ],
+              "from": {
+                "kind": "ImageStreamTag",
+                "name": "postgresql:${POSTGRESQL_VERSION}",
+                "namespace": "${NAMESPACE}"
+              },
+              "lastTriggeredImage": ""
+            }
+          },
+          {
+            "type": "ConfigChange"
+          }
+        ],
+        "replicas": 1,
+        "selector": {
+          "name": "${DATABASE_SERVICE_NAME}"
+        },
+        "template": {
+          "metadata": {
+            "labels": {
+              "name": "${DATABASE_SERVICE_NAME}"
+            }
+          },
+          "spec": {
+            "containers": [
+              {
+                "name": "postgresql",
+                "image": " ",
+                "ports": [
+                  {
+                    "containerPort": 5432,
+                    "protocol": "TCP"
+                  }
+                ],
+                "readinessProbe": {
+                  "timeoutSeconds": 1,
+                  "initialDelaySeconds": 5,
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                  }
+                },
+                "livenessProbe": {
+                  "timeoutSeconds": 1,
+                  "initialDelaySeconds": 30,
+                  "tcpSocket": {
+                    "port": 5432
+                  }
+                },
+                "env": [
+                  {
+                    "name": "POSTGRESQL_USER",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-user"
+                      }
+                    }
+                  },
+                  {
+                    "name": "POSTGRESQL_PASSWORD",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-password"
+                      }
+                    }
+                  },
+                  {
+                    "name": "POSTGRESQL_DATABASE",
+                    "valueFrom": {
+                      "secretKeyRef" : {
+                        "name" : "${DATABASE_SERVICE_NAME}",
+                        "key" : "database-name"
+                      }
+                    }
+                  }
+                ],
+                "resources": {
+                  "limits": {
+                    "memory": "${MEMORY_LIMIT}"
+                  }
+                },
+                "volumeMounts": [
+                  {
+                    "name": "${DATABASE_SERVICE_NAME}-data",
+                    "mountPath": "/var/lib/pgsql/data"
+                  }
+                ],
+                "terminationMessagePath": "/dev/termination-log",
+                "imagePullPolicy": "IfNotPresent",
+                "capabilities": {},
+                "securityContext": {
+                  "capabilities": {},
+                  "privileged": false
+                }
+              }
+            ],
+            "volumes": [
+              {
+                "name": "${DATABASE_SERVICE_NAME}-data",
+                "persistentVolumeClaim": {
+                  "claimName": "${DATABASE_SERVICE_NAME}"
+                }
+              }
+            ],
+            "restartPolicy": "Always",
+            "dnsPolicy": "ClusterFirst"
+          }
+        }
+      },
+      "status": {}
+    }
+  ],
+  "parameters": [
+    {
+      "name": "MEMORY_LIMIT",
+      "displayName": "Memory Limit",
+      "description": "Maximum amount of memory the container can use.",
+      "value": "512Mi",
+      "required": true
+    },
+    {
+      "name": "NAMESPACE",
+      "displayName": "Namespace",
+      "description": "The OpenShift Namespace where the ImageStream resides.",
+      "value": "openshift"
+    },
+    {
+      "name": "DATABASE_SERVICE_NAME",
+      "displayName": "Database Service Name",
+      "description": "The name of the OpenShift Service exposed for the database.",
+      "value": "postgresql",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_USER",
+      "displayName": "PostgreSQL Connection Username",
+      "description": "Username for PostgreSQL user that will be used for accessing the database.",
+      "generate": "expression",
+      "from": "user[A-Z0-9]{3}",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_PASSWORD",
+      "displayName": "PostgreSQL Connection Password",
+      "description": "Password for the PostgreSQL connection user.",
+      "generate": "expression",
+      "from": "[a-zA-Z0-9]{16}",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_DATABASE",
+      "displayName": "PostgreSQL Database Name",
+      "description": "Name of the PostgreSQL database accessed.",
+      "value": "sampledb",
+      "required": true
+    },
+    {
+      "name": "VOLUME_CAPACITY",
+      "displayName": "Volume Capacity",
+      "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
+      "value": "1Gi",
+      "required": true
+    },
+    {
+      "name": "POSTGRESQL_VERSION",
+      "displayName": "Version of PostgreSQL Image",
+      "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
+      "value": "9.5",
+      "required": true
+    }
+  ]
+}
diff --git a/test/test-lib-openshift.sh b/test/test-lib-openshift.sh
new file mode 120000
index 00000000..f48003b8
--- /dev/null
+++ b/test/test-lib-openshift.sh
@@ -0,0 +1 @@
+../common/test-lib-openshift.sh
\ No newline at end of file

From d685f2b960170d5ca723af33cf9346b560198c30 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 20 Oct 2017 14:24:57 +0200
Subject: [PATCH 031/509] test: fix get_image_id() for dist-git builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Restore IFS as soon as possible, since the IMAGE_NAME variable
might contain colons too and working with variables needs more
care:

    $ IFS=:
    $ IMAGE_NAME=rhscl/postgresql-96-rhel7:1-4
    $ echo $IMAGE_NAME
    rhscl/postgresql-96-rhel7 1-4
    $ echo "$IMAGE_NAME"
    rhscl/postgresql-96-rhel7:1-4

Thanks to Lukáš Zachar for the report.
---
 test/test_lib | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/test_lib b/test/test_lib
index 63b5120d..0bb71210 100644
--- a/test/test_lib
+++ b/test/test_lib
@@ -9,12 +9,15 @@ get_image_id ()
 {
     local old_IFS=$IFS
     local result
+
+    # split "$1" into "$1 $2 .." on colons
     IFS=:
     set -- $1
+    IFS=$old_IFS
     case $2 in
         local)
             # Default to $IMAGE_NAME if it is set since .image-id might not exist
-            echo ${IMAGE_NAME-$(cat "$1"/.image-id)}
+            echo "${IMAGE_NAME-$(cat "$1"/.image-id)}"
             ;;
         remote)
             local version=${1//\./}
@@ -38,7 +41,6 @@ get_image_id ()
             echo "$image"
             ;;
     esac
-    IFS=$old_IFS
 }
 
 data_pagila_create ()

From 1e40ea8a2c3c1fa57d8c7e78b90cccbc6e4f396d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 25 Oct 2017 07:08:15 +0200
Subject: [PATCH 032/509] Drop beta channel after GA

---
 latest/Dockerfile.rhel7 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 575a3879..9eda5d44 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -46,7 +46,6 @@ RUN yum repolist > /dev/null && \
     yum install -y yum-utils gettext && \
     yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-server-rhscl-7-beta-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \

From 33772f2aae9fa24f8b60985cf812b5cc50e270b0 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 25 Oct 2017 11:26:59 +0200
Subject: [PATCH 033/509] Remove workaround for rhbz#1479388

---
 9.4/Dockerfile.rhel7    | 6 +-----
 9.5/Dockerfile.rhel7    | 6 +-----
 latest/Dockerfile.rhel7 | 6 +-----
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index c3a06ee5..0be148b7 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -40,11 +40,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-
-# We need to call 2 (!) yum commands before being able to enable repositories properly
-# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
-RUN yum repolist > /dev/null && \
-    yum install -y yum-utils gettext && \
+RUN yum install -y yum-utils gettext && \
     yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 7d55d914..97cc1230 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -40,11 +40,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-#
-# We need to call 2 (!) yum commands before being able to enable repositories properly
-# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
-RUN yum repolist > /dev/null && \
-    yum install -y yum-utils gettext && \
+RUN yum install -y yum-utils gettext && \
     yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 9eda5d44..6c8c83f6 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -39,11 +39,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
-
-# We need to call 2 (!) yum commands before being able to enable repositories properly
-# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
-RUN yum repolist > /dev/null && \
-    yum install -y yum-utils gettext && \
+RUN yum install -y yum-utils gettext && \
     yum-config-manager --disable \* &> /dev/null && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \

From d1bd752e90e500c3684a2aed79667a34a75307ac Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 30 Oct 2017 12:47:06 +0100
Subject: [PATCH 034/509] pagila.sh: epel7 mirror was reorganized

---
 test/pagila.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/pagila.sh b/test/pagila.sh
index 0f623b17..dd064f84 100755
--- a/test/pagila.sh
+++ b/test/pagila.sh
@@ -7,7 +7,7 @@ die() { echo "$*" >&2 ; exit 1; }
 test -z "$CID" && die "Please specify \$CID variable"
 # test -d common || die "Please run me from git root directory"
 
-pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/p/
+pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/
 pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
 pagila=$pagila_mirror$pagila_base
 pagila_file="$PWD/postgresql-container-pagila.sql"

From c7af02cb54b175f72fad7f645bb92ed6dd037f2c Mon Sep 17 00:00:00 2001
From: Dominika <dhodovsk@redhat.com>
Date: Wed, 18 Oct 2017 09:43:49 +0200
Subject: [PATCH 035/509] Add distgen files for generating Dockerfiles

---
 Dockerfile.template | 83 +++++++++++++++++++++++++++++++++++++++++++++
 Makefile            |  9 +++++
 README.md           |  4 +++
 specs/multispec.yml | 65 +++++++++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+)
 create mode 100644 Dockerfile.template
 create mode 100644 specs/multispec.yml

diff --git a/Dockerfile.template b/Dockerfile.template
new file mode 100644
index 00000000..ece6ead3
--- /dev/null
+++ b/Dockerfile.template
@@ -0,0 +1,83 @@
+FROM {{ config.docker.from }}
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION={{ spec.version }} \
+    POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL {{ spec.version }}" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="{{ spec.openshift_tags }}" \
+      name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
+      com.redhat.component="{{ spec.redhat_component }}" \
+{%- if spec.version in spec.rhscl3_introduced %}
+      version="1"
+{%- else %}
+      version="{{ spec.version }}" \
+      release="1"
+{%- endif %}
+{%- if spec.maintainer %} \
+      maintainer="{{ spec.maintainer }}"
+{%- endif %}
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+{%- if spec.repo_enable_reason %}
+{{ spec.repo_enable_reason }}
+{%- endif %}
+RUN {{ spec.environment_setup }}
+{%- if not spec.stable %}
+{{ spec.staging_repo_setup }}
+{%- endif %}
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS={{ spec.enabled_collection }}
+
+COPY root /
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/Makefile b/Makefile
index 6c25c29e..d1d72c65 100644
--- a/Makefile
+++ b/Makefile
@@ -12,3 +12,12 @@ include common/common.mk
 # Additional upgrade tests.  Not hooked into CI ATM.
 upgrade-tests: $(VERSIONS)
 	test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
+
+DG = /usr/bin/dg
+DG_EXEC = ${DG} --max-passes 25 --template Dockerfile.template --multispec specs/multispec.yml
+
+generate_dockerfiles:
+	for version in ${VERSIONS}; do \
+		${DG_EXEC} --distro centos-7-x86_64.yaml --multispec-selector version=$${version} --output $${version}/Dockerfile; \
+		${DG_EXEC} --distro rhel-7-x86_64.yaml --multispec-selector version=$${version} --output $${version}/Dockerfile.rhel7; \
+	done
diff --git a/README.md b/README.md
index 914daf45..f69fa89b 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,10 @@ Choose either the CentOS7 or RHEL7 based image:
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
 on all provided versions of PostgreSQL.**
 
+Contributing
+--------------------------------
+
+In this repository [distgen](https://github.com/devexp-db/distgen/) is used for generating Dockerfiles. If you'd like update a Dockerfile, please make changes in specs/multispec.yml and/or Dockerfile.template (or other distgen file) and run `make generate_dockerfiles`.
 
 Usage
 ---------------------------------
diff --git a/specs/multispec.yml b/specs/multispec.yml
new file mode 100644
index 00000000..8b997b40
--- /dev/null
+++ b/specs/multispec.yml
@@ -0,0 +1,65 @@
+version: 1
+
+specs:
+  distroinfo:
+    centos:
+      distros:
+        - centos-7-x86_64
+      org: "centos"
+      prod: "centos7"
+      repo_enable_reason: ""
+      environment_setup: yum install -y centos-release-scl-rh && \
+      maintainer: "SoftwareCollections.org <sclorg@redhat.com>"
+      staging_repo_setup: >-4
+              yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
+              echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
+
+    rhel7:
+       distros:
+         - rhel-7-x86_64
+       org: "rhscl"
+       prod: "rhel7"
+       repo_enable_reason: |-
+         # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+         # in base RHEL
+       environment_setup: >-4
+           yum install -y yum-utils gettext && \
+               yum-config-manager --disable \* &> /dev/null && \
+               yum-config-manager --enable rhel-server-rhscl-7-rpms && \
+               yum-config-manager --enable rhel-7-server-rpms && \
+               yum-config-manager --enable rhel-7-server-optional-rpms && \
+       maintainer: ""
+       staging_repo_setup: ""
+       rhscl3_introduced:
+         - "9.6"
+
+  version:
+    "9.4":
+      version: "9.4"
+      prev_version: "9.2"
+      short: "94"
+      pkgs: "rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade"
+      enabled_collection: "rh-postgresql94"
+      openshift_tags: "database,postgresql,postgresql94,rh-postgresql94"
+      redhat_component: "rh-postgresql94-docker"
+      stable: True
+
+    "9.5":
+      version: "9.5"
+      prev_version: "9.4"
+      short: "95"
+      pkgs: "rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server"
+      enabled_collection: "rh-postgresql95"
+      openshift_tags: "database,postgresql,postgresql95,rh-postgresql95"
+      redhat_component: "rh-postgresql95-docker"
+      stable: True
+
+    "9.6":
+      version: "9.6"
+      prev_version: "9.5"
+      short: "96"
+      pkgs: "rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server"
+      enabled_collection: "rh-postgresql96"
+      openshift_tags: "database,postgresql,postgresql96,rh-postgresql96"
+      redhat_component: "rh-postgresql96-docker"
+      stable: False

From 0bb8559415a7b10252baba3550dbb4ff7d4c59a3 Mon Sep 17 00:00:00 2001
From: Dominika <dhodovsk@redhat.com>
Date: Mon, 30 Oct 2017 14:07:58 +0100
Subject: [PATCH 036/509] Generate Dockerfiles using distgen

---
 9.4/Dockerfile          | 4 ++--
 9.4/Dockerfile.rhel7    | 2 +-
 9.5/Dockerfile          | 2 +-
 9.5/Dockerfile.rhel7    | 2 +-
 latest/Dockerfile       | 2 +-
 latest/Dockerfile.rhel7 | 5 +++--
 6 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index cc76b9e1..bd2ec725 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -39,8 +39,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN yum install -y centos-release-scl && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index 0be148b7..eb0f38ff 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -45,7 +45,7 @@ RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql-contrib nss_wrapper postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 61054fe4..f1a2dbc8 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -40,7 +40,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper rh-postgresql94-postgresql-server" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 97cc1230..a7e5eeb9 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -45,7 +45,7 @@ RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql95 rh-postgresql95-postgresql-contrib nss_wrapper rh-postgresql94-postgresql-server" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/latest/Dockerfile b/latest/Dockerfile
index d5e02864..fadd1f64 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -42,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum install -y centos-release-scl-rh && \
     yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
     echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 6c8c83f6..b8b6a094 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -44,8 +44,9 @@ RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql96 rh-postgresql96-postgresql-contrib nss_wrapper rh-postgresql95-postgresql-server" && \
-    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
+
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \

From 24a39b167f27b42412a127870927173775ce21b4 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 25 Oct 2017 09:10:55 +0200
Subject: [PATCH 037/509] document permissions for bind-mounted host
 directories

And also "fix" testsuite to not allow world-writeable access into
volumes.

Fixes: #70, #198
---
 .../share/container-scripts/postgresql/README.md  | 15 ++++++++++++---
 .../share/container-scripts/postgresql/README.md  | 15 ++++++++++++---
 .../share/container-scripts/postgresql/README.md  | 15 ++++++++++++---
 test/run_test                                     |  6 +++---
 4 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index 3546c0d7..a38e2efa 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -33,8 +33,8 @@ $ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL
 This will create a container named `postgresql_database` running PostgreSQL with
 database `db` and user with credentials `user:pass`. Port 5432 will be exposed
 and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
 first run [`initdb`](http://www.postgresql.org/docs/9.4/static/app-initdb.html)
@@ -91,7 +91,7 @@ The following environment variables influence the PostgreSQL configuration file.
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
        PostgreSQL database cluster directory
@@ -101,6 +101,15 @@ You can also set the following mount points by passing the `-v /host:/container`
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
+Typically (unless you use `docker run -u` option) processes in docker container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
 
 Data migration
 ----------------------
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index d4d41e1d..ac5c05a2 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -33,8 +33,8 @@ $ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL
 This will create a container named `postgresql_database` running PostgreSQL with
 database `db` and user with credentials `user:pass`. Port 5432 will be exposed
 and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
 first run [`initdb`](http://www.postgresql.org/docs/9.5/static/app-initdb.html)
@@ -91,7 +91,7 @@ The following environment variables influence the PostgreSQL configuration file.
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
        PostgreSQL database cluster directory
@@ -101,6 +101,15 @@ You can also set the following mount points by passing the `-v /host:/container`
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
+Typically (unless you use `docker run -u` option) processes in docker container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
 
 Data migration
 ----------------------
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 6f24448b..9bb5d352 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -33,8 +33,8 @@ $ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL
 This will create a container named `postgresql_database` running PostgreSQL with
 database `db` and user with credentials `user:pass`. Port 5432 will be exposed
 and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument. This will be
-the PostgreSQL database cluster directory.
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
 first run [`initdb`](http://www.postgresql.org/docs/9.6/static/app-initdb.html)
@@ -91,7 +91,7 @@ The following environment variables influence the PostgreSQL configuration file.
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 
-You can also set the following mount points by passing the `-v /host:/container` flag to Docker.
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
        PostgreSQL database cluster directory
@@ -101,6 +101,15 @@ You can also set the following mount points by passing the `-v /host:/container`
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
+Typically (unless you use `docker run -u` option) processes in docker container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
 
 Data migration
 ----------------------
diff --git a/test/run_test b/test/run_test
index 972f3e5a..012a2154 100755
--- a/test/run_test
+++ b/test/run_test
@@ -55,7 +55,7 @@ function cleanup_volume() {
   local volume_args="-v ${volume_dir}:/var/lib/pgsql/data:Z"
 
   docker stop $cid
-  local rm_cmd='/bin/rm -rf /var/lib/pgsql/data/*'
+  local rm_cmd='/bin/rm -rf /var/lib/pgsql/data/userdata'
   docker run $volume_args --rm $IMAGE_NAME /bin/sh -c "$rm_cmd"
   rmdir ${volume_dir}
 }
@@ -130,8 +130,8 @@ function create_container() {
 function create_volume() {
   local volume_dir
   volume_dir=`mktemp -d --tmpdir pg-testdata.XXXXX`
-  chmod a+rwx ${volume_dir}
-  echo $volume_dir
+  setfacl -m u:26:-wx "$volume_dir"
+  echo "$volume_dir"
 }
 
 function assert_login_access() {

From cefc1ae8e488b9d88e6ff1f4444e51d1b5288ca0 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 7 Sep 2016 22:12:34 +0200
Subject: [PATCH 038/509] simplify working with temporary volume directories

Instead of special-case the master-slave tests by (a) stopping the
container manually, (b) removing cidfile and (c) remove data
directory, from now the volume cleanup is "just" planned to be
executed during regular container cleanup in 'cleanup()'.

Related: container-common-scripts#37
---
 common                            |  2 +-
 test/{test_lib => pg-test-lib.sh} |  0
 test/run_migration_test           |  2 +-
 test/run_test                     | 51 ++++++++++++++++---------------
 test/run_upgrade_test             |  2 +-
 test/test-lib.sh                  |  1 +
 6 files changed, 30 insertions(+), 28 deletions(-)
 rename test/{test_lib => pg-test-lib.sh} (100%)
 create mode 120000 test/test-lib.sh

diff --git a/common b/common
index a8d2885d..a068a12e 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a8d2885de09982496ffd7dd3e9a06296bd95e040
+Subproject commit a068a12e2b73646413c0775687980f2c060e82fa
diff --git a/test/test_lib b/test/pg-test-lib.sh
similarity index 100%
rename from test/test_lib
rename to test/pg-test-lib.sh
diff --git a/test/run_migration_test b/test/run_migration_test
index 4067acd8..654e56e4 100755
--- a/test/run_migration_test
+++ b/test/run_migration_test
@@ -1,7 +1,7 @@
 #! /bin/bash
 
 set -e
-. test/test_lib
+. test/pg-test-lib.sh
 ADMIN_PASSWORD=redhat
 
 test $# -eq 2 || error "two args expected: $0 FROM TO"
diff --git a/test/run_test b/test/run_test
index 012a2154..a1f2f9b8 100755
--- a/test/run_test
+++ b/test/run_test
@@ -9,7 +9,11 @@
 set -exo nounset
 shopt -s nullglob
 
-. test/test_lib
+# library from container-common-scripts
+. test/test-lib.sh
+
+# local library
+. test/pg-test-lib.sh
 
 TEST_LIST="\
 run_upgrade_test
@@ -29,6 +33,7 @@ test -n "${OS-}" || false 'make sure $OS is defined'
 
 CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
+volumes_to_clean=
 
 function cleanup() {
   for cidfile in $CIDFILE_DIR/* ; do
@@ -46,18 +51,22 @@ function cleanup() {
     echo "Done."
   done
   rmdir $CIDFILE_DIR
+
+  ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
 }
 trap cleanup EXIT
 
-function cleanup_volume() {
-  local volume_dir="$1"; shift
-  local cid="$1"; shift
-  local volume_args="-v ${volume_dir}:/var/lib/pgsql/data:Z"
-
-  docker stop $cid
-  local rm_cmd='/bin/rm -rf /var/lib/pgsql/data/userdata'
-  docker run $volume_args --rm $IMAGE_NAME /bin/sh -c "$rm_cmd"
-  rmdir ${volume_dir}
+cleanup_volume_dir ()
+{
+  test ! -d "$1" && : "WARN: cleaned $1 for some reason" && return 0
+  # When we run this test script as non-root (we should?), the PostgreSQL server
+  # within container is still run under 'postgres' user.  It means that, taking
+  # into account 0077 umask of PostgreSQL server, we are unable to remove files
+  # created by server.  That's why we need to let docker escalate the privileges
+  # again.
+  local datadir=/var/lib/pgsql/data
+  docker run -v "$1:$datadir:Z" --rm "$IMAGE_NAME" /bin/sh -c "/bin/rm -rf $datadir/userdata"
+  rmdir "$1"
 }
 
 function get_cid() {
@@ -127,13 +136,15 @@ function create_container() {
   echo "Created container $(cat $cidfile)"
 }
 
-function create_volume() {
-  local volume_dir
+
+create_volume_dir ()
+{
   volume_dir=`mktemp -d --tmpdir pg-testdata.XXXXX`
   setfacl -m u:26:-wx "$volume_dir"
-  echo "$volume_dir"
+  ct_path_append volumes_to_clean "$volume_dir"
 }
 
+
 function assert_login_access() {
   local PGUSER=$1 ; shift
   local PASS=$1 ; shift
@@ -385,7 +396,7 @@ function run_master_restart_test() {
   local master_ip=
   local slave_cids=
 
-  local volume_dir=$(create_volume)
+  create_volume_dir
   local master_args="-v ${volume_dir}:/var/lib/pgsql/data:Z"
 
   # Setup the cluster
@@ -409,9 +420,6 @@ function run_master_restart_test() {
 
   # Check if the replication works
   table_name="t1" test_value_replication
-
-  # Cleanup the volume
-  cleanup_volume $volume_dir $(cat $cidfile)
 }
 
 function run_replication_test() {
@@ -445,7 +453,7 @@ function run_change_password_test() {
   local password='password'
   local admin_password='adminPassword'
 
-  local volume_dir=$(create_volume)
+  create_volume_dir
   local volume_options="-v ${volume_dir}:/var/lib/pgsql/data:Z"
 
   DOCKER_ARGS="
@@ -495,13 +503,6 @@ $volume_options
   assert_login_access 'postgres' "NEW_${admin_password}" true
   assert_login_access 'postgres' ${admin_password} false
 
-  # When we run this test script as non-root (we should?), the PostgreSQL server
-  # within container is still run under 'postgres' user.  It means that, taking
-  # into account 0077 umask of PostgreSQL server, we are unable to remove files
-  # created by server.  That's why we need to let docker escalate the privileges
-  # again.
-  cleanup_volume $volume_dir $(get_cid ${name})
-
   echo "  Success!"
 }
 
diff --git a/test/run_upgrade_test b/test/run_upgrade_test
index cfa47932..e91282bc 100755
--- a/test/run_upgrade_test
+++ b/test/run_upgrade_test
@@ -2,7 +2,7 @@
 
 set -e
 
-. test/test_lib
+. test/pg-test-lib.sh
 
 ADMIN_PASSWORD=redhat
 
diff --git a/test/test-lib.sh b/test/test-lib.sh
new file mode 120000
index 00000000..6ddf876e
--- /dev/null
+++ b/test/test-lib.sh
@@ -0,0 +1 @@
+../common/test-lib.sh
\ No newline at end of file

From 87b7fdc85553a76dba497dbb6b74bce135b839e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20=C4=8C=C3=A1p?= <ficap@redhat.com>
Date: Wed, 8 Nov 2017 15:41:23 +0100
Subject: [PATCH 039/509] Adding Dockerfile.fedora

---
 latest/Dockerfile.fedora | 68 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 latest/Dockerfile.fedora

diff --git a/latest/Dockerfile.fedora b/latest/Dockerfile.fedora
new file mode 100644
index 00000000..8d671bae
--- /dev/null
+++ b/latest/Dockerfile.fedora
@@ -0,0 +1,68 @@
+FROM registry.fedoraproject.org/f26/s2i-base:latest
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    RELEASE=1 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.6" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql96" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="$FCG/$NAME" \
+      version="0" \
+      release="$RELEASE.$DISTTAG" \
+      architecture="$ARCH" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME" \
+      help="/help.1"
+
+EXPOSE 5432
+
+ADD root /
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils python2 " && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]

From 4ea239a6be955507e45e8d79f07e9c5f6be8606f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 16 Nov 2017 11:28:09 +0100
Subject: [PATCH 040/509] Do not base Fedora image onto s2i-base

---
 latest/Dockerfile.fedora | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/latest/Dockerfile.fedora b/latest/Dockerfile.fedora
index 8d671bae..c5c0e3e2 100644
--- a/latest/Dockerfile.fedora
+++ b/latest/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM registry.fedoraproject.org/f26/s2i-base:latest
+FROM registry.fedoraproject.org/fedora:26
 
 # PostgreSQL image for OpenShift.
 # Volumes:

From 09f0a1588649fa222e9d7270f285dabbcba0711f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Abd=C3=BClhamit=20Yilmaz?= <mr.yilmaz@gmx.de>
Date: Mon, 27 Nov 2017 14:29:44 +0100
Subject: [PATCH 041/509] Remove code duplications in set_pgdata

---
 9.2/root/usr/share/container-scripts/postgresql/common.sh | 8 +++-----
 9.4/root/usr/share/container-scripts/postgresql/common.sh | 8 +++-----
 9.5/root/usr/share/container-scripts/postgresql/common.sh | 8 +++-----
 .../root/usr/share/container-scripts/postgresql/common.sh | 8 +++-----
 4 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/9.2/root/usr/share/container-scripts/postgresql/common.sh b/9.2/root/usr/share/container-scripts/postgresql/common.sh
index 9608bcc6..367ec664 100644
--- a/9.2/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.2/root/usr/share/container-scripts/postgresql/common.sh
@@ -189,19 +189,17 @@ function set_passwords() {
 
 function set_pgdata ()
 {
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
   # backwards compatibility case, we used to put the data here,
   # move it into our new expected location (userdata)
   if [ -e ${HOME}/data/PG_VERSION ]; then
-    mkdir -p "${HOME}/data/userdata"
     pushd "${HOME}/data"
     # move everything except the userdata directory itself, into the userdata directory.
     mv !(userdata) "userdata"
     popd
-  else 
-    # create a subdirectory that the user owns
-    mkdir -p "${HOME}/data/userdata"
   fi
-  export PGDATA=$HOME/data/userdata
   # ensure sane perms for postgresql startup
   chmod 700 "$PGDATA"
 }
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index 177cfe4e..cd1aed8f 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -224,19 +224,17 @@ migrate_db ()
 
 function set_pgdata ()
 {
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
   # backwards compatibility case, we used to put the data here,
   # move it into our new expected location (userdata)
   if [ -e ${HOME}/data/PG_VERSION ]; then
-    mkdir -p "${HOME}/data/userdata"
     pushd "${HOME}/data"
     # move everything except the userdata directory itself, into the userdata directory.
     mv !(userdata) "userdata"
     popd
-  else 
-    # create a subdirectory that the user owns
-    mkdir -p "${HOME}/data/userdata"
   fi
-  export PGDATA=$HOME/data/userdata
   # ensure sane perms for postgresql startup
   chmod 700 "$PGDATA"
 }
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index db37220a..14413ea4 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -224,19 +224,17 @@ migrate_db ()
 
 function set_pgdata ()
 {
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
   # backwards compatibility case, we used to put the data here,
   # move it into our new expected location (userdata)
   if [ -e ${HOME}/data/PG_VERSION ]; then
-    mkdir -p "${HOME}/data/userdata"
     pushd "${HOME}/data"
     # move everything except the userdata directory itself, into the userdata directory.
     mv !(userdata) "userdata"
     popd
-  else 
-    # create a subdirectory that the user owns
-    mkdir -p "${HOME}/data/userdata"
   fi
-  export PGDATA=$HOME/data/userdata
   # ensure sane perms for postgresql startup
   chmod 700 "$PGDATA"
 }
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index d4b2f501..5f13d5c7 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -224,19 +224,17 @@ migrate_db ()
 
 function set_pgdata ()
 {
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
   # backwards compatibility case, we used to put the data here,
   # move it into our new expected location (userdata)
   if [ -e ${HOME}/data/PG_VERSION ]; then
-    mkdir -p "${HOME}/data/userdata"
     pushd "${HOME}/data"
     # move everything except the userdata directory itself, into the userdata directory.
     mv !(userdata) "userdata"
     popd
-  else 
-    # create a subdirectory that the user owns
-    mkdir -p "${HOME}/data/userdata"
   fi
-  export PGDATA=$HOME/data/userdata
   # ensure sane perms for postgresql startup
   chmod 700 "$PGDATA"
 }

From 4321c9e0dfd2743d2917c71ad6c280168f8b0d03 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 24 Nov 2017 16:41:42 +0100
Subject: [PATCH 042/509] tests: do not set default OS

---
 test/pg-test-lib.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 0bb71210..dc8d2b2c 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -1,4 +1,3 @@
-: ${OS=centos7}
 DEBUG=false
 
 info  () { echo >&2 " * $*" ; }

From 036810abbc093c0fa3fad6f5b1037164df0e896e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 1 Dec 2017 15:41:47 +0100
Subject: [PATCH 043/509] tests: add run-openshift template tests (#209)

* tests: add run-openshift template tests

Resolves: #204
---
 common                                  |  2 +-
 test/postgresql-ephemeral-template.json |  1 +
 test/run-openshift                      | 88 +++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
 create mode 120000 test/postgresql-ephemeral-template.json
 create mode 100755 test/run-openshift

diff --git a/common b/common
index a068a12e..1de313c6 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a068a12e2b73646413c0775687980f2c060e82fa
+Subproject commit 1de313c67ebac09fb375dd77f7fb9b0e62f52774
diff --git a/test/postgresql-ephemeral-template.json b/test/postgresql-ephemeral-template.json
new file mode 120000
index 00000000..d37d8892
--- /dev/null
+++ b/test/postgresql-ephemeral-template.json
@@ -0,0 +1 @@
+../examples/postgresql-ephemeral-template.json
\ No newline at end of file
diff --git a/test/run-openshift b/test/run-openshift
new file mode 100755
index 00000000..89c1750d
--- /dev/null
+++ b/test/run-openshift
@@ -0,0 +1,88 @@
+#!/bin/bash
+#
+# Test the Postgresql image in OpenShift.
+#
+# IMAGE_NAME specifies a name of the candidate image used for testing.
+# The image has to be available before this script is executed.
+#
+
+THISDIR=$(dirname ${BASH_SOURCE[0]})
+
+source "$THISDIR"/test-lib-openshift.sh
+
+set -exo nounset
+
+function check_postgresql_os_service_connection() {
+  local util_image_name=$1 ; shift
+  local service_name=$1 ; shift
+  local user=$1 ; shift
+  local pass=$1 ; shift
+  local database=$1 ; shift
+  local timeout=${1:-60} ; shift || :
+  local pod_ip=$(ct_os_get_service_ip ${service_name})
+
+  : "  Service ${service_name} check ..."
+
+  local cmd="PGPASSWORD=${pass} pg_isready -t 15 -h ${pod_ip} -U ${user} -d ${database}"
+  local expected_value='accepting connections'
+  local output
+  local ret
+  SECONDS=0
+
+  echo -n "Waiting for ${service_name} service becoming ready ..."
+  while true ; do
+    output=$(docker run --rm ${util_image_name} bash -c "${cmd}" || :)
+    echo "${output}" | grep -qe "${expected_value}" && ret=0 || ret=1
+    if [ ${ret} -eq 0 ] ; then
+      echo " PASS"
+      return 0
+    fi
+    echo -n "."
+    [ ${SECONDS} -gt ${timeout} ] && break
+    sleep 3
+  done
+  echo " FAIL"
+  return 1
+}
+
+function test_postgresql_pure_image() {
+  local image_name=$1
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=${image_name_no_namespace}
+
+  ct_os_new_project
+  ct_os_upload_image "${image_name}"
+
+  ct_os_deploy_pure_image "${image_name}" \
+                          --name "${service_name}" \
+                          --env POSTGRESQL_ADMIN_PASSWORD=test
+
+  ct_os_wait_pod_ready "${service_name}" 60
+  check_postgresql_os_service_connection "${image_name}" "${service_name}" postgres test postgres
+
+  ct_os_delete_project
+}
+
+function test_postgresql_template() {
+  local image_name=${1:-centos/postgresql-96-centos7}
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=${image_name_no_namespace}
+
+  ct_os_new_project
+  ct_os_upload_image "${image_name}"
+
+  ct_os_deploy_template_image ${THISDIR}/postgresql-ephemeral-template.json \
+                              DATABASE_SERVICE_NAME="${service_name}" \
+                              POSTGRESQL_USER=testu \
+                              POSTGRESQL_PASSWORD=testp \
+                              POSTGRESQL_DATABASE=testdb
+
+  ct_os_wait_pod_ready "${service_name}" 60
+  check_postgresql_os_service_connection "${image_name}" "${service_name}" testu testp testdb
+
+  ct_os_delete_project
+}
+
+ct_os_cluster_up
+test_postgresql_pure_image ${IMAGE_NAME}
+test_postgresql_template ${IMAGE_NAME}

From 8230ed1221225ed9b9d1706810c1f1f228931856 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 7 Dec 2017 12:03:02 +0100
Subject: [PATCH 044/509] templates: use pg_isready as liveness probe (#206)

* templates: use pg_isready as liveness probe

* templates: Use 9.6 as the default version

* tests: use local namespace instead of openshift

* tests: set the image version for the template

* tests: explicitly state tag during pure image test

* Update to latest commons
---
 common                                       |  2 +-
 examples/postgresql-ephemeral-template.json  | 16 ++++++++--------
 examples/postgresql-persistent-template.json | 16 ++++++++--------
 examples/replica/postgresql_replica.json     | 18 +++++++++---------
 test/run-openshift                           | 17 ++++++++++++-----
 5 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/common b/common
index 1de313c6..fd9b209b 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1de313c67ebac09fb375dd77f7fb9b0e62f52774
+Subproject commit fd9b209b31143366654cd9b9c8e8b87c9a71a29e
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index 849c9d83..5ff29ba4 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -5,7 +5,7 @@
     "name": "postgresql-ephemeral",
     "annotations": {
       "openshift.io/display-name": "PostgreSQL (Ephemeral)",
-      "description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
+      "description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
       "iconClass": "icon-postgresql",
       "tags": "database,postgresql",
       "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is not stored on persistent storage, so any restart of the service will result in all data being lost.  The database name, username, and password are chosen via parameters when provisioning this service.",
@@ -14,7 +14,7 @@
       "template.openshift.io/support-url": "https://access.redhat.com"
     }
   },
-  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
+  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",
   "labels": {
     "template": "postgresql-ephemeral-template"
   },
@@ -127,11 +127,11 @@
                   }
                 },
                 "livenessProbe": {
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
+                  },
                   "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30,
-                  "tcpSocket": {
-                    "port": 5432
-                  }
+                  "initialDelaySeconds": 30
                 },
                 "env": [
                   {
@@ -245,8 +245,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
-      "value": "9.5",
+      "description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
+      "value": "9.6",
       "required": true
     }
   ]
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index b622baa0..b524e369 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -5,7 +5,7 @@
     "name": "postgresql-persistent",
     "annotations": {
       "openshift.io/display-name": "PostgreSQL (Persistent)",
-      "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
+      "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
       "iconClass": "icon-postgresql",
       "tags": "database,postgresql",
       "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is stored on persistent storage.  The database name, username, and password are chosen via parameters when provisioning this service.",
@@ -14,7 +14,7 @@
       "template.openshift.io/support-url": "https://access.redhat.com"
     }
   },
-  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
+  "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",
   "labels": {
     "template": "postgresql-persistent-template"
   },
@@ -144,11 +144,11 @@
                   }
                 },
                 "livenessProbe": {
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
+                  },
                   "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30,
-                  "tcpSocket": {
-                    "port": 5432
-                  }
+                  "initialDelaySeconds": 30
                 },
                 "env": [
                   {
@@ -269,8 +269,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
-      "value": "9.5",
+      "description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
+      "value": "9.6",
       "required": true
     }
   ]
diff --git a/examples/replica/postgresql_replica.json b/examples/replica/postgresql_replica.json
index 008e3571..eb9bf4f6 100644
--- a/examples/replica/postgresql_replica.json
+++ b/examples/replica/postgresql_replica.json
@@ -71,7 +71,7 @@
       "name": "IMAGESTREAMTAG",
       "displayName": "ImageStreamTag",
       "description": "The OpenShift ImageStreamTag to use for PostgreSQL.",
-      "value": "postgresql:9.5"
+      "value": "postgresql:9.6"
     },
     {
       "name": "NAMESPACE",
@@ -211,11 +211,11 @@
                   }
                 },
                 "livenessProbe": {
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
+                  },
                   "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30,
-                  "tcpSocket": {
-                    "port": 5432
-                  }
+                  "initialDelaySeconds": 30
                 },
                 "env": [
                   {
@@ -322,11 +322,11 @@
                   }
                 },
                 "livenessProbe": {
+                  "exec": {
+                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
+                  },
                   "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30,
-                  "tcpSocket": {
-                    "port": 5432
-                  }
+                  "initialDelaySeconds": 30
                 },
                 "env": [
                   {
diff --git a/test/run-openshift b/test/run-openshift
index 89c1750d..651f59b4 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -12,6 +12,9 @@ source "$THISDIR"/test-lib-openshift.sh
 
 set -exo nounset
 
+test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
+test -n "${VERSION-}" || false 'make sure $VERSION is defined'
+
 function check_postgresql_os_service_connection() {
   local util_image_name=$1 ; shift
   local service_name=$1 ; shift
@@ -52,8 +55,10 @@ function test_postgresql_pure_image() {
 
   ct_os_new_project
   ct_os_upload_image "${image_name}"
+  # Create a specific imagestream tag for the image so that oc cannot use anything else
+  ct_os_upload_image "${image_name}" "$image_name_no_namespace:testing"
 
-  ct_os_deploy_pure_image "${image_name}" \
+  ct_os_deploy_pure_image "$image_name_no_namespace:testing" \
                           --name "${service_name}" \
                           --env POSTGRESQL_ADMIN_PASSWORD=test
 
@@ -69,9 +74,11 @@ function test_postgresql_template() {
   local service_name=${image_name_no_namespace}
 
   ct_os_new_project
-  ct_os_upload_image "${image_name}"
+  ct_os_upload_image "${image_name}" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image ${THISDIR}/postgresql-ephemeral-template.json \
+  ct_os_deploy_template_image "$THISDIR/postgresql-ephemeral-template.json" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="${service_name}" \
                               POSTGRESQL_USER=testu \
                               POSTGRESQL_PASSWORD=testp \
@@ -84,5 +91,5 @@ function test_postgresql_template() {
 }
 
 ct_os_cluster_up
-test_postgresql_pure_image ${IMAGE_NAME}
-test_postgresql_template ${IMAGE_NAME}
+test_postgresql_pure_image "${IMAGE_NAME}"
+test_postgresql_template "${IMAGE_NAME}"

From 80d6dae6fd5c757a509e62867c4b3cd5964730a8 Mon Sep 17 00:00:00 2001
From: Corey Daley <cdaley@redhat.com>
Date: Wed, 13 Dec 2017 07:58:24 -0500
Subject: [PATCH 045/509] Adding server started message to run scripts

Adding server started message to run scripts
since the last message displayed is always
server stopped which can be confusing for users
---
 9.2/root/usr/bin/run-postgresql          | 1 +
 9.2/root/usr/bin/run-postgresql-slave    | 1 +
 9.4/root/usr/bin/run-postgresql          | 1 +
 9.4/root/usr/bin/run-postgresql-slave    | 1 +
 9.5/root/usr/bin/run-postgresql          | 1 +
 9.5/root/usr/bin/run-postgresql-slave    | 1 +
 latest/root/usr/bin/run-postgresql       | 1 +
 latest/root/usr/bin/run-postgresql-slave | 1 +
 8 files changed, 8 insertions(+)

diff --git a/9.2/root/usr/bin/run-postgresql b/9.2/root/usr/bin/run-postgresql
index 1c8de780..d14d72ef 100755
--- a/9.2/root/usr/bin/run-postgresql
+++ b/9.2/root/usr/bin/run-postgresql
@@ -25,4 +25,5 @@ set_passwords
 pg_ctl stop
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/9.2/root/usr/bin/run-postgresql-slave b/9.2/root/usr/bin/run-postgresql-slave
index 5d42d0d4..be327a93 100755
--- a/9.2/root/usr/bin/run-postgresql-slave
+++ b/9.2/root/usr/bin/run-postgresql-slave
@@ -33,4 +33,5 @@ export MASTER_FQDN=$(postgresql_master_addr)
 initialize_replica
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
index af6ac4a1..a5ad5fa1 100755
--- a/9.4/root/usr/bin/run-postgresql
+++ b/9.4/root/usr/bin/run-postgresql
@@ -31,4 +31,5 @@ set_passwords
 pg_ctl stop
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/9.4/root/usr/bin/run-postgresql-slave b/9.4/root/usr/bin/run-postgresql-slave
index 5d42d0d4..be327a93 100755
--- a/9.4/root/usr/bin/run-postgresql-slave
+++ b/9.4/root/usr/bin/run-postgresql-slave
@@ -33,4 +33,5 @@ export MASTER_FQDN=$(postgresql_master_addr)
 initialize_replica
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
index af6ac4a1..a5ad5fa1 100755
--- a/9.5/root/usr/bin/run-postgresql
+++ b/9.5/root/usr/bin/run-postgresql
@@ -31,4 +31,5 @@ set_passwords
 pg_ctl stop
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-slave b/9.5/root/usr/bin/run-postgresql-slave
index 5d42d0d4..be327a93 100755
--- a/9.5/root/usr/bin/run-postgresql-slave
+++ b/9.5/root/usr/bin/run-postgresql-slave
@@ -33,4 +33,5 @@ export MASTER_FQDN=$(postgresql_master_addr)
 initialize_replica
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
index af6ac4a1..a5ad5fa1 100755
--- a/latest/root/usr/bin/run-postgresql
+++ b/latest/root/usr/bin/run-postgresql
@@ -31,4 +31,5 @@ set_passwords
 pg_ctl stop
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"
diff --git a/latest/root/usr/bin/run-postgresql-slave b/latest/root/usr/bin/run-postgresql-slave
index 5d42d0d4..be327a93 100755
--- a/latest/root/usr/bin/run-postgresql-slave
+++ b/latest/root/usr/bin/run-postgresql-slave
@@ -33,4 +33,5 @@ export MASTER_FQDN=$(postgresql_master_addr)
 initialize_replica
 
 unset_env_vars
+echo "Starting server..."
 exec postgres "$@"

From 850797c2bbed1a4d0b235f7e0e74fef494992a81 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 15 Dec 2017 14:49:27 +0100
Subject: [PATCH 046/509] tests: Add image update test to run-openshift (#216)

* tests: Add image update test to run-openshift
---
 test/postgresql-persistent-template.json |  1 +
 test/run-openshift                       | 88 ++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
 create mode 120000 test/postgresql-persistent-template.json

diff --git a/test/postgresql-persistent-template.json b/test/postgresql-persistent-template.json
new file mode 120000
index 00000000..8556e17f
--- /dev/null
+++ b/test/postgresql-persistent-template.json
@@ -0,0 +1 @@
+../examples/postgresql-persistent-template.json
\ No newline at end of file
diff --git a/test/run-openshift b/test/run-openshift
index 651f59b4..ef53977c 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -14,6 +14,46 @@ set -exo nounset
 
 test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
+test -n "${OS-}" || false 'make sure $OS is defined'
+
+function insert_postgresql_data() {
+  local image_name=$1 ; shift
+  local user=$1 ; shift
+  local pass=$1 ; shift
+  local database=$1 ; shift
+  local pod_ip=$1; shift
+
+  : "Inserting data into the database"
+  local cmd="PGPASSWORD=$pass psql -c \"CREATE TABLE testing (a integer); INSERT INTO testing VALUES (42);\""
+  local cmd_args="-h $pod_ip -U $user -d $database"
+  docker run --rm "$image_name" bash -c "$cmd $cmd_args"
+}
+
+function check_postgresql_data() {
+  local image_name=$1 ; shift
+  local user=$1 ; shift
+  local pass=$1 ; shift
+  local database=$1 ; shift
+  local pod_ip=$1; shift
+  local timeout=${1:-60}
+  SECONDS=0
+
+  : "Checking whether the data can be accessed"
+  local cmd="PGPASSWORD=$pass psql -c \"select * from testing;\""
+  local cmd_args="-h $pod_ip -U $user -d $database"
+  while true ; do
+    result=$(docker run --rm "$image_name" bash -c "$cmd -At $cmd_args")
+    if [ "$result" = "42" ]; then
+      echo " PASS"
+      return 0
+    fi
+    echo -n "."
+    [ $SECONDS -gt $timeout ] && break
+    sleep 3
+  done
+  echo " FAIL"
+  return 1
+}
 
 function check_postgresql_os_service_connection() {
   local util_image_name=$1 ; shift
@@ -90,6 +130,54 @@ function test_postgresql_template() {
   ct_os_delete_project
 }
 
+function test_postgresql_update() {
+  local image_name=$1
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=$image_name_no_namespace
+  local user="testu" pass="testp" db="testdb"
+  local registry="" old_image="" pod_ip=""
+
+  case $OS in
+  rhel7)
+      registry=registry.access.redhat.com
+      ;;
+  centos7)
+      registry=docker.io
+      ;;
+  esac
+
+  old_image="$registry/$image_name"
+  docker pull "$old_image" 2>/dev/null
+
+  ct_os_new_project
+  ct_os_upload_image "$old_image" "postgresql:$VERSION"
+
+  ct_os_deploy_template_image "$THISDIR/postgresql-persistent-template.json" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
+                              DATABASE_SERVICE_NAME="$service_name" \
+                              POSTGRESQL_USER="$user" \
+                              POSTGRESQL_PASSWORD="$pass" \
+                              POSTGRESQL_DATABASE="$db"
+
+  ct_os_wait_pod_ready "${service_name}" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  pod_ip=$(ct_os_get_service_ip "$service_name")
+  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+
+  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  : "Waiting for a few seconds while the pods get restarted"
+  sleep 5
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+  ct_os_delete_project
+}
+
 ct_os_cluster_up
 test_postgresql_pure_image "${IMAGE_NAME}"
 test_postgresql_template "${IMAGE_NAME}"
+test_postgresql_update "${IMAGE_NAME}"

From b66f12fdc924c49b3f9b2f657546365f15d9bf93 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 18 Dec 2017 12:10:15 +0100
Subject: [PATCH 047/509] Various small documentation related changes (#218)

* Various small documentation related changes

Use maintainer label consistently
Few edits in top-level README
Using usage label and command

* Use latest/ for 9.6 version so it looks correct on github
---
 9.4/Dockerfile            |  2 +-
 9.4/Dockerfile.rhel7      |  3 ++-
 9.4/root/usr/bin/usage    |  4 ++++
 9.5/Dockerfile            |  2 +-
 9.5/Dockerfile.rhel7      |  3 ++-
 9.5/root/usr/bin/usage    |  4 ++++
 README.md                 | 30 ++++++++++++++++++++----------
 latest/Dockerfile         |  2 +-
 latest/Dockerfile.rhel7   |  4 +++-
 latest/root/usr/bin/usage |  4 ++++
 10 files changed, 42 insertions(+), 16 deletions(-)
 create mode 100755 9.4/root/usr/bin/usage
 create mode 100755 9.5/root/usr/bin/usage
 create mode 100755 latest/root/usr/bin/usage

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index bd2ec725..9ccb14e5 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -29,7 +29,7 @@ LABEL summary=$SUMMARY \
       name="centos/postgresql-94-centos7" \
       com.redhat.component="rh-postgresql94-docker" \
       version="9.4" \
-      release="1" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-94-centos7" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index eb0f38ff..f230746b 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -29,7 +29,8 @@ LABEL summary=$SUMMARY \
       name="rhscl/postgresql-94-rhel7" \
       com.redhat.component="rh-postgresql94-docker" \
       version="9.4" \
-      release="1"
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-94-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
diff --git a/9.4/root/usr/bin/usage b/9.4/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/9.4/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index f1a2dbc8..3000023c 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -29,7 +29,7 @@ LABEL summary=$SUMMARY \
       name="centos/postgresql-95-centos7" \
       com.redhat.component="rh-postgresql95-docker" \
       version="9.5" \
-      release="1" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-95-centos7" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index a7e5eeb9..d2f9c7d5 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -29,7 +29,8 @@ LABEL summary=$SUMMARY \
       name="rhscl/postgresql-95-rhel7" \
       com.redhat.component="rh-postgresql95-docker" \
       version="9.5" \
-      release="1"
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
diff --git a/9.5/root/usr/bin/usage b/9.5/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/9.5/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/README.md b/README.md
index f69fa89b..944f01b3 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ PostgreSQL Docker images
 ========================
 
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
-Users can choose between RHEL and CentOS based images.
+Users can choose between RHEL, Fedora and CentOS based images.
 
 For more information about using these images with OpenShift, please see the
 official [OpenShift Documentation](https://docs.openshift.org/latest/using_images/db_images/postgresql.html).
@@ -18,6 +18,7 @@ Versions
 PostgreSQL versions currently provided are:
 * [postgresql-9.4](9.4)
 * [postgresql-9.5](9.5)
+* [postgresql-9.6](latest)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -32,21 +33,27 @@ Choose either the CentOS7 or RHEL7 based image:
 
 *  **RHEL7 based image**
 
+    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7).
+    To download it run:
+    ```
+    docker pull registry.access.redhat.com/rhscl/postgresql-96-rhel7
+    ```
+
     To build a RHEL7 based image, you need to run Docker build on a properly
     subscribed RHEL machine.
 
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONS=9.5
+    $ make build TARGET=rhel7 VERSIONiS=9.6
     ```
 
 *  **CentOS7 based image**
 
-    This image is available on DockerHub. To download it run:
+    These images are available on DockerHub. To download it run:
 
     ```
-    $ docker pull centos/postgresql-95-centos7
+    $ docker pull centos/postgresql-96-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -54,7 +61,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSIONS=9.5
+    $ make build TARGET=centos7 VERSIONS=9.6
     ```
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
@@ -69,10 +76,13 @@ Usage
 ---------------------------------
 
 For information about usage of Dockerfile for PostgreSQL 9.4,
-see [usage documentation](9.4/README.md).
+see [usage documentation](9.4).
 
 For information about usage of Dockerfile for PostgreSQL 9.5,
-see [usage documentation](9.5/README.md).
+see [usage documentation](9.5).
+
+For information about usage of Dockerfile for PostgreSQL 9.6,
+see [usage documentation](latest).
 
 Test
 ---------------------------------
@@ -89,19 +99,19 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSIONS=9.5
+    $ make test TARGET=rhel7 VERSIONS=9.6
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSIONS=9.5
+    $ make test TARGET=centos7 VERSIONS=9.6
     ```
 +By using the `TEST_CASE` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSIONS=9.5 TEST_CASE="run_general_tests run_replication_test"
+    $ make test VERSIONS=9.6 TEST_CASE="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
diff --git a/latest/Dockerfile b/latest/Dockerfile
index fadd1f64..7ed2499b 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -29,7 +29,7 @@ LABEL summary=$SUMMARY \
       name="centos/postgresql-96-centos7" \
       com.redhat.component="rh-postgresql96-docker" \
       version="9.6" \
-      release="1" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-96-centos7" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index b8b6a094..c35763db 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -28,7 +28,9 @@ LABEL summary=$SUMMARY \
       io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
       name="rhscl/postgresql-96-rhel7" \
       com.redhat.component="rh-postgresql96-docker" \
-      version="1"
+      version="1" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
diff --git a/latest/root/usr/bin/usage b/latest/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/latest/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+

From 732ad93a6ac8e3a9de1d14378128f115303f5432 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 14 Dec 2017 10:40:04 +0100
Subject: [PATCH 048/509] tests: link to examples directory instead to specific
 templates

---
 test/examples                            | 1 +
 test/postgresql-ephemeral-template.json  | 1 -
 test/postgresql-persistent-template.json | 1 -
 test/run-openshift                       | 5 +++--
 4 files changed, 4 insertions(+), 4 deletions(-)
 create mode 120000 test/examples
 delete mode 120000 test/postgresql-ephemeral-template.json
 delete mode 120000 test/postgresql-persistent-template.json

diff --git a/test/examples b/test/examples
new file mode 120000
index 00000000..785887f7
--- /dev/null
+++ b/test/examples
@@ -0,0 +1 @@
+../examples/
\ No newline at end of file
diff --git a/test/postgresql-ephemeral-template.json b/test/postgresql-ephemeral-template.json
deleted file mode 120000
index d37d8892..00000000
--- a/test/postgresql-ephemeral-template.json
+++ /dev/null
@@ -1 +0,0 @@
-../examples/postgresql-ephemeral-template.json
\ No newline at end of file
diff --git a/test/postgresql-persistent-template.json b/test/postgresql-persistent-template.json
deleted file mode 120000
index 8556e17f..00000000
--- a/test/postgresql-persistent-template.json
+++ /dev/null
@@ -1 +0,0 @@
-../examples/postgresql-persistent-template.json
\ No newline at end of file
diff --git a/test/run-openshift b/test/run-openshift
index ef53977c..61e91151 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -7,6 +7,7 @@
 #
 
 THISDIR=$(dirname ${BASH_SOURCE[0]})
+TEMPLATES="$THISDIR/examples"
 
 source "$THISDIR"/test-lib-openshift.sh
 
@@ -116,7 +117,7 @@ function test_postgresql_template() {
   ct_os_new_project
   ct_os_upload_image "${image_name}" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$THISDIR/postgresql-ephemeral-template.json" \
+  ct_os_deploy_template_image "$TEMPLATES/postgresql-ephemeral-template.json" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="${service_name}" \
@@ -152,7 +153,7 @@ function test_postgresql_update() {
   ct_os_new_project
   ct_os_upload_image "$old_image" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$THISDIR/postgresql-persistent-template.json" \
+  ct_os_deploy_template_image "$TEMPLATES/postgresql-persistent-template.json" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="$service_name" \

From b7bac1142e05d6dfc7d0258a6c3ce440d0a39de5 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 14 Dec 2017 10:58:07 +0100
Subject: [PATCH 049/509] tests: Add replication test to run-openshift

---
 common             |  2 +-
 test/run-openshift | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/common b/common
index fd9b209b..a6401ffa 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit fd9b209b31143366654cd9b9c8e8b87c9a71a29e
+Subproject commit a6401ffa47f0dcceef0f582541ed9339cbcb4956
diff --git a/test/run-openshift b/test/run-openshift
index 61e91151..b67b3224 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -56,6 +56,7 @@ function check_postgresql_data() {
   return 1
 }
 
+
 function check_postgresql_os_service_connection() {
   local util_image_name=$1 ; shift
   local service_name=$1 ; shift
@@ -178,7 +179,76 @@ function test_postgresql_update() {
   ct_os_delete_project
 }
 
+function test_postgresql_replication() {
+  local image_name=$1
+  local image_name_no_namespace=${image_name##*/}
+  local master_service_name=${image_name_no_namespace}-master
+  local slave_service_name=${image_name_no_namespace}-slave
+  local istag="postgresql:$VERSION"
+  local user="testu" pass="testp" db="testdb"
+  local master_name="" master_ip="" slave_name="" slave_ip=""
+
+  ct_os_new_project
+  ct_os_upload_image "${image_name}" "$istag"
+
+  ct_os_deploy_template_image "$TEMPLATES/replica/postgresql_replica.json" \
+                              NAMESPACE="$(oc project -q)" \
+                              IMAGESTREAMTAG="$istag" \
+                              POSTGRESQL_MASTER_SERVICE_NAME="$master_service_name" \
+                              POSTGRESQL_SLAVE_SERVICE_NAME="$slave_service_name" \
+                              POSTGRESQL_USER=testu \
+                              POSTGRESQL_PASSWORD=testp \
+                              POSTGRESQL_DATABASE=testdb
+
+  ct_os_wait_pod_ready "$master_service_name" 60
+  ct_os_wait_pod_ready "$slave_service_name" 60
+
+  # Force unused rc removal as we do not need rollbacks during testing
+  oc patch "dc/$master_service_name" -p '{"spec":{"revisionHistoryLimit":0}}'
+  oc patch "dc/$slave_service_name" -p '{"spec":{"revisionHistoryLimit":0}}'
+
+  master_name=$(ct_os_get_pod_name "$master_service_name")
+  slave_name=$(ct_os_get_pod_name "$slave_service_name")
+  master_ip=$(ct_os_get_pod_ip "$master_name")
+  slave_ip=$(ct_os_get_pod_ip "$slave_name")
+  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$master_ip"
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
+
+  : "Changing POSTGRESQL_PASSWORD for master and slave"
+  pass=redhat
+  oc set env "dc/$master_service_name" -e POSTGRESQL_PASSWORD="$pass"
+  oc set env "dc/$slave_service_name" -e POSTGRESQL_PASSWORD="$pass"
+  ct_os_wait_pod_ready "$master_service_name-2" 60
+  ct_os_wait_pod_ready "$slave_service_name-2" 60
+  # We need to get new pod names and IPs
+  master_name=$(ct_os_get_pod_name "$master_service_name")
+  slave_name=$(ct_os_get_pod_name "$slave_service_name")
+  master_ip=$(ct_os_get_pod_ip "$master_name")
+  slave_ip=$(ct_os_get_pod_ip "$slave_name")
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$master_ip"
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
+
+  : "Redeploying slave node"
+  oc deploy "$slave_service_name" --latest
+  ct_os_wait_pod_ready "$slave_service_name-3" 60
+  slave_name=$(ct_os_get_pod_name "$slave_service_name")
+  slave_ip=$(ct_os_get_pod_ip "$slave_name")
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
+
+  : "Scaling slaves to 2"
+  oc scale --replicas 2 "dc/$slave_service_name"
+  ct_os_wait_rc_ready "$slave_service_name" 60
+  slave_name=$(ct_os_get_pod_name "$slave_service_name")
+  for slave in $slave_name; do
+    slave_ip=$(ct_os_get_pod_ip "$slave")
+    check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
+  done
+
+  ct_os_delete_project
+}
+
 ct_os_cluster_up
 test_postgresql_pure_image "${IMAGE_NAME}"
 test_postgresql_template "${IMAGE_NAME}"
 test_postgresql_update "${IMAGE_NAME}"
+test_postgresql_replication "${IMAGE_NAME}"

From 4a4be823437944448138ad8fd6d463d8d09f317c Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 19 Dec 2017 14:49:44 +0100
Subject: [PATCH 050/509] Fix typo in top-level README.md

SSIA
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 944f01b3..88fed7f8 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONiS=9.6
+    $ make build TARGET=rhel7 VERSIONS=9.6
     ```
 
 *  **CentOS7 based image**

From fc33d8f90d8a3f4dbe8a1c8ab48488c4c5e21aea Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 2 Jan 2018 13:49:05 +0100
Subject: [PATCH 051/509] tests: add redeployment tests for ephemeral and
 persistent templates (#219)

* tests: add redeployment tests for ephemeral and persistent templates

* make assert_cmd_fails more readable
---
 test/run-openshift | 85 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/test/run-openshift b/test/run-openshift
index b67b3224..d47eda8d 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -17,6 +17,15 @@ test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
+function assert_cmd_fails() {
+  if eval "$@" &>/dev/null; then
+    echo " FAIL"
+    return 1
+  fi
+  echo " PASS"
+  return 0
+}
+
 function insert_postgresql_data() {
   local image_name=$1 ; shift
   local user=$1 ; shift
@@ -247,8 +256,84 @@ function test_postgresql_replication() {
   ct_os_delete_project
 }
 
+function test_postgresql_persistent_redeploy() {
+  local image_name=$1
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=$image_name_no_namespace
+  local user="testu" pass="testp" db="testdb"
+  local registry="" old_image="" pod_ip=""
+
+  ct_os_new_project
+  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+
+  ct_os_deploy_template_image "$TEMPLATES/postgresql-persistent-template.json" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
+                              DATABASE_SERVICE_NAME="$service_name" \
+                              POSTGRESQL_USER="$user" \
+                              POSTGRESQL_PASSWORD="$pass" \
+                              POSTGRESQL_DATABASE="$db"
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
+
+  pod_ip=$(ct_os_get_service_ip "$service_name")
+  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+
+  : "Redeploying pod"
+  oc deploy "$service_name" --latest
+  : "Waiting for a few seconds while the pod gets restarted"
+  sleep 5
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  : "This should succeed"
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip" 0
+  ct_os_delete_project
+}
+
+function test_postgresql_ephemeral_redeploy() {
+  local image_name=$1
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=$image_name_no_namespace
+  local user="testu" pass="testp" db="testdb"
+  local registry="" old_image="" pod_ip=""
+
+  ct_os_new_project
+  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+
+  ct_os_deploy_template_image "$TEMPLATES/postgresql-ephemeral-template.json" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
+                              DATABASE_SERVICE_NAME="$service_name" \
+                              POSTGRESQL_USER="$user" \
+                              POSTGRESQL_PASSWORD="$pass" \
+                              POSTGRESQL_DATABASE="$db"
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
+
+  pod_ip=$(ct_os_get_service_ip "$service_name")
+  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+
+  : "Redeploying pod"
+  oc deploy "$service_name" --latest
+  : "Waiting for a few seconds while the pod gets restarted"
+  sleep 5
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  : "This should fail"
+  assert_cmd_fails check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip" 0
+  ct_os_delete_project
+}
+
 ct_os_cluster_up
 test_postgresql_pure_image "${IMAGE_NAME}"
 test_postgresql_template "${IMAGE_NAME}"
+test_postgresql_ephemeral_redeploy "${IMAGE_NAME}"
+test_postgresql_persistent_redeploy "${IMAGE_NAME}"
 test_postgresql_update "${IMAGE_NAME}"
 test_postgresql_replication "${IMAGE_NAME}"

From 5e2424ab0b58adffce9087ee62a2fb54d85c8837 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Mon, 8 Jan 2018 10:50:59 +0100
Subject: [PATCH 052/509] Fix templates according to `openshift/origin` (#221)

* New common commit.

* Replace 'template.openshift.io' with 'openshift.io'

https://github.com/openshift/origin/pull/17922#pullrequestreview-86819501

* Remove ' (Persistent)'

https://github.com/openshift/origin/pull/17922#pullrequestreview-86940496
---
 common                                       |  2 +-
 examples/postgresql-ephemeral-template.json  |  8 ++++----
 examples/postgresql-persistent-template.json | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common b/common
index a6401ffa..4782af82 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a6401ffa47f0dcceef0f582541ed9339cbcb4956
+Subproject commit 4782af829e32e0b4fe8000d43b50c7a08ee2be1c
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index 5ff29ba4..f29698d0 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -8,10 +8,10 @@
       "description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
       "iconClass": "icon-postgresql",
       "tags": "database,postgresql",
-      "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is not stored on persistent storage, so any restart of the service will result in all data being lost.  The database name, username, and password are chosen via parameters when provisioning this service.",
-      "template.openshift.io/provider-display-name": "Red Hat, Inc.",
-      "template.openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
-      "template.openshift.io/support-url": "https://access.redhat.com"
+      "openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is not stored on persistent storage, so any restart of the service will result in all data being lost.  The database name, username, and password are chosen via parameters when provisioning this service.",
+      "openshift.io/provider-display-name": "Red Hat, Inc.",
+      "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "openshift.io/support-url": "https://access.redhat.com"
     }
   },
   "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index b524e369..7feeb704 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -4,14 +4,14 @@
   "metadata": {
     "name": "postgresql-persistent",
     "annotations": {
-      "openshift.io/display-name": "PostgreSQL (Persistent)",
+      "openshift.io/display-name": "PostgreSQL",
       "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
       "iconClass": "icon-postgresql",
       "tags": "database,postgresql",
-      "template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is stored on persistent storage.  The database name, username, and password are chosen via parameters when provisioning this service.",
-      "template.openshift.io/provider-display-name": "Red Hat, Inc.",
-      "template.openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
-      "template.openshift.io/support-url": "https://access.redhat.com"
+      "openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is stored on persistent storage.  The database name, username, and password are chosen via parameters when provisioning this service.",
+      "openshift.io/provider-display-name": "Red Hat, Inc.",
+      "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "openshift.io/support-url": "https://access.redhat.com"
     }
   },
   "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n       Username: ${POSTGRESQL_USER}\n       Password: ${POSTGRESQL_PASSWORD}\n  Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",

From 4924ab50ffe8d1c9b40732709f00ab76e60d5c3b Mon Sep 17 00:00:00 2001
From: Tomas Tomecek <ttomecek@redhat.com>
Date: Wed, 10 Jan 2018 10:21:25 +0100
Subject: [PATCH 053/509] latest,fedora: typo fix s/FCG/FGC/

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
---
 latest/Dockerfile.fedora | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/latest/Dockerfile.fedora b/latest/Dockerfile.fedora
index c5c0e3e2..71f78a10 100644
--- a/latest/Dockerfile.fedora
+++ b/latest/Dockerfile.fedora
@@ -33,7 +33,7 @@ LABEL summary=$SUMMARY \
       io.openshift.tags="database,postgresql,postgresql96" \
       com.redhat.component="$NAME" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="$FCG/$NAME" \
+      name="$FGC/$NAME" \
       version="0" \
       release="$RELEASE.$DISTTAG" \
       architecture="$ARCH" \

From 6443165783197a3f8b6d4ee8fa3bdb3395c6f853 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Fri, 24 Nov 2017 12:10:23 +0100
Subject: [PATCH 054/509] Enable s2i

---
 9.4/Dockerfile                                | 11 +++-
 9.4/Dockerfile.rhel7                          | 11 +++-
 9.4/root/usr/bin/run-postgresql               |  5 +-
 .../container-scripts/postgresql/README.md    | 39 +++++++++++++
 .../container-scripts/postgresql/common.sh    | 44 ++++++++++-----
 .../postgresql/postgresql-init/set-config.sh  | 14 +++++
 .../postgresql-start-hook/set_passwords.sh    | 14 +++++
 9.4/s2i/bin/assemble                          | 14 +++++
 9.4/s2i/bin/run                               |  1 +
 9.4/s2i/bin/usage                             |  1 +
 9.5/Dockerfile                                | 11 +++-
 9.5/Dockerfile.rhel7                          | 11 +++-
 9.5/root/usr/bin/run-postgresql               |  5 +-
 .../container-scripts/postgresql/README.md    | 39 +++++++++++++
 .../container-scripts/postgresql/common.sh    | 44 ++++++++++-----
 .../postgresql/postgresql-init/set-config.sh  | 14 +++++
 .../postgresql-start-hook/set_passwords.sh    | 14 +++++
 9.5/s2i/bin/assemble                          | 14 +++++
 9.5/s2i/bin/run                               |  1 +
 9.5/s2i/bin/usage                             |  1 +
 Dockerfile.template                           | 11 +++-
 .../postgresql-config/s2i-extending.conf      |  4 ++
 .../postgresql-start-hook/set_passwords.sh    |  4 ++
 latest/Dockerfile                             | 11 +++-
 latest/Dockerfile.rhel7                       | 11 +++-
 latest/root/usr/bin/run-postgresql            |  5 +-
 .../container-scripts/postgresql/README.md    | 39 +++++++++++++
 .../container-scripts/postgresql/common.sh    | 44 ++++++++++-----
 .../postgresql/postgresql-init/set-config.sh  | 14 +++++
 .../postgresql-start-hook/set_passwords.sh    | 14 +++++
 latest/s2i/bin/assemble                       | 14 +++++
 latest/s2i/bin/run                            |  1 +
 latest/s2i/bin/usage                          |  1 +
 specs/multispec.yml                           |  2 +
 test/run_test                                 | 55 +++++++++++++++++++
 test/test-app/postgresql-init/backup_user.sh  |  8 +++
 36 files changed, 484 insertions(+), 62 deletions(-)
 create mode 100644 9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 create mode 100644 9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
 create mode 100755 9.4/s2i/bin/assemble
 create mode 120000 9.4/s2i/bin/run
 create mode 100755 9.4/s2i/bin/usage
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 create mode 100644 9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
 create mode 100755 9.5/s2i/bin/assemble
 create mode 120000 9.5/s2i/bin/run
 create mode 100755 9.5/s2i/bin/usage
 create mode 100644 examples/extending-image/postgresql-config/s2i-extending.conf
 create mode 100644 examples/extending-image/postgresql-start-hook/set_passwords.sh
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
 create mode 100755 latest/s2i/bin/assemble
 create mode 120000 latest/s2i/bin/run
 create mode 100755 latest/s2i/bin/usage
 create mode 100644 test/test-app/postgresql-init/backup_user.sh

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
index 9ccb14e5..3bab542e 100644
--- a/9.4/Dockerfile
+++ b/9.4/Dockerfile
@@ -1,4 +1,4 @@
-FROM centos:centos7
+FROM centos/s2i-core-centos7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM centos:centos7
 ENV POSTGRESQL_VERSION=9.4 \
     POSTGRESQL_PREV_VERSION=9.2 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -55,6 +56,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -65,6 +67,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index f230746b..2da5d0ac 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -1,4 +1,4 @@
-FROM rhel7
+FROM rhscl/s2i-core-rhel7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM rhel7
 ENV POSTGRESQL_VERSION=9.4 \
     POSTGRESQL_PREV_VERSION=9.2 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -61,6 +62,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql94
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -71,6 +73,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
index a5ad5fa1..da8a31a8 100755
--- a/9.4/root/usr/bin/run-postgresql
+++ b/9.4/root/usr/bin/run-postgresql
@@ -24,10 +24,13 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
     migrate_db
     create_users
 fi
-set_passwords
+
+process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+
 pg_ctl stop
 
 unset_env_vars
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index a38e2efa..42984af2 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -235,6 +235,45 @@ enough space for the copy;  upgrade failure because of not enough space might
 lead to data loss.
 
 
+Extending image
+----------------
+
+This image can be extended using
+[source-to-image](https://github.com/openshift/source-to-image).
+
+For example to build customized image `new-postgresql`
+with configuration in `~/image-configuration/` run:
+
+
+```
+$ s2i build ~/image-configuration/ postgresql new-postgresql
+```
+
+The directory passed to `s2i build` should contain one or more of the
+following directories:
+
+##### `postgresql-config/`
+
+contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+
+
+##### `postgresql-init/`
+
+contained shell scripts (`*.sh`) are sourced once, when database is initialized
+
+##### `postgresql-start-hook/`
+
+contained shell scripts (`*.sh`) are sourced before every start
+
+----------------------------------------------
+
+During `s2i build` all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
 Troubleshooting
 ---------------
 At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index cd1aed8f..6ba804a5 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -190,21 +190,6 @@ function create_users() {
   fi
 }
 
-function set_passwords() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-  fi
-}
-
 migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
@@ -413,3 +398,32 @@ try_pgupgrade ()
 
   run_pgupgrade
 }
+
+# get_matched_files finds file for image extending
+function get_matched_files() {
+  local custom_dir default_dir
+  custom_dir="$1"
+  default_dir="$2"
+  files_matched="$3"
+  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+}
+
+# process_extending_files process extending files in $1 and $2 directories
+# - source all *.sh files
+#   (if there are files with same name source only file from $1)
+function process_extending_files() {
+  local custom_dir default_dir
+  custom_dir=$1
+  default_dir=$2
+
+  while read filename ; do
+    echo "=> sourcing $filename ..."
+    # Custom file is prefered
+    if [ -f $custom_dir/$filename ]; then
+      source $custom_dir/$filename
+    elif [ -f $default_dir/$filename ]; then
+      source $default_dir/$filename
+    fi
+  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+}
diff --git a/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
new file mode 100644
index 00000000..a087a687
--- /dev/null
+++ b/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+shopt -s nullglob
+
+cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom extending configuration
+EOF
+
+extending_cfg_dir="${APP_DATA}/src/postgresql-config"
+
+for conf in "$extending_cfg_dir"/*.conf; do
+    echo include \'${conf}\' >> $PGDATA/postgresql.conf
+done
diff --git a/9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
new file mode 100644
index 00000000..f14ff46a
--- /dev/null
+++ b/9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+fi
diff --git a/9.4/s2i/bin/assemble b/9.4/s2i/bin/assemble
new file mode 100755
index 00000000..c1472bdc
--- /dev/null
+++ b/9.4/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions ./
diff --git a/9.4/s2i/bin/run b/9.4/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/9.4/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/9.4/s2i/bin/usage b/9.4/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/9.4/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
index 3000023c..e6bff730 100644
--- a/9.5/Dockerfile
+++ b/9.5/Dockerfile
@@ -1,4 +1,4 @@
-FROM centos:centos7
+FROM centos/s2i-core-centos7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM centos:centos7
 ENV POSTGRESQL_VERSION=9.5 \
     POSTGRESQL_PREV_VERSION=9.4 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -55,6 +56,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -65,6 +67,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index d2f9c7d5..74b4a830 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -1,4 +1,4 @@
-FROM rhel7
+FROM rhscl/s2i-core-rhel7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM rhel7
 ENV POSTGRESQL_VERSION=9.5 \
     POSTGRESQL_PREV_VERSION=9.4 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -61,6 +62,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql95
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -71,6 +73,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
index a5ad5fa1..da8a31a8 100755
--- a/9.5/root/usr/bin/run-postgresql
+++ b/9.5/root/usr/bin/run-postgresql
@@ -24,10 +24,13 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
     migrate_db
     create_users
 fi
-set_passwords
+
+process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+
 pg_ctl stop
 
 unset_env_vars
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index ac5c05a2..b2ceb8aa 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -235,6 +235,45 @@ enough space for the copy;  upgrade failure because of not enough space might
 lead to data loss.
 
 
+Extending image
+----------------
+
+This image can be extended using
+[source-to-image](https://github.com/openshift/source-to-image).
+
+For example to build customized image `new-postgresql`
+with configuration in `~/image-configuration/` run:
+
+
+```
+$ s2i build ~/image-configuration/ postgresql new-postgresql
+```
+
+The directory passed to `s2i build` should contain one or more of the
+following directories:
+
+##### `postgresql-config/`
+
+contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+
+
+##### `postgresql-init/`
+
+contained shell scripts (`*.sh`) are sourced once, when database is initialized
+
+##### `postgresql-start-hook/`
+
+contained shell scripts (`*.sh`) are sourced before every start
+
+----------------------------------------------
+
+During `s2i build` all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
 Troubleshooting
 ---------------
 At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index 14413ea4..5fa871be 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -190,21 +190,6 @@ function create_users() {
   fi
 }
 
-function set_passwords() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-  fi
-}
-
 migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
@@ -413,3 +398,32 @@ try_pgupgrade ()
 
   run_pgupgrade
 }
+
+# get_matched_files finds file for image extending
+function get_matched_files() {
+  local custom_dir default_dir
+  custom_dir="$1"
+  default_dir="$2"
+  files_matched="$3"
+  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+}
+
+# process_extending_files process extending files in $1 and $2 directories
+# - source all *.sh files
+#   (if there are files with same name source only file from $1)
+function process_extending_files() {
+  local custom_dir default_dir
+  custom_dir=$1
+  default_dir=$2
+
+  while read filename ; do
+    echo "=> sourcing $filename ..."
+    # Custom file is prefered
+    if [ -f $custom_dir/$filename ]; then
+      source $custom_dir/$filename
+    elif [ -f $default_dir/$filename ]; then
+      source $default_dir/$filename
+    fi
+  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
new file mode 100644
index 00000000..a087a687
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+shopt -s nullglob
+
+cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom extending configuration
+EOF
+
+extending_cfg_dir="${APP_DATA}/src/postgresql-config"
+
+for conf in "$extending_cfg_dir"/*.conf; do
+    echo include \'${conf}\' >> $PGDATA/postgresql.conf
+done
diff --git a/9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
new file mode 100644
index 00000000..f14ff46a
--- /dev/null
+++ b/9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+fi
diff --git a/9.5/s2i/bin/assemble b/9.5/s2i/bin/assemble
new file mode 100755
index 00000000..c1472bdc
--- /dev/null
+++ b/9.5/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions ./
diff --git a/9.5/s2i/bin/run b/9.5/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/9.5/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/9.5/s2i/bin/usage b/9.5/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/9.5/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/Dockerfile.template b/Dockerfile.template
index ece6ead3..dca37509 100644
--- a/Dockerfile.template
+++ b/Dockerfile.template
@@ -1,4 +1,4 @@
-FROM {{ config.docker.from }}
+FROM {{ spec.s2i_base }}
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM {{ config.docker.from }}
 ENV POSTGRESQL_VERSION={{ spec.version }} \
     POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -67,6 +68,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS={{ spec.enabled_collection }}
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -77,6 +79,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/examples/extending-image/postgresql-config/s2i-extending.conf b/examples/extending-image/postgresql-config/s2i-extending.conf
new file mode 100644
index 00000000..668142b2
--- /dev/null
+++ b/examples/extending-image/postgresql-config/s2i-extending.conf
@@ -0,0 +1,4 @@
+log_destination = 'stderr'
+logging_collector = on
+log_directory = 'pg_log'
+log_filename = 'postgresql.log'
diff --git a/examples/extending-image/postgresql-start-hook/set_passwords.sh b/examples/extending-image/postgresql-start-hook/set_passwords.sh
new file mode 100644
index 00000000..9388e5b3
--- /dev/null
+++ b/examples/extending-image/postgresql-start-hook/set_passwords.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# postgresql image encrypts user passwords at service start
+# the functionality can be disabled by providing this file (postgresql-start-hook/set_passwords.sh) in s2i build
diff --git a/latest/Dockerfile b/latest/Dockerfile
index 7ed2499b..0dcae391 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -1,4 +1,4 @@
-FROM centos:centos7
+FROM centos/s2i-core-centos7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM centos:centos7
 ENV POSTGRESQL_VERSION=9.6 \
     POSTGRESQL_PREV_VERSION=9.5 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -57,6 +58,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql96
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -67,6 +69,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index c35763db..2e00caba 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -1,4 +1,4 @@
-FROM rhel7
+FROM rhscl/s2i-core-rhel7
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -13,7 +13,8 @@ FROM rhel7
 ENV POSTGRESQL_VERSION=9.6 \
     POSTGRESQL_PREV_VERSION=9.5 \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
@@ -62,6 +63,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
     ENABLED_COLLECTIONS=rh-postgresql96
 
 COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
@@ -72,6 +74,11 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
index a5ad5fa1..da8a31a8 100755
--- a/latest/root/usr/bin/run-postgresql
+++ b/latest/root/usr/bin/run-postgresql
@@ -24,10 +24,13 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
     migrate_db
     create_users
 fi
-set_passwords
+
+process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+
 pg_ctl stop
 
 unset_env_vars
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 9bb5d352..a2395ec9 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -235,6 +235,45 @@ enough space for the copy;  upgrade failure because of not enough space might
 lead to data loss.
 
 
+Extending image
+----------------
+
+This image can be extended using
+[source-to-image](https://github.com/openshift/source-to-image).
+
+For example to build customized image `new-postgresql`
+with configuration in `~/image-configuration/` run:
+
+
+```
+$ s2i build ~/image-configuration/ postgresql new-postgresql
+```
+
+The directory passed to `s2i build` should contain one or more of the
+following directories:
+
+##### `postgresql-config/`
+
+contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+
+
+##### `postgresql-init/`
+
+contained shell scripts (`*.sh`) are sourced once, when database is initialized
+
+##### `postgresql-start-hook/`
+
+contained shell scripts (`*.sh`) are sourced before every start
+
+----------------------------------------------
+
+During `s2i build` all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
 Troubleshooting
 ---------------
 At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index 5f13d5c7..59c87e69 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -190,21 +190,6 @@ function create_users() {
   fi
 }
 
-function set_passwords() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-  fi
-}
-
 migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
@@ -413,3 +398,32 @@ try_pgupgrade ()
 
   run_pgupgrade
 }
+
+# get_matched_files finds file for image extending
+function get_matched_files() {
+  local custom_dir default_dir
+  custom_dir="$1"
+  default_dir="$2"
+  files_matched="$3"
+  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+}
+
+# process_extending_files process extending files in $1 and $2 directories
+# - source all *.sh files
+#   (if there are files with same name source only file from $1)
+function process_extending_files() {
+  local custom_dir default_dir
+  custom_dir=$1
+  default_dir=$2
+
+  while read filename ; do
+    echo "=> sourcing $filename ..."
+    # Custom file is prefered
+    if [ -f $custom_dir/$filename ]; then
+      source $custom_dir/$filename
+    elif [ -f $default_dir/$filename ]; then
+      source $default_dir/$filename
+    fi
+  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+}
diff --git a/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
new file mode 100644
index 00000000..a087a687
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+shopt -s nullglob
+
+cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom extending configuration
+EOF
+
+extending_cfg_dir="${APP_DATA}/src/postgresql-config"
+
+for conf in "$extending_cfg_dir"/*.conf; do
+    echo include \'${conf}\' >> $PGDATA/postgresql.conf
+done
diff --git a/latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
new file mode 100644
index 00000000..f14ff46a
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+fi
diff --git a/latest/s2i/bin/assemble b/latest/s2i/bin/assemble
new file mode 100755
index 00000000..c1472bdc
--- /dev/null
+++ b/latest/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions ./
diff --git a/latest/s2i/bin/run b/latest/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/latest/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/latest/s2i/bin/usage b/latest/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/latest/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 8b997b40..7ac2a6cc 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -5,6 +5,7 @@ specs:
     centos:
       distros:
         - centos-7-x86_64
+      s2i_base: centos/s2i-core-centos7
       org: "centos"
       prod: "centos7"
       repo_enable_reason: ""
@@ -17,6 +18,7 @@ specs:
     rhel7:
        distros:
          - rhel-7-x86_64
+       s2i_base: rhscl/s2i-core-rhel7
        org: "rhscl"
        prod: "rhel7"
        repo_enable_reason: |-
diff --git a/test/run_test b/test/run_test
index a1f2f9b8..8c645812 100755
--- a/test/run_test
+++ b/test/run_test
@@ -24,6 +24,7 @@ run_change_password_test
 run_replication_test
 run_master_restart_test
 run_doc_test
+run_s2i_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -34,6 +35,8 @@ test -n "${OS-}" || false 'make sure $OS is defined'
 CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
 volumes_to_clean=
+s2i_test_app_dir="$(mktemp -d)"
+test_dir="$(readlink -f "$(dirname "$0")")"
 
 function cleanup() {
   for cidfile in $CIDFILE_DIR/* ; do
@@ -53,6 +56,8 @@ function cleanup() {
   rmdir $CIDFILE_DIR
 
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
+
+  test -d "$s2i_test_app_dir" && rm -rf "$s2i_test_app_dir"
 }
 trap cleanup EXIT
 
@@ -558,6 +563,56 @@ run_doc_test() {
   echo
 }
 
+_s2i_test_image() {
+  local container_name="$1"
+  local mount_opts="$2"
+  echo "    Testing s2i app image with invalid configuration"
+  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db
+  echo "    Testing s2i app image with correct configuration"
+
+    DOCKER_ARGS="
+-e POSTGRESQL_DATABASE=db
+-e POSTGRESQL_USER=user
+-e POSTGRESQL_PASSWORD=password
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-e POSTGRESQL_BACKUP_USER=backuser
+-e POSTGRESQL_BACKUP_PASSWORD=pass
+${mount_opts}
+" create_container "$container_name"
+
+
+  # need to set these because `postgresql_cmd` relies on global variables
+  PGUSER=user
+  PASS=password
+
+  # need this to wait for the container to start up
+  CONTAINER_IP=$(get_container_ip "${container_name}")
+  test_connection "$container_name"
+
+  docker stop "$(get_cid $container_name)" >/dev/null
+}
+
+run_s2i_test() {
+  echo "  Testing s2i usage"
+  s2i usage --pull-policy=never "${IMAGE_NAME}" &>/dev/null
+
+  echo "  Testing s2i build"
+  s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "${IMAGE_NAME}-testapp"
+  local image_name_backup="${IMAGE_NAME}"
+  export IMAGE_NAME="${IMAGE_NAME}-testapp"
+
+  local container_name=s2i_config_build
+  _s2i_test_image "s2i_config_build" ""
+
+  # return back original value for IMAGE_NAME
+  export IMAGE_NAME="${image_name_backup}"
+
+  echo "  Testing s2i mount"
+  cp -Lr "${test_dir}/test-app" "${s2i_test_app_dir}/"
+  _s2i_test_image "_s2i_test_mount" "-v ${s2i_test_app_dir}/test-app:/opt/app-root/src/:z"
+  echo "  Success!"
+}
+
 function run_general_tests() {
   PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin
   PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin
diff --git a/test/test-app/postgresql-init/backup_user.sh b/test/test-app/postgresql-init/backup_user.sh
new file mode 100644
index 00000000..a1ac6535
--- /dev/null
+++ b/test/test-app/postgresql-init/backup_user.sh
@@ -0,0 +1,8 @@
+# Check that user credentials for backup is set
+
+[[ -v POSTGRESQL_BACKUP_USER && -v POSTGRESQL_BACKUP_PASSWORD ]] || usage "You have to set all variables for user for doing backup: POSTGRESQL_BACKUP_USER, POSTGRESQL_BACKUP_PASSWORD"
+
+# create backup user
+
+psql -c "CREATE USER $POSTGRESQL_BACKUP_USER SUPERUSER  password '$POSTGRESQL_BACKUP_PASSWORD';"
+psql -c "ALTER USER $POSTGRESQL_BACKUP_USER set default_transaction_read_only = on;"

From 2db24392b8bc3db0938b98fbdf6fdf8f720b89a4 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Wed, 10 Jan 2018 13:26:24 +0100
Subject: [PATCH 055/509] Remove extra line in rhel7 latest Dockerfile

---
 Dockerfile.template     | 2 +-
 latest/Dockerfile.rhel7 | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/Dockerfile.template b/Dockerfile.template
index dca37509..397c4546 100644
--- a/Dockerfile.template
+++ b/Dockerfile.template
@@ -50,7 +50,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {{ spec.repo_enable_reason }}
 {%- endif %}
 RUN {{ spec.environment_setup }}
-{%- if not spec.stable %}
+{%- if not spec.stable and spec.staging_repo_setup %}
 {{ spec.staging_repo_setup }}
 {%- endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index 2e00caba..d0bfb9c6 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -47,7 +47,6 @@ RUN yum install -y yum-utils gettext && \
     yum-config-manager --enable rhel-server-rhscl-7-rpms && \
     yum-config-manager --enable rhel-7-server-rpms && \
     yum-config-manager --enable rhel-7-server-optional-rpms && \
-
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From ad3c3b295ef1cd24497a6d4e5eb1202e96adfd76 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Wed, 10 Jan 2018 13:26:50 +0100
Subject: [PATCH 056/509] Add usage and maintainer to Dockerfile template

---
 Dockerfile.template | 8 +++-----
 specs/multispec.yml | 3 ---
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/Dockerfile.template b/Dockerfile.template
index 397c4546..d85a08ed 100644
--- a/Dockerfile.template
+++ b/Dockerfile.template
@@ -30,14 +30,12 @@ LABEL summary=$SUMMARY \
       name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
       com.redhat.component="{{ spec.redhat_component }}" \
 {%- if spec.version in spec.rhscl3_introduced %}
-      version="1"
+      version="1" \
 {%- else %}
       version="{{ spec.version }}" \
-      release="1"
-{%- endif %}
-{%- if spec.maintainer %} \
-      maintainer="{{ spec.maintainer }}"
 {%- endif %}
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 7ac2a6cc..bbd37e96 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -10,11 +10,9 @@ specs:
       prod: "centos7"
       repo_enable_reason: ""
       environment_setup: yum install -y centos-release-scl-rh && \
-      maintainer: "SoftwareCollections.org <sclorg@redhat.com>"
       staging_repo_setup: >-4
               yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
               echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
-
     rhel7:
        distros:
          - rhel-7-x86_64
@@ -30,7 +28,6 @@ specs:
                yum-config-manager --enable rhel-server-rhscl-7-rpms && \
                yum-config-manager --enable rhel-7-server-rpms && \
                yum-config-manager --enable rhel-7-server-optional-rpms && \
-       maintainer: ""
        staging_repo_setup: ""
        rhscl3_introduced:
          - "9.6"

From 9312a4294d4dc938b622abc2b698554335767cd3 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 31 Jan 2018 13:29:52 +0100
Subject: [PATCH 057/509] Use prepare-yum-repositories script for enabling
 repositories

---
 9.4/Dockerfile.rhel7    | 5 +----
 9.5/Dockerfile.rhel7    | 5 +----
 latest/Dockerfile.rhel7 | 5 +----
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
index 2da5d0ac..dd28dc84 100644
--- a/9.4/Dockerfile.rhel7
+++ b/9.4/Dockerfile.rhel7
@@ -43,10 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
 RUN yum install -y yum-utils gettext && \
-    yum-config-manager --disable \* &> /dev/null && \
-    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-7-server-rpms && \
-    yum-config-manager --enable rhel-7-server-optional-rpms && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
index 74b4a830..d3119c3f 100644
--- a/9.5/Dockerfile.rhel7
+++ b/9.5/Dockerfile.rhel7
@@ -43,10 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
 RUN yum install -y yum-utils gettext && \
-    yum-config-manager --disable \* &> /dev/null && \
-    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-7-server-rpms && \
-    yum-config-manager --enable rhel-7-server-optional-rpms && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
index d0bfb9c6..0934b6d3 100644
--- a/latest/Dockerfile.rhel7
+++ b/latest/Dockerfile.rhel7
@@ -43,10 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
 # in base RHEL
 RUN yum install -y yum-utils gettext && \
-    yum-config-manager --disable \* &> /dev/null && \
-    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-7-server-rpms && \
-    yum-config-manager --enable rhel-7-server-optional-rpms && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From 1086d8a309d4a18910f5682dae81d911ad009f2f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 1 Feb 2018 10:12:16 +0100
Subject: [PATCH 058/509] Run openshift image update test with live template

---
 test/run-openshift | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/run-openshift b/test/run-openshift
index d47eda8d..ae330d87 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -146,6 +146,7 @@ function test_postgresql_update() {
   local image_name_no_namespace=${image_name##*/}
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
+  local template="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/postgresql-persistent-template.json"
   local registry="" old_image="" pod_ip=""
 
   case $OS in
@@ -163,7 +164,8 @@ function test_postgresql_update() {
   ct_os_new_project
   ct_os_upload_image "$old_image" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$TEMPLATES/postgresql-persistent-template.json" \
+  # Use remote template to make sure the new image works regardless of template changes
+  ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="$service_name" \

From 62871affc0776819d2b92a99b67d628b3a4e0897 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 2 Feb 2018 16:36:19 +0100
Subject: [PATCH 059/509] Drop "beta" repositories since 9.6 is released

---
 latest/Dockerfile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/latest/Dockerfile b/latest/Dockerfile
index 0dcae391..dd242c1e 100644
--- a/latest/Dockerfile
+++ b/latest/Dockerfile
@@ -41,8 +41,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum install -y centos-release-scl-rh && \
-    yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
-    echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From 28de1f11c9124a7c2c0f341c5606073cf3c7dab2 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 30 Jan 2018 20:48:05 +0100
Subject: [PATCH 060/509] check-container: {live,ready}ness checks moved from
 templates

Related: #226
---
 9.4/root/usr/libexec/check-container         | 39 ++++++++++++++++++++
 9.5/root/usr/libexec/check-container         | 39 ++++++++++++++++++++
 examples/postgresql-ephemeral-template.json  | 10 ++---
 examples/postgresql-persistent-template.json | 10 ++---
 examples/replica/postgresql_replica.json     | 20 +++++-----
 latest/root/usr/libexec/check-container      | 39 ++++++++++++++++++++
 6 files changed, 137 insertions(+), 20 deletions(-)
 create mode 100755 9.4/root/usr/libexec/check-container
 create mode 100755 9.5/root/usr/libexec/check-container
 create mode 100755 latest/root/usr/libexec/check-container

diff --git a/9.4/root/usr/libexec/check-container b/9.4/root/usr/libexec/check-container
new file mode 100755
index 00000000..bee6acc8
--- /dev/null
+++ b/9.4/root/usr/libexec/check-container
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+check=ready
+case $1 in
+    --live) check=live ;;
+esac
+
+while true; do
+    # Wait until the /bin/postgres is executed.
+    case $(readlink -f /proc/1/exe) in
+        *bash) sleep 0.2; continue ;;
+        *) break ;;
+    esac
+done
+
+# Timeout is infinite (openshift template has the timeout pre-set)
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
+rc=$?
+
+# we are ready only if the db accepts connections
+test $rc -eq 0 && exit 0
+
+# container is live also during pg cluster start-up
+test $rc -eq 1 && test $check = live && exit 0
+
+exit 1
diff --git a/9.5/root/usr/libexec/check-container b/9.5/root/usr/libexec/check-container
new file mode 100755
index 00000000..bee6acc8
--- /dev/null
+++ b/9.5/root/usr/libexec/check-container
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+check=ready
+case $1 in
+    --live) check=live ;;
+esac
+
+while true; do
+    # Wait until the /bin/postgres is executed.
+    case $(readlink -f /proc/1/exe) in
+        *bash) sleep 0.2; continue ;;
+        *) break ;;
+    esac
+done
+
+# Timeout is infinite (openshift template has the timeout pre-set)
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
+rc=$?
+
+# we are ready only if the db accepts connections
+test $rc -eq 0 && exit 0
+
+# container is live also during pg cluster start-up
+test $rc -eq 1 && test $check = live && exit 0
+
+exit 1
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index f29698d0..d4b58608 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -123,15 +123,15 @@
                   "timeoutSeconds": 1,
                   "initialDelaySeconds": 5,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                    "command": [ "/usr/libexec/check-container" ]
                   }
                 },
                 "livenessProbe": {
+                  "timeoutSeconds": 10,
+                  "initialDelaySeconds": 120,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
-                  },
-                  "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30
+                    "command": [ "/usr/libexec/check-container", "--live" ]
+                  }
                 },
                 "env": [
                   {
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index 7feeb704..abfe6d66 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -140,15 +140,15 @@
                   "timeoutSeconds": 1,
                   "initialDelaySeconds": 5,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                    "command": [ "/usr/libexec/check-container" ]
                   }
                 },
                 "livenessProbe": {
+                  "timeoutSeconds": 10,
+                  "initialDelaySeconds": 120,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
-                  },
-                  "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30
+                    "command": [ "/usr/libexec/check-container", "--live" ]
+                  }
                 },
                 "env": [
                   {
diff --git a/examples/replica/postgresql_replica.json b/examples/replica/postgresql_replica.json
index eb9bf4f6..775a2dc7 100644
--- a/examples/replica/postgresql_replica.json
+++ b/examples/replica/postgresql_replica.json
@@ -207,15 +207,15 @@
                   "timeoutSeconds": 1,
                   "initialDelaySeconds": 5,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                    "command": [ "/usr/libexec/check-container" ]
                   }
                 },
                 "livenessProbe": {
+                  "timeoutSeconds": 10,
+                  "initialDelaySeconds": 120,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
-                  },
-                  "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30
+                    "command": [ "/usr/libexec/check-container", "--live" ]
+                  }
                 },
                 "env": [
                   {
@@ -318,15 +318,15 @@
                   "timeoutSeconds": 1,
                   "initialDelaySeconds": 5,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
+                    "command": [ "/usr/libexec/check-container" ]
                   }
                 },
                 "livenessProbe": {
+                  "timeoutSeconds": 10,
+                  "initialDelaySeconds": 120,
                   "exec": {
-                    "command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
-                  },
-                  "timeoutSeconds": 1,
-                  "initialDelaySeconds": 30
+                    "command": [ "/usr/libexec/check-container", "--live" ]
+                  }
                 },
                 "env": [
                   {
diff --git a/latest/root/usr/libexec/check-container b/latest/root/usr/libexec/check-container
new file mode 100755
index 00000000..bee6acc8
--- /dev/null
+++ b/latest/root/usr/libexec/check-container
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+check=ready
+case $1 in
+    --live) check=live ;;
+esac
+
+while true; do
+    # Wait until the /bin/postgres is executed.
+    case $(readlink -f /proc/1/exe) in
+        *bash) sleep 0.2; continue ;;
+        *) break ;;
+    esac
+done
+
+# Timeout is infinite (openshift template has the timeout pre-set)
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
+rc=$?
+
+# we are ready only if the db accepts connections
+test $rc -eq 0 && exit 0
+
+# container is live also during pg cluster start-up
+test $rc -eq 1 && test $check = live && exit 0
+
+exit 1

From 078bc0822be06ca3c70bf1ded6a51c0c19aec311 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 8 Feb 2018 12:21:30 +0100
Subject: [PATCH 061/509] new container-common-scripts version

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 4782af82..f3283fa0 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 4782af829e32e0b4fe8000d43b50c7a08ee2be1c
+Subproject commit f3283fa09175e4e4095da064798f69b969d986bc

From 7d84aae93236ba728ee7901297f9af7c721e5f9a Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 7 Feb 2018 15:08:06 +0100
Subject: [PATCH 062/509] 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
---
 9.4/root/usr/bin/run-postgresql                |  4 ++--
 .../container-scripts/postgresql/README.md     | 18 +++++++++++++-----
 .../container-scripts/postgresql/common.sh     |  7 +++++++
 .../postgresql/postgresql-init/set-config.sh   | 14 --------------
 .../set_passwords.sh                           |  0
 9.5/root/usr/bin/run-postgresql                |  4 ++--
 .../container-scripts/postgresql/README.md     | 18 +++++++++++++-----
 .../container-scripts/postgresql/common.sh     |  7 +++++++
 .../postgresql/postgresql-init/set-config.sh   | 14 --------------
 .../set_passwords.sh                           |  0
 .../s2i-extending.conf                         |  0
 .../set_passwords.sh                           |  0
 latest/root/usr/bin/run-postgresql             |  4 ++--
 .../container-scripts/postgresql/README.md     | 18 +++++++++++++-----
 .../container-scripts/postgresql/common.sh     |  7 +++++++
 .../postgresql/postgresql-init/set-config.sh   | 14 --------------
 .../set_passwords.sh                           |  0
 17 files changed, 66 insertions(+), 63 deletions(-)
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 rename 9.4/root/usr/share/container-scripts/postgresql/{postgresql-start-hook => start}/set_passwords.sh (100%)
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 rename 9.5/root/usr/share/container-scripts/postgresql/{postgresql-start-hook => start}/set_passwords.sh (100%)
 rename examples/extending-image/{postgresql-config => postgresql-cfg}/s2i-extending.conf (100%)
 rename examples/extending-image/{postgresql-start-hook => postgresql-start}/set_passwords.sh (100%)
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
 rename latest/root/usr/share/container-scripts/postgresql/{postgresql-start-hook => start}/set_passwords.sh (100%)

diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
index da8a31a8..48ff4258 100755
--- a/9.4/root/usr/bin/run-postgresql
+++ b/9.4/root/usr/bin/run-postgresql
@@ -24,12 +24,12 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
     migrate_db
     create_users
 fi
 
-process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
 
 pg_ctl stop
 
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index 42984af2..10337ec7 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
 The directory passed to `s2i build` should contain one or more of the
 following directories:
 
-##### `postgresql-config/`
+##### `postgresql-cfg/`
 
-contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
 
 
 ##### `postgresql-init/`
 
-contained shell scripts (`*.sh`) are sourced once, when database is initialized
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
 
-##### `postgresql-start-hook/`
 
-contained shell scripts (`*.sh`) are sourced before every start
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
 
 ----------------------------------------------
 
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
index 6ba804a5..2bc6784b 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.4/root/usr/share/container-scripts/postgresql/common.sh
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
         < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
 }
 
 function generate_postgresql_recovery_config() {
diff --git a/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
deleted file mode 100644
index a087a687..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-shopt -s nullglob
-
-cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom extending configuration
-EOF
-
-extending_cfg_dir="${APP_DATA}/src/postgresql-config"
-
-for conf in "$extending_cfg_dir"/*.conf; do
-    echo include \'${conf}\' >> $PGDATA/postgresql.conf
-done
diff --git a/9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
similarity index 100%
rename from 9.4/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
rename to 9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
index da8a31a8..48ff4258 100755
--- a/9.5/root/usr/bin/run-postgresql
+++ b/9.5/root/usr/bin/run-postgresql
@@ -24,12 +24,12 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
     migrate_db
     create_users
 fi
 
-process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
 
 pg_ctl stop
 
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index b2ceb8aa..d57d5934 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
 The directory passed to `s2i build` should contain one or more of the
 following directories:
 
-##### `postgresql-config/`
+##### `postgresql-cfg/`
 
-contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
 
 
 ##### `postgresql-init/`
 
-contained shell scripts (`*.sh`) are sourced once, when database is initialized
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
 
-##### `postgresql-start-hook/`
 
-contained shell scripts (`*.sh`) are sourced before every start
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
 
 ----------------------------------------------
 
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
index 5fa871be..bbbb76e4 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ b/9.5/root/usr/share/container-scripts/postgresql/common.sh
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
         < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
 }
 
 function generate_postgresql_recovery_config() {
diff --git a/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
deleted file mode 100644
index a087a687..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-shopt -s nullglob
-
-cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom extending configuration
-EOF
-
-extending_cfg_dir="${APP_DATA}/src/postgresql-config"
-
-for conf in "$extending_cfg_dir"/*.conf; do
-    echo include \'${conf}\' >> $PGDATA/postgresql.conf
-done
diff --git a/9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
similarity index 100%
rename from 9.5/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
rename to 9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
diff --git a/examples/extending-image/postgresql-config/s2i-extending.conf b/examples/extending-image/postgresql-cfg/s2i-extending.conf
similarity index 100%
rename from examples/extending-image/postgresql-config/s2i-extending.conf
rename to examples/extending-image/postgresql-cfg/s2i-extending.conf
diff --git a/examples/extending-image/postgresql-start-hook/set_passwords.sh b/examples/extending-image/postgresql-start/set_passwords.sh
similarity index 100%
rename from examples/extending-image/postgresql-start-hook/set_passwords.sh
rename to examples/extending-image/postgresql-start/set_passwords.sh
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
index da8a31a8..48ff4258 100755
--- a/latest/root/usr/bin/run-postgresql
+++ b/latest/root/usr/bin/run-postgresql
@@ -24,12 +24,12 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/postgresql-init
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
     migrate_db
     create_users
 fi
 
-process_extending_files ${APP_DATA}/src/postgresql-start-hook ${CONTAINER_SCRIPTS_PATH}/postgresql-start-hook
+process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
 
 pg_ctl stop
 
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index a2395ec9..87cd502f 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -252,18 +252,26 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
 The directory passed to `s2i build` should contain one or more of the
 following directories:
 
-##### `postgresql-config/`
+##### `postgresql-cfg/`
 
-contained configuration files (`*.conf`) will be included at the end of image postgresql.conf file during database initialization
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
 
 
 ##### `postgresql-init/`
 
-contained shell scripts (`*.sh`) are sourced once, when database is initialized
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
 
-##### `postgresql-start-hook/`
 
-contained shell scripts (`*.sh`) are sourced before every start
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
 
 ----------------------------------------------
 
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
index 59c87e69..757b3a1e 100644
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -125,6 +125,13 @@ function generate_postgresql_config() {
         < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
 }
 
 function generate_postgresql_recovery_config() {
diff --git a/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh b/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
deleted file mode 100644
index a087a687..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/postgresql-init/set-config.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-shopt -s nullglob
-
-cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom extending configuration
-EOF
-
-extending_cfg_dir="${APP_DATA}/src/postgresql-config"
-
-for conf in "$extending_cfg_dir"/*.conf; do
-    echo include \'${conf}\' >> $PGDATA/postgresql.conf
-done
diff --git a/latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh b/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/postgresql-start-hook/set_passwords.sh
rename to latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh

From 49a01540bb31e65977d0daa6b06c02b8619e1f5f Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 7 Feb 2018 18:05:16 +0100
Subject: [PATCH 063/509] tests: make sure that s2i test tests something

Previously the test have not tested that the backup user was
created and can login.

Also implement cleanup hook for the s2i image, which now has
randomly generated name.

Implemented "create tempfile" method with garbage collector.
---
 test/run_test                                | 56 ++++++++++++--------
 test/test-app/postgresql-init/backup_user.sh | 12 +++--
 2 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/test/run_test b/test/run_test
index 8c645812..4bcd0fcd 100755
--- a/test/run_test
+++ b/test/run_test
@@ -35,7 +35,8 @@ test -n "${OS-}" || false 'make sure $OS is defined'
 CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
 volumes_to_clean=
-s2i_test_app_dir="$(mktemp -d)"
+images_to_clean=
+files_to_clean=
 test_dir="$(readlink -f "$(dirname "$0")")"
 
 function cleanup() {
@@ -56,8 +57,8 @@ function cleanup() {
   rmdir $CIDFILE_DIR
 
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
-
-  test -d "$s2i_test_app_dir" && rm -rf "$s2i_test_app_dir"
+  ct_path_foreach "$images_to_clean" cleanup_image
+  ct_path_foreach "$files_to_clean" rm
 }
 trap cleanup EXIT
 
@@ -74,6 +75,11 @@ cleanup_volume_dir ()
   rmdir "$1"
 }
 
+cleanup_image ()
+{
+    docker rmi -f "$1"
+}
+
 function get_cid() {
   local id="$1" ; shift || return 1
   echo $(cat "$CIDFILE_DIR/$id")
@@ -150,6 +156,14 @@ create_volume_dir ()
 }
 
 
+create_temp_file ()
+{
+  temp_file=`mktemp --tmpdir pg-testfile.XXXXX`
+  setfacl -m u:26:rw- "$temp_file"
+  ct_path_append files_to_clean "$temp_file"
+}
+
+
 function assert_login_access() {
   local PGUSER=$1 ; shift
   local PASS=$1 ; shift
@@ -563,9 +577,9 @@ run_doc_test() {
   echo
 }
 
-_s2i_test_image() {
-  local container_name="$1"
-  local mount_opts="$2"
+test_the_app_image () {
+  local container_name=$1
+  local mount_opts=$2
   echo "    Testing s2i app image with invalid configuration"
   assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db
   echo "    Testing s2i app image with correct configuration"
@@ -580,36 +594,34 @@ _s2i_test_image() {
 ${mount_opts}
 " create_container "$container_name"
 
-
-  # need to set these because `postgresql_cmd` relies on global variables
-  PGUSER=user
-  PASS=password
-
   # need this to wait for the container to start up
-  CONTAINER_IP=$(get_container_ip "${container_name}")
-  test_connection "$container_name"
+  PGUSER=user     PASS=password           test_connection "$container_name"
+  PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name"
 
   docker stop "$(get_cid $container_name)" >/dev/null
 }
 
 run_s2i_test() {
+  local temp_file
   echo "  Testing s2i usage"
   s2i usage --pull-policy=never "${IMAGE_NAME}" &>/dev/null
 
   echo "  Testing s2i build"
-  s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "${IMAGE_NAME}-testapp"
-  local image_name_backup="${IMAGE_NAME}"
-  export IMAGE_NAME="${IMAGE_NAME}-testapp"
 
-  local container_name=s2i_config_build
-  _s2i_test_image "s2i_config_build" ""
+  local s2i_image_name=$IMAGE_NAME-testapp_$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 10 | head -n 1)
+  ct_path_append images_to_clean "$s2i_image_name"
 
-  # return back original value for IMAGE_NAME
-  export IMAGE_NAME="${image_name_backup}"
+  s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name"
+  IMAGE_NAME=$s2i_image_name test_the_app_image s2i_config_build ""
 
   echo "  Testing s2i mount"
-  cp -Lr "${test_dir}/test-app" "${s2i_test_app_dir}/"
-  _s2i_test_image "_s2i_test_mount" "-v ${s2i_test_app_dir}/test-app:/opt/app-root/src/:z"
+  create_temp_file
+  cat "$test_dir"/test-app/postgresql-init/backup_user.sh >> "$temp_file"
+
+  # Test against original image, not the s2i one.  But even if so, we expect
+  # user mouns the directory under "s2i" direcetory $APP_DATA/src.
+  local mount_point=/opt/app-root/src/postgresql-init/add_backup_user.sh
+  test_the_app_image _s2i_test_mount "-v ${temp_file}:$mount_point:z,ro"
   echo "  Success!"
 }
 
diff --git a/test/test-app/postgresql-init/backup_user.sh b/test/test-app/postgresql-init/backup_user.sh
index a1ac6535..762bef17 100644
--- a/test/test-app/postgresql-init/backup_user.sh
+++ b/test/test-app/postgresql-init/backup_user.sh
@@ -2,7 +2,11 @@
 
 [[ -v POSTGRESQL_BACKUP_USER && -v POSTGRESQL_BACKUP_PASSWORD ]] || usage "You have to set all variables for user for doing backup: POSTGRESQL_BACKUP_USER, POSTGRESQL_BACKUP_PASSWORD"
 
-# create backup user
-
-psql -c "CREATE USER $POSTGRESQL_BACKUP_USER SUPERUSER  password '$POSTGRESQL_BACKUP_PASSWORD';"
-psql -c "ALTER USER $POSTGRESQL_BACKUP_USER set default_transaction_read_only = on;"
+# create backup user with 'backup' database
+psql --variable=user="$POSTGRESQL_BACKUP_USER" \
+     --variable=password="$POSTGRESQL_BACKUP_PASSWORD" \
+     <<<"
+CREATE USER :user SUPERUSER  password :'password';
+CREATE DATABASE backup OWNER = :user;
+ALTER USER :user set default_transaction_read_only = on;
+"

From 7dabc9340f60418b440f6a3792518f335d27b2d2 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 7 Feb 2018 16:07:08 +0100
Subject: [PATCH 064/509] run_test: introduce $TESTS variable

If the $TESTS variable is set to space-separated list of test-case
names, only those will be executed, e.g.:

$ make test VERSIONS=9.5 TESTS=run_s2i_test
---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 4bcd0fcd..57cb5224 100755
--- a/test/run_test
+++ b/test/run_test
@@ -648,4 +648,4 @@ POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0
 POSTGRESQL_SHARED_BUFFERS=32MB
 
 # Run the chosen tests
-TEST_LIST=${@:-$TEST_LIST} run_all_tests
+TEST_LIST=${TESTS:-$TEST_LIST} run_all_tests

From cb90095e8ca40155db6d67a914994f4c692a0faf Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 13 Feb 2018 10:30:24 +0100
Subject: [PATCH 065/509] Backport latest dockerfile changes into distgen
 template

---
 specs/multispec.yml | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index bbd37e96..a9851f0c 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -24,10 +24,7 @@ specs:
          # in base RHEL
        environment_setup: >-4
            yum install -y yum-utils gettext && \
-               yum-config-manager --disable \* &> /dev/null && \
-               yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-               yum-config-manager --enable rhel-7-server-rpms && \
-               yum-config-manager --enable rhel-7-server-optional-rpms && \
+               prepare-yum-repositories rhel-server-rhscl-7-rpms && \
        staging_repo_setup: ""
        rhscl3_introduced:
          - "9.6"
@@ -61,4 +58,4 @@ specs:
       enabled_collection: "rh-postgresql96"
       openshift_tags: "database,postgresql,postgresql96,rh-postgresql96"
       redhat_component: "rh-postgresql96-docker"
-      stable: False
+      stable: True

From 212c4fcf2361cbb4d6e6495f02330e2f2b32bf4c Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 14 Feb 2018 07:47:57 +0100
Subject: [PATCH 066/509] fast-forward the 'common' sub-project

This is to fix build-system regression
https://github.com/sclorg/container-common-scripts/pull/60

And for:
https://github.com/sclorg/container-common-scripts/pull/62
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index f3283fa0..2211a111 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit f3283fa09175e4e4095da064798f69b969d986bc
+Subproject commit 2211a111c44171559075bfb3d4ecbe913dc64b41

From 7578ec7a4619470cbeb5eddef3f7ef8c7fdfdfa3 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 15 Feb 2018 10:04:42 +0100
Subject: [PATCH 067/509] tests-openshift: race condition in getting pod IP

After successful pod scale to 2, it takes some time to have the
replica ready, and it probably takes some time to get allocated
the IP address.  So rather wait for the pod to be ready before we
expect that the IP is available.

We could in future make the 'ct_os_get_pod_ip' accept some option
which would wait till the IP is available.
---
 test/run-openshift | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/run-openshift b/test/run-openshift
index ae330d87..08fe5639 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -251,6 +251,7 @@ function test_postgresql_replication() {
   ct_os_wait_rc_ready "$slave_service_name" 60
   slave_name=$(ct_os_get_pod_name "$slave_service_name")
   for slave in $slave_name; do
+    ct_os_wait_pod_ready "$slave" 60
     slave_ip=$(ct_os_get_pod_ip "$slave")
     check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
   done

From 7cd4f0ecec5f7f7fef6965445da93d72dea6e3eb Mon Sep 17 00:00:00 2001
From: Ben Parees <bparees@redhat.com>
Date: Mon, 26 Feb 2018 16:43:27 -0500
Subject: [PATCH 068/509] add imagestreams to image repo

---
 imagestreams/postgresql-centos7.json | 88 ++++++++++++++++++++++++++++
 imagestreams/postgresql-rhel7.json   | 88 ++++++++++++++++++++++++++++
 2 files changed, 176 insertions(+)
 create mode 100644 imagestreams/postgresql-centos7.json
 create mode 100644 imagestreams/postgresql-rhel7.json

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
new file mode 100644
index 00000000..dc6654fe
--- /dev/null
+++ b/imagestreams/postgresql-centos7.json
@@ -0,0 +1,88 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "9.6"
+        }
+      },
+      {
+        "name": "9.2",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.2",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.2 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.2/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "hidden,postgresql",
+          "version": "9.2"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/openshift/postgresql-92-centos7:latest"
+        }
+      },
+      {
+        "name": "9.4",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.4",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.4 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.4"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-94-centos7:latest"
+        }
+      },
+      {
+        "name": "9.5",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.5",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.5/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.5"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-95-centos7:latest"
+        }
+      },
+      {
+        "name": "9.6",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-96-centos7:latest"
+        }
+      }
+    ]
+  }
+}
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
new file mode 100644
index 00000000..3a6374de
--- /dev/null
+++ b/imagestreams/postgresql-rhel7.json
@@ -0,0 +1,88 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "9.6"
+        }
+      },
+      {
+        "name": "9.2",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.2",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.2 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.2/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "hidden,postgresql",
+          "version": "9.2"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.access.redhat.com/openshift3/postgresql-92-rhel7:latest"
+        }
+      },
+      {
+        "name": "9.4",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.4",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.4 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.4"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.access.redhat.com/rhscl/postgresql-94-rhel7:latest"
+        }
+      },
+      {
+        "name": "9.5",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.5",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.5/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.5"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest"
+        }
+      },
+      {
+        "name": "9.6",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.access.redhat.com/rhscl/postgresql-96-rhel7:latest"
+        }
+      }
+    ]
+  }
+}

From e306e27176fb0f737a1545495bd4ebc7461b4ab9 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 15 Feb 2018 19:16:53 +0100
Subject: [PATCH 069/509] tests: new tests for postgresql-cfg/ hook and
 readiness probe

---
 examples/custom-config/README                 |  2 +
 .../postgresql-cfg/10_shared_buffers.conf     |  1 +
 test/run_test                                 | 72 +++++++++++++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 examples/custom-config/README
 create mode 100644 examples/custom-config/postgresql-cfg/10_shared_buffers.conf

diff --git a/examples/custom-config/README b/examples/custom-config/README
new file mode 100644
index 00000000..0c785211
--- /dev/null
+++ b/examples/custom-config/README
@@ -0,0 +1,2 @@
+Bind-mount this directory under /opt/app-root/src in container, and all the
+*.conf files from postgresql-cfg/ files will be included to postgresql.conf.
diff --git a/examples/custom-config/postgresql-cfg/10_shared_buffers.conf b/examples/custom-config/postgresql-cfg/10_shared_buffers.conf
new file mode 100644
index 00000000..5c23ff78
--- /dev/null
+++ b/examples/custom-config/postgresql-cfg/10_shared_buffers.conf
@@ -0,0 +1 @@
+shared_buffers = 111MB
diff --git a/test/run_test b/test/run_test
index 57cb5224..ebbeb471 100755
--- a/test/run_test
+++ b/test/run_test
@@ -25,6 +25,7 @@ run_replication_test
 run_master_restart_test
 run_doc_test
 run_s2i_test
+run_test_cfg_hook
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -39,6 +40,20 @@ images_to_clean=
 files_to_clean=
 test_dir="$(readlink -f "$(dirname "$0")")"
 
+_cleanup_commands_space=
+_cleanup_commands=
+
+add_cleanup_command ()
+{
+    local cmd= space=
+    for arg; do
+        cmd+="$space$(printf "%q" "$arg")"
+        space=' '
+    done
+    _cleanup_commands+="$_cleanup_commands_space$cmd"
+    _cleanup_commands_space='
+'
+}
 function cleanup() {
   for cidfile in $CIDFILE_DIR/* ; do
     CONTAINER=$(cat $cidfile)
@@ -59,6 +74,9 @@ function cleanup() {
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
   ct_path_foreach "$images_to_clean" cleanup_image
   ct_path_foreach "$files_to_clean" rm
+  echo "$_cleanup_commands" | while read -r line; do
+    eval "$line"
+  done
 }
 trap cleanup EXIT
 
@@ -238,6 +256,29 @@ function test_config_option() {
   docker exec $(get_cid ${name}) grep -q "${setting} = ${value}" /var/lib/pgsql/openshift-custom-postgresql.conf
 }
 
+
+# wait_ready
+# ----------
+# Wait until the PG container becomes ready
+wait_ready ()
+{
+  while ! docker exec "$(get_cid "$1")" /usr/libexec/check-container ; do
+    sleep 1
+  done
+}
+
+
+# assert_runtime_option option value
+# ----------------------------------
+assert_runtime_option ()
+{
+  local name=$1 option=$2 value=$3
+  wait_ready "$name"
+  set -- $(docker exec "$(get_cid "$name")" bash -c "psql -tA -c 'SHOW $option;'")
+  test "$value" = "$1"
+}
+
+
 function run_configuration_tests() {
   local name=$1 ; shift
   echo "  Testing image configuration settings"
@@ -635,6 +676,37 @@ function run_general_tests() {
   DB=postgres DOCKER_ARGS="-u 12345" ADMIN_PASS=rOOt run_tests only_admin_altuid
 }
 
+run_test_cfg_hook()
+{
+  local volume_dir name=pg-test-cfg-dir
+  volume_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
+  add_cleanup_command /bin/rm -rf "$volume_dir"
+  setfacl -R -m u:26:rwx "$volume_dir"
+  cp -r "$test_dir"/../examples/custom-config/* "$volume_dir"
+  setfacl -R -m u:26:rwx "$volume_dir"
+
+  DOCKER_ARGS="
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-v $volume_dir:/opt/app-root/src:Z
+  " create_container "$name"
+  assert_runtime_option "$name" shared_buffers 111MB
+
+  # Check that POSTGRESQL_SHARED_BUFFERS has effect.
+  DOCKER_ARGS="
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-e POSTGRESQL_SHARED_BUFFERS=113MB
+  " create_container "$name-2"
+  assert_runtime_option "$name-2" shared_buffers 113MB
+
+  # Check that volume has priority over POSTGRESQL_SHARED_BUFFERS.
+  DOCKER_ARGS="
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-e POSTGRESQL_SHARED_BUFFERS=113MB
+-v $volume_dir:/opt/app-root/src:Z
+  " create_container "$name-3"
+  assert_runtime_option "$name-3" shared_buffers 111MB
+}
+
 function run_all_tests() {
   for test_case in $TEST_LIST; do
     : "Running test $test_case"

From 1e48006604a488a3ff5a3325ddc362ad17b4ed6a Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 5 Mar 2018 11:42:42 +0100
Subject: [PATCH 070/509] make: fix upgrade-tests target

That's fix for 4321c9e0dfd2743d291.
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index d1d72c65..0f0f72aa 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ include common/common.mk
 
 # Additional upgrade tests.  Not hooked into CI ATM.
 upgrade-tests: $(VERSIONS)
-	test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
+	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
 
 DG = /usr/bin/dg
 DG_EXEC = ${DG} --max-passes 25 --template Dockerfile.template --multispec specs/multispec.yml

From 70430e727deeea59067308021dd23b6fd2fd92f6 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 5 Mar 2018 15:37:07 +0100
Subject: [PATCH 071/509] Remove mentions of docker from README

---
 9.4/root/usr/share/container-scripts/postgresql/README.md    | 2 +-
 9.5/root/usr/share/container-scripts/postgresql/README.md    | 2 +-
 README.md                                                    | 2 +-
 latest/root/usr/share/container-scripts/postgresql/README.md | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index 10337ec7..a464994c 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -101,7 +101,7 @@ You can also set the following mount points by passing the `-v /host/dir:/contai
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Typically (unless you use `docker run -u` option) processes in docker container
+Typically (unless you use `docker run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index d57d5934..5078d03e 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -101,7 +101,7 @@ You can also set the following mount points by passing the `-v /host/dir:/contai
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Typically (unless you use `docker run -u` option) processes in docker container
+Typically (unless you use `docker run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
diff --git a/README.md b/README.md
index 88fed7f8..b3855311 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ official [OpenShift Documentation](https://docs.openshift.org/latest/using_image
 
 For more information about contributing, see
 [the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).
-For more information about concepts used in these docker images, see the
+For more information about concepts used in these container images, see the
 [Landing page](https://github.com/sclorg/welcome).
 
 
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 87cd502f..5c97953f 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -101,7 +101,7 @@ You can also set the following mount points by passing the `-v /host/dir:/contai
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Typically (unless you use `docker run -u` option) processes in docker container
+Typically (unless you use `docker run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 

From 05a62a762f13c0fd6d85f3d8773ed6be135315b0 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 7 Mar 2018 12:45:26 +0100
Subject: [PATCH 072/509] Some more Docker mentions removal

---
 9.2/root/usr/share/container-scripts/postgresql/README.md    | 2 +-
 9.4/root/usr/share/container-scripts/postgresql/README.md    | 2 +-
 9.5/root/usr/share/container-scripts/postgresql/README.md    | 2 +-
 README.md                                                    | 2 +-
 latest/root/usr/share/container-scripts/postgresql/README.md | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/9.2/root/usr/share/container-scripts/postgresql/README.md b/9.2/root/usr/share/container-scripts/postgresql/README.md
index f8f4176c..45af59a9 100644
--- a/9.2/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.2/root/usr/share/container-scripts/postgresql/README.md
@@ -1,4 +1,4 @@
-PostgreSQL Docker image
+PostgreSQL container image
 =======================
 
 **The PostgreSQL 9.2 image is deprecated.**
\ No newline at end of file
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
index a464994c..38665d65 100644
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.4/root/usr/share/container-scripts/postgresql/README.md
@@ -1,4 +1,4 @@
-PostgreSQL 9.4 SQL Database Server Docker image
+PostgreSQL 9.4 SQL Database Server container image
 ===============================================
 
 This container image includes PostgreSQL 9.4 SQL database server for OpenShift and general usage.
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
index 5078d03e..5fc5b00f 100644
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ b/9.5/root/usr/share/container-scripts/postgresql/README.md
@@ -1,4 +1,4 @@
-PostgreSQL 9.5 SQL Database Server Docker image
+PostgreSQL 9.5 SQL Database Server container image
 ===============================================
 
 This container image includes PostgreSQL 9.5 SQL database server for OpenShift and general usage.
diff --git a/README.md b/README.md
index b3855311..e74c2701 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-PostgreSQL Docker images
+PostgreSQL container images
 ========================
 
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
index 5c97953f..623dc1e9 100644
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -1,4 +1,4 @@
-PostgreSQL 9.6 SQL Database Server Docker image
+PostgreSQL 9.6 SQL Database Server container image
 ===============================================
 
 This container image includes PostgreSQL 9.6 SQL database server for OpenShift and general usage.

From b5b29773883014fcb969adc4d6bef37d092013af Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 6 Mar 2018 15:30:42 +0100
Subject: [PATCH 073/509] run_test: use ct_random_string function

.. which is new library function which should work fine for
environments with blocked SIGPIPE.  See discussion in:
https://github.com/sclorg/postgresql-container/commit/49a01540bb31
---
 common        | 2 +-
 test/run_test | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common b/common
index 2211a111..6adc2c4c 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2211a111c44171559075bfb3d4ecbe913dc64b41
+Subproject commit 6adc2c4c58628ece3e9cd78b7fbd1021c3c1dfdd
diff --git a/test/run_test b/test/run_test
index ebbeb471..d7f26da4 100755
--- a/test/run_test
+++ b/test/run_test
@@ -649,7 +649,7 @@ run_s2i_test() {
 
   echo "  Testing s2i build"
 
-  local s2i_image_name=$IMAGE_NAME-testapp_$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 10 | head -n 1)
+  local s2i_image_name=$IMAGE_NAME-testapp_$(ct_random_string)
   ct_path_append images_to_clean "$s2i_image_name"
 
   s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name"

From 5136552d8295de4884c217192eeab5e45c5a58ce Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Sat, 10 Mar 2018 12:20:48 +0100
Subject: [PATCH 074/509] openshift: test dev-images against both dev/released
 templates

---
 test/run-openshift | 60 ++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/test/run-openshift b/test/run-openshift
index 08fe5639..a4a268e5 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -146,7 +146,6 @@ function test_postgresql_update() {
   local image_name_no_namespace=${image_name##*/}
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
-  local template="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/postgresql-persistent-template.json"
   local registry="" old_image="" pod_ip=""
 
   case $OS in
@@ -161,33 +160,38 @@ function test_postgresql_update() {
   old_image="$registry/$image_name"
   docker pull "$old_image" 2>/dev/null
 
-  ct_os_new_project
-  ct_os_upload_image "$old_image" "postgresql:$VERSION"
-
-  # Use remote template to make sure the new image works regardless of template changes
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="$service_name" \
-                              POSTGRESQL_USER="$user" \
-                              POSTGRESQL_PASSWORD="$pass" \
-                              POSTGRESQL_DATABASE="$db"
-
-  ct_os_wait_pod_ready "${service_name}" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  pod_ip=$(ct_os_get_service_ip "$service_name")
-  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-
-  ct_os_upload_image "$image_name" "postgresql:$VERSION"
-  : "Waiting for a few seconds while the pods get restarted"
-  sleep 5
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-  ct_os_delete_project
+  # Use also remote template to make sure the new image works regardless of
+  # template changes
+  for template in \
+        "https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/postgresql-persistent-template.json" \
+        "$TEMPLATES/postgresql-persistent-template.json"
+  do
+    ct_os_new_project
+    ct_os_upload_image "$old_image" "postgresql:$VERSION"
+    ct_os_deploy_template_image "$template" \
+                                NAMESPACE="$(oc project -q)" \
+                                POSTGRESQL_VERSION="$VERSION" \
+                                DATABASE_SERVICE_NAME="$service_name" \
+                                POSTGRESQL_USER="$user" \
+                                POSTGRESQL_PASSWORD="$pass" \
+                                POSTGRESQL_DATABASE="$db"
+
+    ct_os_wait_pod_ready "${service_name}" 60
+    check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+    pod_ip=$(ct_os_get_service_ip "$service_name")
+    insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+
+    ct_os_upload_image "$image_name" "postgresql:$VERSION"
+    : "Waiting for a few seconds while the pods get restarted"
+    sleep 5
+
+    ct_os_wait_pod_ready "$service_name" 60
+    check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+    check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+    ct_os_delete_project
+  done
 }
 
 function test_postgresql_replication() {

From ee344601ea71eec99993c7c06be2b9a5738a96b1 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:11:18 +0100
Subject: [PATCH 075/509] Create src directory from latest (step one)

---
 {latest => src}/Dockerfile                                        | 0
 {latest => src}/Dockerfile.fedora                                 | 0
 {latest => src}/Dockerfile.rhel7                                  | 0
 {latest => src}/README.md                                         | 0
 {latest => src}/cccp.yml                                          | 0
 {latest => src}/root/usr/bin/cgroup-limits                        | 0
 {latest => src}/root/usr/bin/container-entrypoint                 | 0
 {latest => src}/root/usr/bin/run-postgresql                       | 0
 {latest => src}/root/usr/bin/run-postgresql-master                | 0
 {latest => src}/root/usr/bin/run-postgresql-slave                 | 0
 {latest => src}/root/usr/bin/usage                                | 0
 {latest => src}/root/usr/libexec/check-container                  | 0
 {latest => src}/root/usr/libexec/fix-permissions                  | 0
 .../root/usr/share/container-scripts/postgresql/README.md         | 0
 .../root/usr/share/container-scripts/postgresql/common.sh         | 0
 .../openshift-custom-postgresql-replication.conf.template         | 0
 .../postgresql/openshift-custom-postgresql.conf.template          | 0
 .../postgresql/openshift-custom-recovery.conf.template            | 0
 .../root/usr/share/container-scripts/postgresql/scl_enable        | 0
 .../usr/share/container-scripts/postgresql/start/set_passwords.sh | 0
 {latest => src}/s2i/bin/assemble                                  | 0
 {latest => src}/s2i/bin/run                                       | 0
 {latest => src}/s2i/bin/usage                                     | 0
 {latest => src}/test                                              | 0
 24 files changed, 0 insertions(+), 0 deletions(-)
 rename {latest => src}/Dockerfile (100%)
 rename {latest => src}/Dockerfile.fedora (100%)
 rename {latest => src}/Dockerfile.rhel7 (100%)
 rename {latest => src}/README.md (100%)
 rename {latest => src}/cccp.yml (100%)
 rename {latest => src}/root/usr/bin/cgroup-limits (100%)
 rename {latest => src}/root/usr/bin/container-entrypoint (100%)
 rename {latest => src}/root/usr/bin/run-postgresql (100%)
 rename {latest => src}/root/usr/bin/run-postgresql-master (100%)
 rename {latest => src}/root/usr/bin/run-postgresql-slave (100%)
 rename {latest => src}/root/usr/bin/usage (100%)
 rename {latest => src}/root/usr/libexec/check-container (100%)
 rename {latest => src}/root/usr/libexec/fix-permissions (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/README.md (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/common.sh (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/scl_enable (100%)
 rename {latest => src}/root/usr/share/container-scripts/postgresql/start/set_passwords.sh (100%)
 rename {latest => src}/s2i/bin/assemble (100%)
 rename {latest => src}/s2i/bin/run (100%)
 rename {latest => src}/s2i/bin/usage (100%)
 rename {latest => src}/test (100%)

diff --git a/latest/Dockerfile b/src/Dockerfile
similarity index 100%
rename from latest/Dockerfile
rename to src/Dockerfile
diff --git a/latest/Dockerfile.fedora b/src/Dockerfile.fedora
similarity index 100%
rename from latest/Dockerfile.fedora
rename to src/Dockerfile.fedora
diff --git a/latest/Dockerfile.rhel7 b/src/Dockerfile.rhel7
similarity index 100%
rename from latest/Dockerfile.rhel7
rename to src/Dockerfile.rhel7
diff --git a/latest/README.md b/src/README.md
similarity index 100%
rename from latest/README.md
rename to src/README.md
diff --git a/latest/cccp.yml b/src/cccp.yml
similarity index 100%
rename from latest/cccp.yml
rename to src/cccp.yml
diff --git a/latest/root/usr/bin/cgroup-limits b/src/root/usr/bin/cgroup-limits
similarity index 100%
rename from latest/root/usr/bin/cgroup-limits
rename to src/root/usr/bin/cgroup-limits
diff --git a/latest/root/usr/bin/container-entrypoint b/src/root/usr/bin/container-entrypoint
similarity index 100%
rename from latest/root/usr/bin/container-entrypoint
rename to src/root/usr/bin/container-entrypoint
diff --git a/latest/root/usr/bin/run-postgresql b/src/root/usr/bin/run-postgresql
similarity index 100%
rename from latest/root/usr/bin/run-postgresql
rename to src/root/usr/bin/run-postgresql
diff --git a/latest/root/usr/bin/run-postgresql-master b/src/root/usr/bin/run-postgresql-master
similarity index 100%
rename from latest/root/usr/bin/run-postgresql-master
rename to src/root/usr/bin/run-postgresql-master
diff --git a/latest/root/usr/bin/run-postgresql-slave b/src/root/usr/bin/run-postgresql-slave
similarity index 100%
rename from latest/root/usr/bin/run-postgresql-slave
rename to src/root/usr/bin/run-postgresql-slave
diff --git a/latest/root/usr/bin/usage b/src/root/usr/bin/usage
similarity index 100%
rename from latest/root/usr/bin/usage
rename to src/root/usr/bin/usage
diff --git a/latest/root/usr/libexec/check-container b/src/root/usr/libexec/check-container
similarity index 100%
rename from latest/root/usr/libexec/check-container
rename to src/root/usr/libexec/check-container
diff --git a/latest/root/usr/libexec/fix-permissions b/src/root/usr/libexec/fix-permissions
similarity index 100%
rename from latest/root/usr/libexec/fix-permissions
rename to src/root/usr/libexec/fix-permissions
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/README.md
rename to src/root/usr/share/container-scripts/postgresql/README.md
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/common.sh
rename to src/root/usr/share/container-scripts/postgresql/common.sh
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
rename to src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
rename to src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
rename to src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
diff --git a/latest/root/usr/share/container-scripts/postgresql/scl_enable b/src/root/usr/share/container-scripts/postgresql/scl_enable
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/scl_enable
rename to src/root/usr/share/container-scripts/postgresql/scl_enable
diff --git a/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
similarity index 100%
rename from latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
rename to src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
diff --git a/latest/s2i/bin/assemble b/src/s2i/bin/assemble
similarity index 100%
rename from latest/s2i/bin/assemble
rename to src/s2i/bin/assemble
diff --git a/latest/s2i/bin/run b/src/s2i/bin/run
similarity index 100%
rename from latest/s2i/bin/run
rename to src/s2i/bin/run
diff --git a/latest/s2i/bin/usage b/src/s2i/bin/usage
similarity index 100%
rename from latest/s2i/bin/usage
rename to src/s2i/bin/usage
diff --git a/latest/test b/src/test
similarity index 100%
rename from latest/test
rename to src/test

From 7d6b80dacb92768bea0ea14a3a69324af03ca5a4 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:12:08 +0100
Subject: [PATCH 076/509] Create src directory from latest (step two)

---
 latest/Dockerfile                             |  78 ++++
 latest/Dockerfile.fedora                      |  68 +++
 latest/Dockerfile.rhel7                       |  81 ++++
 latest/README.md                              |   1 +
 latest/cccp.yml                               |   1 +
 latest/root/usr/bin/cgroup-limits             |  92 ++++
 latest/root/usr/bin/container-entrypoint      |   3 +
 latest/root/usr/bin/run-postgresql            |  38 ++
 latest/root/usr/bin/run-postgresql-master     |   5 +
 latest/root/usr/bin/run-postgresql-slave      |  37 ++
 latest/root/usr/bin/usage                     |   4 +
 latest/root/usr/libexec/check-container       |  39 ++
 latest/root/usr/libexec/fix-permissions       |   7 +
 .../container-scripts/postgresql/README.md    | 299 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 436 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   9 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  14 +
 latest/s2i/bin/assemble                       |  14 +
 latest/s2i/bin/run                            |   1 +
 latest/s2i/bin/usage                          |   1 +
 latest/test                                   |   1 +
 24 files changed, 1260 insertions(+)
 create mode 100644 latest/Dockerfile
 create mode 100644 latest/Dockerfile.fedora
 create mode 100644 latest/Dockerfile.rhel7
 create mode 120000 latest/README.md
 create mode 100644 latest/cccp.yml
 create mode 100755 latest/root/usr/bin/cgroup-limits
 create mode 100755 latest/root/usr/bin/container-entrypoint
 create mode 100755 latest/root/usr/bin/run-postgresql
 create mode 100755 latest/root/usr/bin/run-postgresql-master
 create mode 100755 latest/root/usr/bin/run-postgresql-slave
 create mode 100755 latest/root/usr/bin/usage
 create mode 100755 latest/root/usr/libexec/check-container
 create mode 100755 latest/root/usr/libexec/fix-permissions
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 latest/s2i/bin/assemble
 create mode 120000 latest/s2i/bin/run
 create mode 100755 latest/s2i/bin/usage
 create mode 120000 latest/test

diff --git a/latest/Dockerfile b/latest/Dockerfile
new file mode 100644
index 00000000..dd242c1e
--- /dev/null
+++ b/latest/Dockerfile
@@ -0,0 +1,78 @@
+FROM centos/s2i-core-centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.6" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
+      name="centos/postgresql-96-centos7" \
+      com.redhat.component="rh-postgresql96-docker" \
+      version="9.6" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-96-centos7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql96
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/latest/Dockerfile.fedora b/latest/Dockerfile.fedora
new file mode 100644
index 00000000..71f78a10
--- /dev/null
+++ b/latest/Dockerfile.fedora
@@ -0,0 +1,68 @@
+FROM registry.fedoraproject.org/fedora:26
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    RELEASE=1 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.6" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql96" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="$FGC/$NAME" \
+      version="0" \
+      release="$RELEASE.$DISTTAG" \
+      architecture="$ARCH" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME" \
+      help="/help.1"
+
+EXPOSE 5432
+
+ADD root /
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils python2 " && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+VOLUME ["/var/lib/pgsql/data"]
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
new file mode 100644
index 00000000..0934b6d3
--- /dev/null
+++ b/latest/Dockerfile.rhel7
@@ -0,0 +1,81 @@
+FROM rhscl/s2i-core-rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=9.6 \
+    POSTGRESQL_PREV_VERSION=9.5 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary=$SUMMARY \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 9.6" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
+      name="rhscl/postgresql-96-rhel7" \
+      com.redhat.component="rh-postgresql96-docker" \
+      version="1" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum clean all && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql && \
+    /usr/libexec/fix-permissions /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql96
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/latest/README.md b/latest/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/latest/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/latest/cccp.yml b/latest/cccp.yml
new file mode 100644
index 00000000..fb90f577
--- /dev/null
+++ b/latest/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-96-centos7
diff --git a/latest/root/usr/bin/cgroup-limits b/latest/root/usr/bin/cgroup-limits
new file mode 100755
index 00000000..b9d4edc2
--- /dev/null
+++ b/latest/root/usr/bin/cgroup-limits
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+"""
+Script for parsing cgroup information
+
+This script will read some limits from the cgroup system and parse
+them, printing out "VARIABLE=VALUE" on each line for every limit that is
+successfully read. Output of this script can be directly fed into
+bash's export command. Recommended usage from a bash script:
+
+    set -o errexit
+    export_vars=$(cgroup-limits) ; export $export_vars
+
+Variables currently supported:
+    MAX_MEMORY_LIMIT_IN_BYTES
+        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
+        currently constant value of 9223372036854775807.
+    MEMORY_LIMIT_IN_BYTES
+        Maximum amount of user memory in bytes. If this value is set
+        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
+        there is no limit set. The value is taken from
+        /sys/fs/cgroup/memory/memory.limit_in_bytes
+    NUMBER_OF_CORES
+        Number of detected CPU cores that can be used. This value is
+        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
+    NO_MEMORY_LIMIT
+        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
+        can act as if no memory limit was set. Undefined otherwise.
+"""
+
+from __future__ import print_function
+import sys
+
+
+def _read_file(path):
+    try:
+        with open(path, 'r') as f:
+            return f.read().strip()
+    except IOError:
+        return None
+
+
+def get_memory_limit():
+    """
+    Read memory limit, in bytes.
+    """
+
+    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
+    if limit is None or not limit.isdigit():
+        print("Warning: Can't detect memory limit from cgroups",
+              file=sys.stderr)
+        return None
+    return int(limit)
+
+
+def get_number_of_cores():
+    """
+    Read number of CPU cores.
+    """
+
+    core_count = 0
+
+    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
+    if line is None:
+        print("Warning: Can't detect number of CPU cores from cgroups",
+              file=sys.stderr)
+        return None
+
+    for group in line.split(','):
+        core_ids = list(map(int, group.split('-')))
+        if len(core_ids) == 2:
+            core_count += core_ids[1] - core_ids[0] + 1
+        else:
+            core_count += 1
+
+    return core_count
+
+
+if __name__ == "__main__":
+    env_vars = {
+        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
+        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
+        "NUMBER_OF_CORES": get_number_of_cores()
+    }
+
+    env_vars = {k: v for k, v in env_vars.items() if v is not None}
+
+    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
+        env_vars["NO_MEMORY_LIMIT"] = "true"
+
+    for key, value in env_vars.items():
+        print("{0}={1}".format(key, value))
diff --git a/latest/root/usr/bin/container-entrypoint b/latest/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/latest/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..48ff4258
--- /dev/null
+++ b/latest/root/usr/bin/run-postgresql
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+pg_ctl -w start -o "-h ''"
+if $PG_INITIALIZED ; then
+    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
+    migrate_db
+    create_users
+fi
+
+process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/latest/root/usr/bin/run-postgresql-master b/latest/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/latest/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/latest/root/usr/bin/run-postgresql-slave b/latest/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..be327a93
--- /dev/null
+++ b/latest/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/recovery.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/latest/root/usr/bin/usage b/latest/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/latest/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/latest/root/usr/libexec/check-container b/latest/root/usr/libexec/check-container
new file mode 100755
index 00000000..bee6acc8
--- /dev/null
+++ b/latest/root/usr/libexec/check-container
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+check=ready
+case $1 in
+    --live) check=live ;;
+esac
+
+while true; do
+    # Wait until the /bin/postgres is executed.
+    case $(readlink -f /proc/1/exe) in
+        *bash) sleep 0.2; continue ;;
+        *) break ;;
+    esac
+done
+
+# Timeout is infinite (openshift template has the timeout pre-set)
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
+rc=$?
+
+# we are ready only if the db accepts connections
+test $rc -eq 0 && exit 0
+
+# container is live also during pg cluster start-up
+test $rc -eq 1 && test $check = live && exit 0
+
+exit 1
diff --git a/latest/root/usr/libexec/fix-permissions b/latest/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..ebcdd3d4
--- /dev/null
+++ b/latest/root/usr/libexec/fix-permissions
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Fix permissions on the given directory to allow group read/write of 
+# regular files and execute of directories.
+find "$1" -exec chown postgres {} \;
+find "$1" -exec chgrp 0 {} \;
+find "$1" -exec chmod g+rw {} \;
+find "$1" -type d -exec chmod g+x {} +
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..623dc1e9
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,299 @@
+PostgreSQL 9.6 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 9.6 SQL database server for OpenShift and general usage.
+Users can choose between RHEL and CentOS based images.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7)
+as registry.access.redhat.com/rhscl/postgresql-96-rhel7.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-96-centos7/)
+as centos/postgresql-96-centos7.
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-96-rhel7` image.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/9.6/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.6/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`docker stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `docker run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+----------------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ docker run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+--------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 9.5 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended using
+[source-to-image](https://github.com/openshift/source-to-image).
+
+For example to build customized image `new-postgresql`
+with configuration in `~/image-configuration/` run:
+
+
+```
+$ s2i build ~/image-configuration/ postgresql new-postgresql
+```
+
+The directory passed to `s2i build` should contain one or more of the
+following directories:
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During `s2i build` all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    docker logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
+for RHEL is called Dockerfile.rhel7.
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..757b3a1e
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,436 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
+psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER (regex: '$psql_identifier_regex')
+  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
+  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
+    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
+    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v ^postgres /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/9.6/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files finds file for image extending
+function get_matched_files() {
+  local custom_dir default_dir
+  custom_dir="$1"
+  default_dir="$2"
+  files_matched="$3"
+  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+}
+
+# process_extending_files process extending files in $1 and $2 directories
+# - source all *.sh files
+#   (if there are files with same name source only file from $1)
+function process_extending_files() {
+  local custom_dir default_dir
+  custom_dir=$1
+  default_dir=$2
+
+  while read filename ; do
+    echo "=> sourcing $filename ..."
+    # Custom file is prefered
+    if [ -f $custom_dir/$filename ]; then
+      source $custom_dir/$filename
+    elif [ -f $default_dir/$filename ]; then
+      source $default_dir/$filename
+    fi
+  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+}
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..26d56693
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,9 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+standby_mode = on
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/latest/root/usr/share/container-scripts/postgresql/scl_enable b/latest/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..f14ff46a
--- /dev/null
+++ b/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
+psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+fi
diff --git a/latest/s2i/bin/assemble b/latest/s2i/bin/assemble
new file mode 100755
index 00000000..c1472bdc
--- /dev/null
+++ b/latest/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions ./
diff --git a/latest/s2i/bin/run b/latest/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/latest/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/latest/s2i/bin/usage b/latest/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/latest/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/latest/test b/latest/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/latest/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file

From 03dc0c47a84d04d2bcc8294cae14e41f66c96a1d Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:12:55 +0100
Subject: [PATCH 077/509] History for Dockerfile.template (step one)

---
 Dockerfile.template | 88 ---------------------------------------------
 1 file changed, 88 deletions(-)
 delete mode 100644 Dockerfile.template

diff --git a/Dockerfile.template b/Dockerfile.template
deleted file mode 100644
index d85a08ed..00000000
--- a/Dockerfile.template
+++ /dev/null
@@ -1,88 +0,0 @@
-FROM {{ spec.s2i_base }}
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION={{ spec.version }} \
-    POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL {{ spec.version }}" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="{{ spec.openshift_tags }}" \
-      name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
-      com.redhat.component="{{ spec.redhat_component }}" \
-{%- if spec.version in spec.rhscl3_introduced %}
-      version="1" \
-{%- else %}
-      version="{{ spec.version }}" \
-{%- endif %}
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-{%- if spec.repo_enable_reason %}
-{{ spec.repo_enable_reason }}
-{%- endif %}
-RUN {{ spec.environment_setup }}
-{%- if not spec.stable and spec.staging_repo_setup %}
-{{ spec.staging_repo_setup }}
-{%- endif %}
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS={{ spec.enabled_collection }}
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]

From ce7fdfae357a3b76857a2be2a61d2f1a5364187b Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:15:02 +0100
Subject: [PATCH 078/509] History for Dockerfile.template (step two)

---
 src/Dockerfile => Dockerfile.template | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename src/Dockerfile => Dockerfile.template (100%)

diff --git a/src/Dockerfile b/Dockerfile.template
similarity index 100%
rename from src/Dockerfile
rename to Dockerfile.template

From b70a9c6ba5dcbf8b0ca7785210b006d23222cdcc Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Fri, 23 Feb 2018 10:10:59 +0100
Subject: [PATCH 079/509] Add manifest for generation and templates

---
 Dockerfile.template                           | 78 ----------------
 Makefile                                      |  9 +-
 manifest.sh                                   | 92 +++++++++++++++++++
 specs/multispec.yml                           |  9 ++
 src/{Dockerfile.rhel7 => Dockerfile}          | 35 ++++---
 src/cccp.yml                                  |  2 +-
 .../container-scripts/postgresql/README.md    | 22 ++---
 .../container-scripts/postgresql/common.sh    |  4 +-
 8 files changed, 138 insertions(+), 113 deletions(-)
 delete mode 100644 Dockerfile.template
 create mode 100644 manifest.sh
 rename src/{Dockerfile.rhel7 => Dockerfile} (75%)

diff --git a/Dockerfile.template b/Dockerfile.template
deleted file mode 100644
index dd242c1e..00000000
--- a/Dockerfile.template
+++ /dev/null
@@ -1,78 +0,0 @@
-FROM centos/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
-      name="centos/postgresql-96-centos7" \
-      com.redhat.component="rh-postgresql96-docker" \
-      version="9.6" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-96-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql96
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/Makefile b/Makefile
index 0f0f72aa..73a47347 100644
--- a/Makefile
+++ b/Makefile
@@ -13,11 +13,4 @@ include common/common.mk
 upgrade-tests: $(VERSIONS)
 	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
 
-DG = /usr/bin/dg
-DG_EXEC = ${DG} --max-passes 25 --template Dockerfile.template --multispec specs/multispec.yml
-
-generate_dockerfiles:
-	for version in ${VERSIONS}; do \
-		${DG_EXEC} --distro centos-7-x86_64.yaml --multispec-selector version=$${version} --output $${version}/Dockerfile; \
-		${DG_EXEC} --distro rhel-7-x86_64.yaml --multispec-selector version=$${version} --output $${version}/Dockerfile.rhel7; \
-	done
+build-serial: generate
diff --git a/manifest.sh b/manifest.sh
new file mode 100644
index 00000000..be08be08
--- /dev/null
+++ b/manifest.sh
@@ -0,0 +1,92 @@
+# Manifest for image directories creation
+# every dest path will be prefixed by $DESTDIR/$version
+
+DESTDIR='' # optional, defaults to $PWD
+
+# Files containing distgen directives
+DISTGEN_RULES="
+    src=src/Dockerfile
+    dest=Dockerfile;
+
+    src=src/Dockerfile
+    dest=Dockerfile.rhel7;
+
+    src=src/cccp.yml
+    dest=cccp.yml;
+
+    src=src/root/usr/share/container-scripts/postgresql/README.md
+    dest=root/usr/share/container-scripts/postgresql/README.md;
+
+    src=src/root/usr/share/container-scripts/postgresql/common.sh
+    dest=root/usr/share/container-scripts/postgresql/common.sh
+"
+
+# Symbolic links
+SYMLINK_RULES="
+    link_target=root/usr/share/container-scripts/postgresql/README.md
+    link_name=README.md;
+
+    link_target=../test
+    link_name=test;
+
+    link_target=/usr/bin/run-postgresql
+    link_name=s2i/bin/run
+"
+
+# Files to copy
+COPY_RULES="
+    src=src/root/usr/libexec/fix-permissions
+    dest=root/usr/libexec/fix-permissions
+    mode=0755;
+
+    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template;
+
+    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template;
+
+    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+    dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
+
+    src=src/root/usr/bin/cgroup-limits
+    dest=root/usr/bin/cgroup-limits
+    mode=0755;
+
+    src=src/root/usr/share/container-scripts/postgresql/scl_enable
+    dest=root/usr/share/container-scripts/postgresql/scl_enable;
+
+    src=src/root/usr/bin/run-postgresql
+    dest=root/usr/bin/run-postgresql
+    mode=0755;
+
+    src=src/root/usr/bin/run-postgresql-master
+    dest=root/usr/bin/run-postgresql-master
+    mode=0755;
+
+    src=src/root/usr/bin/run-postgresql-slave
+    dest=root/usr/bin/run-postgresql-slave
+    mode=0755;
+
+    src=src/root/usr/bin/container-entrypoint
+    dest=root/usr/bin/container-entrypoint
+    mode=0755;
+
+    src=src/root/usr/bin/usage
+    dest=root/usr/bin/usage
+    mode=0755;
+
+    src=src/root/usr/libexec/check-container
+    dest=root/usr/libexec/check-container
+    mode=0755;
+
+    src=src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+    dest=root/usr/share/container-scripts/postgresql/start/set_passwords.sh;
+
+    src=src/s2i/bin/assemble
+    dest=s2i/bin/assemble
+    mode=0755;
+
+    src=src/s2i/bin/usage
+    dest=s2i/bin/usage
+    mode=0755;
+"
diff --git a/specs/multispec.yml b/specs/multispec.yml
index a9851f0c..15d28042 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -38,6 +38,9 @@ specs:
       enabled_collection: "rh-postgresql94"
       openshift_tags: "database,postgresql,postgresql94,rh-postgresql94"
       redhat_component: "rh-postgresql94-docker"
+      common_image_name: "{{ spec.org }}/postgresql-94-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-94-rhel7"
+      centos_image_name: "centos/postgresql-94-centos7"
       stable: True
 
     "9.5":
@@ -48,6 +51,9 @@ specs:
       enabled_collection: "rh-postgresql95"
       openshift_tags: "database,postgresql,postgresql95,rh-postgresql95"
       redhat_component: "rh-postgresql95-docker"
+      common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-95-rhel7"
+      centos_image_name: "centos/postgresql-95-centos7"
       stable: True
 
     "9.6":
@@ -58,4 +64,7 @@ specs:
       enabled_collection: "rh-postgresql96"
       openshift_tags: "database,postgresql,postgresql96,rh-postgresql96"
       redhat_component: "rh-postgresql96-docker"
+      common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-96-rhel7"
+      centos_image_name: "centos/postgresql-96-centos7"
       stable: True
diff --git a/src/Dockerfile.rhel7 b/src/Dockerfile
similarity index 75%
rename from src/Dockerfile.rhel7
rename to src/Dockerfile
index 0934b6d3..d85a08ed 100644
--- a/src/Dockerfile.rhel7
+++ b/src/Dockerfile
@@ -1,4 +1,4 @@
-FROM rhscl/s2i-core-rhel7
+FROM {{ spec.s2i_base }}
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -10,8 +10,8 @@ FROM rhscl/s2i-core-rhel7
 #  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
 #                           PostgreSQL administrative account
 
-ENV POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
+ENV POSTGRESQL_VERSION={{ spec.version }} \
+    POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
@@ -24,13 +24,17 @@ create, run, maintain and access a PostgreSQL DBMS server."
 LABEL summary=$SUMMARY \
       description="$DESCRIPTION" \
       io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
+      io.k8s.display-name="PostgreSQL {{ spec.version }}" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
-      name="rhscl/postgresql-96-rhel7" \
-      com.redhat.component="rh-postgresql96-docker" \
+      io.openshift.tags="{{ spec.openshift_tags }}" \
+      name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
+      com.redhat.component="{{ spec.redhat_component }}" \
+{%- if spec.version in spec.rhscl3_introduced %}
       version="1" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7" \
+{%- else %}
+      version="{{ spec.version }}" \
+{%- endif %}
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
@@ -40,11 +44,14 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
+{%- if spec.repo_enable_reason %}
+{{ spec.repo_enable_reason }}
+{%- endif %}
+RUN {{ spec.environment_setup }}
+{%- if not spec.stable and spec.staging_repo_setup %}
+{{ spec.staging_repo_setup }}
+{%- endif %}
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     yum clean all && \
@@ -56,7 +63,7 @@ RUN yum install -y yum-utils gettext && \
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql96
+    ENABLED_COLLECTIONS={{ spec.enabled_collection }}
 
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
diff --git a/src/cccp.yml b/src/cccp.yml
index fb90f577..6c36ace9 100644
--- a/src/cccp.yml
+++ b/src/cccp.yml
@@ -1 +1 @@
-job-id: postgresql-96-centos7
+job-id: postgresql-{{ spec.short }}-{{ spec.prod }}
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 623dc1e9..a24a1cbf 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -1,12 +1,12 @@
-PostgreSQL 9.6 SQL Database Server container image
+PostgreSQL {{ spec.version }} SQL Database Server container image
 ===============================================
 
-This container image includes PostgreSQL 9.6 SQL database server for OpenShift and general usage.
+This container image includes PostgreSQL {{ spec.version }} SQL database server for OpenShift and general usage.
 Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7)
-as registry.access.redhat.com/rhscl/postgresql-96-rhel7.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-96-centos7/)
-as centos/postgresql-96-centos7.
+The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/{{ spec.rhel_image_name }})
+as registry.access.redhat.com/{{ spec.rhel_image_name }}.
+The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/{{ spec.centos_image_name }}/)
+as {{ spec.centos_image_name }}.
 
 
 Description
@@ -22,12 +22,12 @@ You can find more information on the PostgreSQL project from the project Web sit
 Usage
 -----
 
-For this, we will assume that you are using the `rhscl/postgresql-96-rhel7` image.
+For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image.
 If you want to set only the mandatory environment variables and not store the database
 in a host directory, execute the following command:
 
 ```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7
+$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.rhel_image_name }}
 ```
 
 This will create a container named `postgresql_database` running PostgreSQL with
@@ -37,9 +37,9 @@ executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
 below). This will be the PostgreSQL database cluster directory.
 
 If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.6/static/app-initdb.html)
+first run [`initdb`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-initdb.html)
 and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.6/static/app-postgres.html)
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-postgres.html)
 is executed and will run as PID 1. You can stop the detached container by running
 `docker stop postgresql_database`.
 
@@ -205,7 +205,7 @@ ensure that you've carefully backed up all your data and that you are OK with
 potential manual rollback! **
 
 This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 9.5 (and _only_ this version) - provided by sclorg
+the PostgreSQL server version {{ spec.prev_version }} (and _only_ this version) - provided by sclorg
 image.  The upgrade process is designed so that you should be able to just
 switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
 appropriately to explicitly request the database data transformation.
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 757b3a1e..bf433987 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -70,8 +70,10 @@ function check_env_vars() {
     [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
     [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
     [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
+{%- raw %}
     [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
     [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+{%- endraw %}
     postinitdb_actions+=",simple_db"
   fi
 
@@ -155,7 +157,7 @@ initdb_wrapper ()
 {
   # Initialize the database cluster with utf8 support enabled by default.
   # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.6/static/locale.html
+  # http://www.postgresql.org/docs/{{ spec.version }}/static/locale.html
   LANG=${LANG:-en_US.utf8} "$@"
 }
 

From 886ba8165d559bb7b77f63987897f96c531c48d4 Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:24:57 +0100
Subject: [PATCH 080/509] Drop version 9.2

---
 9.2/Dockerfile                                |  60 -----
 9.2/Dockerfile.rhel7                          |  66 ------
 9.2/README.md                                 |   1 -
 9.2/cccp.yml                                  |   1 -
 9.2/root/help.1                               |  12 -
 9.2/root/usr/bin/cgroup-limits                |  92 --------
 9.2/root/usr/bin/container-entrypoint         |   3 -
 9.2/root/usr/bin/run-postgresql               |  29 ---
 9.2/root/usr/bin/run-postgresql-master        |   5 -
 9.2/root/usr/bin/run-postgresql-slave         |  37 ---
 9.2/root/usr/libexec/fix-permissions          |   7 -
 .../container-scripts/postgresql/README.md    |   4 -
 .../container-scripts/postgresql/common.sh    | 218 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 --
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 9.2/test                                      |   1 -
 18 files changed, 576 deletions(-)
 delete mode 100644 9.2/Dockerfile
 delete mode 100644 9.2/Dockerfile.rhel7
 delete mode 120000 9.2/README.md
 delete mode 100644 9.2/cccp.yml
 delete mode 100644 9.2/root/help.1
 delete mode 100755 9.2/root/usr/bin/cgroup-limits
 delete mode 100755 9.2/root/usr/bin/container-entrypoint
 delete mode 100755 9.2/root/usr/bin/run-postgresql
 delete mode 100755 9.2/root/usr/bin/run-postgresql-master
 delete mode 100755 9.2/root/usr/bin/run-postgresql-slave
 delete mode 100755 9.2/root/usr/libexec/fix-permissions
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 9.2/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 120000 9.2/test

diff --git a/9.2/Dockerfile b/9.2/Dockerfile
deleted file mode 100644
index 9aa7020e..00000000
--- a/9.2/Dockerfile
+++ /dev/null
@@ -1,60 +0,0 @@
-FROM centos:centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-MAINTAINER SoftwareCollections.org <sclorg@redhat.com>
-
-ENV POSTGRESQL_VERSION=9.2 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres
-
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
-      io.k8s.display-name="PostgreSQL 9.2" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql92"
-
-EXPOSE 5432
-
-ADD README.md /help.md
-ADD root /
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl && \
-    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=postgresql92
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-
-VOLUME ["/var/lib/pgsql/data"]
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.2/Dockerfile.rhel7 b/9.2/Dockerfile.rhel7
deleted file mode 100644
index f274a90e..00000000
--- a/9.2/Dockerfile.rhel7
+++ /dev/null
@@ -1,66 +0,0 @@
-FROM rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.2 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres
-
-LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
-      io.k8s.display-name="PostgreSQL 9.2" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql92"
-
-# Labels consumed by Red Hat build service
-LABEL name="openshift3/postgresql-92-rhel7" \
-      com.redhat.component="openshift-postgresql-docker" \
-      version="9.2" \
-      release="1" \
-      architecture="x86_64"
-
-EXPOSE 5432
-
-ADD README.md /help.md
-ADD root /
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y yum-utils && \
-    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
-    yum-config-manager --enable rhel-7-server-optional-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils postgresql92 postgresql92-postgresql-contrib nss_wrapper" && \
-    yum install -y --disablerepo="epel" --setopt=tsflags=nodocs $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=postgresql92
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.2/README.md b/9.2/README.md
deleted file mode 120000
index d359f030..00000000
--- a/9.2/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.2/cccp.yml b/9.2/cccp.yml
deleted file mode 100644
index 96f9f25c..00000000
--- a/9.2/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-92-centos7
diff --git a/9.2/root/help.1 b/9.2/root/help.1
deleted file mode 100644
index 3c74aa50..00000000
--- a/9.2/root/help.1
+++ /dev/null
@@ -1,12 +0,0 @@
-.\"t
-.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
-.\"
-.\" Automatically generated by Pandoc 1.16.0.2
-.\"
-.TH "POSTGRESQL\-92\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
-.hy
-.SH PostgreSQL Docker image
-.PP
-\f[B]The PostgreSQL 9.2 image is deprecated.\f[]
-.SH AUTHORS
-Red Hat.
diff --git a/9.2/root/usr/bin/cgroup-limits b/9.2/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/9.2/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))
diff --git a/9.2/root/usr/bin/container-entrypoint b/9.2/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/9.2/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/9.2/root/usr/bin/run-postgresql b/9.2/root/usr/bin/run-postgresql
deleted file mode 100755
index d14d72ef..00000000
--- a/9.2/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  NEED_TO_CREATE_USERS=yes
-fi
-
-pg_ctl -w start -o "-h ''"
-if [ "${NEED_TO_CREATE_USERS:-}" == "yes" ]; then
-  create_users
-fi
-set_passwords
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.2/root/usr/bin/run-postgresql-master b/9.2/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/9.2/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/9.2/root/usr/bin/run-postgresql-slave b/9.2/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index be327a93..00000000
--- a/9.2/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.2/root/usr/libexec/fix-permissions b/9.2/root/usr/libexec/fix-permissions
deleted file mode 100755
index ebcdd3d4..00000000
--- a/9.2/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
diff --git a/9.2/root/usr/share/container-scripts/postgresql/README.md b/9.2/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 45af59a9..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-PostgreSQL container image
-=======================
-
-**The PostgreSQL 9.2 image is deprecated.**
\ No newline at end of file
diff --git a/9.2/root/usr/share/container-scripts/postgresql/common.sh b/9.2/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 367ec664..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,218 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-You must either specify the following environment variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
-Or both.
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/openshift/postgresql.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  case ",$postinitdb_actions," in
-    *,admin_pass,*|*,simple_db,*) ;;
-    *) usage ;;
-  esac
-
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-function initialize_database() {
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.2/static/locale.html
-  LANG=${LANG:-en_US.utf8} initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-function set_passwords() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-    psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-  fi
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.2/root/usr/share/container-scripts/postgresql/scl_enable b/9.2/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/9.2/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.2/test b/9.2/test
deleted file mode 120000
index 419df4f9..00000000
--- a/9.2/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file

From fb13d4fa213475c2859df15da784f38c2003093b Mon Sep 17 00:00:00 2001
From: Dominika Hodovska <dhodovsk@redhat.com>
Date: Mon, 12 Mar 2018 13:26:32 +0100
Subject: [PATCH 081/509] Drop files that can be generated

---
 9.4/Dockerfile                                |  78 ----
 9.4/Dockerfile.rhel7                          |  81 ----
 9.4/README.md                                 |   1 -
 9.4/cccp.yml                                  |   1 -
 9.4/root/usr/bin/cgroup-limits                |  92 ----
 9.4/root/usr/bin/container-entrypoint         |   3 -
 9.4/root/usr/bin/run-postgresql               |  38 --
 9.4/root/usr/bin/run-postgresql-master        |   5 -
 9.4/root/usr/bin/run-postgresql-slave         |  37 --
 9.4/root/usr/bin/usage                        |   4 -
 9.4/root/usr/libexec/check-container          |  39 --
 9.4/root/usr/libexec/fix-permissions          |   7 -
 .../container-scripts/postgresql/README.md    | 299 ------------
 .../container-scripts/postgresql/common.sh    | 436 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  14 -
 9.4/s2i/bin/assemble                          |  14 -
 9.4/s2i/bin/run                               |   1 -
 9.4/s2i/bin/usage                             |   1 -
 9.4/test                                      |   1 -
 9.5/Dockerfile                                |  78 ----
 9.5/Dockerfile.rhel7                          |  81 ----
 9.5/README.md                                 |   1 -
 9.5/cccp.yml                                  |   1 -
 9.5/root/usr/bin/cgroup-limits                |  92 ----
 9.5/root/usr/bin/container-entrypoint         |   3 -
 9.5/root/usr/bin/run-postgresql               |  38 --
 9.5/root/usr/bin/run-postgresql-master        |   5 -
 9.5/root/usr/bin/run-postgresql-slave         |  37 --
 9.5/root/usr/bin/usage                        |   4 -
 9.5/root/usr/libexec/check-container          |  39 --
 9.5/root/usr/libexec/fix-permissions          |   7 -
 .../container-scripts/postgresql/README.md    | 299 ------------
 .../container-scripts/postgresql/common.sh    | 436 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  14 -
 9.5/s2i/bin/assemble                          |  14 -
 9.5/s2i/bin/run                               |   1 -
 9.5/s2i/bin/usage                             |   1 -
 9.5/test                                      |   1 -
 9.6                                           |   1 -
 latest/Dockerfile                             |  78 ----
 latest/Dockerfile.fedora                      |  68 ---
 latest/Dockerfile.rhel7                       |  81 ----
 latest/README.md                              |   1 -
 latest/cccp.yml                               |   1 -
 latest/root/usr/bin/cgroup-limits             |  92 ----
 latest/root/usr/bin/container-entrypoint      |   3 -
 latest/root/usr/bin/run-postgresql            |  38 --
 latest/root/usr/bin/run-postgresql-master     |   5 -
 latest/root/usr/bin/run-postgresql-slave      |  37 --
 latest/root/usr/bin/usage                     |   4 -
 latest/root/usr/libexec/check-container       |  39 --
 latest/root/usr/libexec/fix-permissions       |   7 -
 .../container-scripts/postgresql/README.md    | 299 ------------
 .../container-scripts/postgresql/common.sh    | 436 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  14 -
 latest/s2i/bin/assemble                       |  14 -
 latest/s2i/bin/run                            |   1 -
 latest/s2i/bin/usage                          |   1 -
 latest/test                                   |   1 -
 71 files changed, 3645 deletions(-)
 delete mode 100644 9.4/Dockerfile
 delete mode 100644 9.4/Dockerfile.rhel7
 delete mode 120000 9.4/README.md
 delete mode 100644 9.4/cccp.yml
 delete mode 100755 9.4/root/usr/bin/cgroup-limits
 delete mode 100755 9.4/root/usr/bin/container-entrypoint
 delete mode 100755 9.4/root/usr/bin/run-postgresql
 delete mode 100755 9.4/root/usr/bin/run-postgresql-master
 delete mode 100755 9.4/root/usr/bin/run-postgresql-slave
 delete mode 100755 9.4/root/usr/bin/usage
 delete mode 100755 9.4/root/usr/libexec/check-container
 delete mode 100755 9.4/root/usr/libexec/fix-permissions
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 9.4/s2i/bin/assemble
 delete mode 120000 9.4/s2i/bin/run
 delete mode 100755 9.4/s2i/bin/usage
 delete mode 120000 9.4/test
 delete mode 100644 9.5/Dockerfile
 delete mode 100644 9.5/Dockerfile.rhel7
 delete mode 120000 9.5/README.md
 delete mode 100644 9.5/cccp.yml
 delete mode 100755 9.5/root/usr/bin/cgroup-limits
 delete mode 100755 9.5/root/usr/bin/container-entrypoint
 delete mode 100755 9.5/root/usr/bin/run-postgresql
 delete mode 100755 9.5/root/usr/bin/run-postgresql-master
 delete mode 100755 9.5/root/usr/bin/run-postgresql-slave
 delete mode 100755 9.5/root/usr/bin/usage
 delete mode 100755 9.5/root/usr/libexec/check-container
 delete mode 100755 9.5/root/usr/libexec/fix-permissions
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 9.5/s2i/bin/assemble
 delete mode 120000 9.5/s2i/bin/run
 delete mode 100755 9.5/s2i/bin/usage
 delete mode 120000 9.5/test
 delete mode 120000 9.6
 delete mode 100644 latest/Dockerfile
 delete mode 100644 latest/Dockerfile.fedora
 delete mode 100644 latest/Dockerfile.rhel7
 delete mode 120000 latest/README.md
 delete mode 100644 latest/cccp.yml
 delete mode 100755 latest/root/usr/bin/cgroup-limits
 delete mode 100755 latest/root/usr/bin/container-entrypoint
 delete mode 100755 latest/root/usr/bin/run-postgresql
 delete mode 100755 latest/root/usr/bin/run-postgresql-master
 delete mode 100755 latest/root/usr/bin/run-postgresql-slave
 delete mode 100755 latest/root/usr/bin/usage
 delete mode 100755 latest/root/usr/libexec/check-container
 delete mode 100755 latest/root/usr/libexec/fix-permissions
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 latest/s2i/bin/assemble
 delete mode 120000 latest/s2i/bin/run
 delete mode 100755 latest/s2i/bin/usage
 delete mode 120000 latest/test

diff --git a/9.4/Dockerfile b/9.4/Dockerfile
deleted file mode 100644
index 3bab542e..00000000
--- a/9.4/Dockerfile
+++ /dev/null
@@ -1,78 +0,0 @@
-FROM centos/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.4 \
-    POSTGRESQL_PREV_VERSION=9.2 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.4" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
-      name="centos/postgresql-94-centos7" \
-      com.redhat.component="rh-postgresql94-docker" \
-      version="9.4" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-94-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql94
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.4/Dockerfile.rhel7 b/9.4/Dockerfile.rhel7
deleted file mode 100644
index dd28dc84..00000000
--- a/9.4/Dockerfile.rhel7
+++ /dev/null
@@ -1,81 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.4 \
-    POSTGRESQL_PREV_VERSION=9.2 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.4" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94" \
-      name="rhscl/postgresql-94-rhel7" \
-      com.redhat.component="rh-postgresql94-docker" \
-      version="9.4" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-94-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql94
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.4/README.md b/9.4/README.md
deleted file mode 120000
index d359f030..00000000
--- a/9.4/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.4/cccp.yml b/9.4/cccp.yml
deleted file mode 100644
index d9989f10..00000000
--- a/9.4/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-94-centos7
diff --git a/9.4/root/usr/bin/cgroup-limits b/9.4/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/9.4/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))
diff --git a/9.4/root/usr/bin/container-entrypoint b/9.4/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/9.4/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/9.4/root/usr/bin/run-postgresql b/9.4/root/usr/bin/run-postgresql
deleted file mode 100755
index 48ff4258..00000000
--- a/9.4/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-pg_ctl -w start -o "-h ''"
-if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
-    migrate_db
-    create_users
-fi
-
-process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.4/root/usr/bin/run-postgresql-master b/9.4/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/9.4/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/9.4/root/usr/bin/run-postgresql-slave b/9.4/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index be327a93..00000000
--- a/9.4/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.4/root/usr/bin/usage b/9.4/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/9.4/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/9.4/root/usr/libexec/check-container b/9.4/root/usr/libexec/check-container
deleted file mode 100755
index bee6acc8..00000000
--- a/9.4/root/usr/libexec/check-container
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-check=ready
-case $1 in
-    --live) check=live ;;
-esac
-
-while true; do
-    # Wait until the /bin/postgres is executed.
-    case $(readlink -f /proc/1/exe) in
-        *bash) sleep 0.2; continue ;;
-        *) break ;;
-    esac
-done
-
-# Timeout is infinite (openshift template has the timeout pre-set)
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
-rc=$?
-
-# we are ready only if the db accepts connections
-test $rc -eq 0 && exit 0
-
-# container is live also during pg cluster start-up
-test $rc -eq 1 && test $check = live && exit 0
-
-exit 1
diff --git a/9.4/root/usr/libexec/fix-permissions b/9.4/root/usr/libexec/fix-permissions
deleted file mode 100755
index ebcdd3d4..00000000
--- a/9.4/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
diff --git a/9.4/root/usr/share/container-scripts/postgresql/README.md b/9.4/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 38665d65..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,299 +0,0 @@
-PostgreSQL 9.4 SQL Database Server container image
-===============================================
-
-This container image includes PostgreSQL 9.4 SQL database server for OpenShift and general usage.
-Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-94-rhel7)
-as registry.access.redhat.com/rhscl/postgresql-94-rhel7.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-94-centos7/)
-as centos/postgresql-94-centos7.
-
-
-Description
------------
-
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
-
-
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-94-rhel7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-94-rhel7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.4/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.4/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
-
-
-
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
-       Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
-       Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `docker run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```
-$ setfacl -m u:26:-wx /your/data/dir
-$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-
-Data migration
-----------------------
-
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
-$ docker run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
-```
-
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
-Migration from a different kind of PostgreSQL container can likely fail.
-
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
-
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
-
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
-
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
-
-PostgreSQL auto-tuning
---------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
-
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 9.2 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
-
-
-Extending image
-----------------
-
-This image can be extended using
-[source-to-image](https://github.com/openshift/source-to-image).
-
-For example to build customized image `new-postgresql`
-with configuration in `~/image-configuration/` run:
-
-
-```
-$ s2i build ~/image-configuration/ postgresql new-postgresql
-```
-
-The directory passed to `s2i build` should contain one or more of the
-following directories:
-
-##### `postgresql-cfg/`
-
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
-
-##### `postgresql-init/`
-
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
-
-##### `postgresql-start/`
-
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
-
-
-----------------------------------------------
-
-During `s2i build` all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
-
-
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    docker logs <container>
-
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
-
-
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
-for RHEL is called Dockerfile.rhel7.
diff --git a/9.4/root/usr/share/container-scripts/postgresql/common.sh b/9.4/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 2bc6784b..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,436 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.4/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files finds file for image extending
-function get_matched_files() {
-  local custom_dir default_dir
-  custom_dir="$1"
-  default_dir="$2"
-  files_matched="$3"
-  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-}
-
-# process_extending_files process extending files in $1 and $2 directories
-# - source all *.sh files
-#   (if there are files with same name source only file from $1)
-function process_extending_files() {
-  local custom_dir default_dir
-  custom_dir=$1
-  default_dir=$2
-
-  while read filename ; do
-    echo "=> sourcing $filename ..."
-    # Custom file is prefered
-    if [ -f $custom_dir/$filename ]; then
-      source $custom_dir/$filename
-    elif [ -f $default_dir/$filename ]; then
-      source $default_dir/$filename
-    fi
-  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
-}
diff --git a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.4/root/usr/share/container-scripts/postgresql/scl_enable b/9.4/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index f14ff46a..00000000
--- a/9.4/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-fi
diff --git a/9.4/s2i/bin/assemble b/9.4/s2i/bin/assemble
deleted file mode 100755
index c1472bdc..00000000
--- a/9.4/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions ./
diff --git a/9.4/s2i/bin/run b/9.4/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/9.4/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/9.4/s2i/bin/usage b/9.4/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/9.4/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/9.4/test b/9.4/test
deleted file mode 120000
index 419df4f9..00000000
--- a/9.4/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file
diff --git a/9.5/Dockerfile b/9.5/Dockerfile
deleted file mode 100644
index e6bff730..00000000
--- a/9.5/Dockerfile
+++ /dev/null
@@ -1,78 +0,0 @@
-FROM centos/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.5 \
-    POSTGRESQL_PREV_VERSION=9.4 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="centos/postgresql-95-centos7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-95-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.5/Dockerfile.rhel7 b/9.5/Dockerfile.rhel7
deleted file mode 100644
index d3119c3f..00000000
--- a/9.5/Dockerfile.rhel7
+++ /dev/null
@@ -1,81 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.5 \
-    POSTGRESQL_PREV_VERSION=9.4 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.5" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql95,rh-postgresql95" \
-      name="rhscl/postgresql-95-rhel7" \
-      com.redhat.component="rh-postgresql95-docker" \
-      version="9.5" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql95
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/9.5/README.md b/9.5/README.md
deleted file mode 120000
index d359f030..00000000
--- a/9.5/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/9.5/cccp.yml b/9.5/cccp.yml
deleted file mode 100644
index 03d18e29..00000000
--- a/9.5/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-95-centos7
diff --git a/9.5/root/usr/bin/cgroup-limits b/9.5/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/9.5/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))
diff --git a/9.5/root/usr/bin/container-entrypoint b/9.5/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/9.5/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/9.5/root/usr/bin/run-postgresql b/9.5/root/usr/bin/run-postgresql
deleted file mode 100755
index 48ff4258..00000000
--- a/9.5/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-pg_ctl -w start -o "-h ''"
-if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
-    migrate_db
-    create_users
-fi
-
-process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-master b/9.5/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/9.5/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/9.5/root/usr/bin/run-postgresql-slave b/9.5/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index be327a93..00000000
--- a/9.5/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/9.5/root/usr/bin/usage b/9.5/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/9.5/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/9.5/root/usr/libexec/check-container b/9.5/root/usr/libexec/check-container
deleted file mode 100755
index bee6acc8..00000000
--- a/9.5/root/usr/libexec/check-container
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-check=ready
-case $1 in
-    --live) check=live ;;
-esac
-
-while true; do
-    # Wait until the /bin/postgres is executed.
-    case $(readlink -f /proc/1/exe) in
-        *bash) sleep 0.2; continue ;;
-        *) break ;;
-    esac
-done
-
-# Timeout is infinite (openshift template has the timeout pre-set)
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
-rc=$?
-
-# we are ready only if the db accepts connections
-test $rc -eq 0 && exit 0
-
-# container is live also during pg cluster start-up
-test $rc -eq 1 && test $check = live && exit 0
-
-exit 1
diff --git a/9.5/root/usr/libexec/fix-permissions b/9.5/root/usr/libexec/fix-permissions
deleted file mode 100755
index ebcdd3d4..00000000
--- a/9.5/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
diff --git a/9.5/root/usr/share/container-scripts/postgresql/README.md b/9.5/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 5fc5b00f..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,299 +0,0 @@
-PostgreSQL 9.5 SQL Database Server container image
-===============================================
-
-This container image includes PostgreSQL 9.5 SQL database server for OpenShift and general usage.
-Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-95-rhel7)
-as registry.access.redhat.com/rhscl/postgresql-95-rhel7.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-95-centos7/)
-as centos/postgresql-95-centos7.
-
-
-Description
------------
-
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
-
-
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-95-rhel7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-95-rhel7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.5/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.5/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
-
-
-
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
-       Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
-       Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `docker run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```
-$ setfacl -m u:26:-wx /your/data/dir
-$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-
-Data migration
-----------------------
-
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
-$ docker run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
-```
-
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
-Migration from a different kind of PostgreSQL container can likely fail.
-
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
-
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
-
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
-
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
-
-PostgreSQL auto-tuning
---------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
-
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 9.4 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
-
-
-Extending image
-----------------
-
-This image can be extended using
-[source-to-image](https://github.com/openshift/source-to-image).
-
-For example to build customized image `new-postgresql`
-with configuration in `~/image-configuration/` run:
-
-
-```
-$ s2i build ~/image-configuration/ postgresql new-postgresql
-```
-
-The directory passed to `s2i build` should contain one or more of the
-following directories:
-
-##### `postgresql-cfg/`
-
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
-
-##### `postgresql-init/`
-
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
-
-##### `postgresql-start/`
-
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
-
-
-----------------------------------------------
-
-During `s2i build` all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
-
-
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    docker logs <container>
-
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
-
-
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
-for RHEL is called Dockerfile.rhel7.
diff --git a/9.5/root/usr/share/container-scripts/postgresql/common.sh b/9.5/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index bbbb76e4..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,436 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.5/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files finds file for image extending
-function get_matched_files() {
-  local custom_dir default_dir
-  custom_dir="$1"
-  default_dir="$2"
-  files_matched="$3"
-  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-}
-
-# process_extending_files process extending files in $1 and $2 directories
-# - source all *.sh files
-#   (if there are files with same name source only file from $1)
-function process_extending_files() {
-  local custom_dir default_dir
-  custom_dir=$1
-  default_dir=$2
-
-  while read filename ; do
-    echo "=> sourcing $filename ..."
-    # Custom file is prefered
-    if [ -f $custom_dir/$filename ]; then
-      source $custom_dir/$filename
-    elif [ -f $default_dir/$filename ]; then
-      source $default_dir/$filename
-    fi
-  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
-}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/9.5/root/usr/share/container-scripts/postgresql/scl_enable b/9.5/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index f14ff46a..00000000
--- a/9.5/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-fi
diff --git a/9.5/s2i/bin/assemble b/9.5/s2i/bin/assemble
deleted file mode 100755
index c1472bdc..00000000
--- a/9.5/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions ./
diff --git a/9.5/s2i/bin/run b/9.5/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/9.5/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/9.5/s2i/bin/usage b/9.5/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/9.5/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/9.5/test b/9.5/test
deleted file mode 120000
index 419df4f9..00000000
--- a/9.5/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file
diff --git a/9.6 b/9.6
deleted file mode 120000
index b9bc2fdc..00000000
--- a/9.6
+++ /dev/null
@@ -1 +0,0 @@
-latest
\ No newline at end of file
diff --git a/latest/Dockerfile b/latest/Dockerfile
deleted file mode 100644
index dd242c1e..00000000
--- a/latest/Dockerfile
+++ /dev/null
@@ -1,78 +0,0 @@
-FROM centos/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
-      name="centos/postgresql-96-centos7" \
-      com.redhat.component="rh-postgresql96-docker" \
-      version="9.6" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos/postgresql-96-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql96
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/latest/Dockerfile.fedora b/latest/Dockerfile.fedora
deleted file mode 100644
index 71f78a10..00000000
--- a/latest/Dockerfile.fedora
+++ /dev/null
@@ -1,68 +0,0 @@
-FROM registry.fedoraproject.org/fedora:26
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV NAME=postgresql \
-    VERSION=0 \
-    RELEASE=1 \
-    ARCH=x86_64 \
-    \
-    POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96" \
-      com.redhat.component="$NAME" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="$FGC/$NAME" \
-      version="0" \
-      release="$RELEASE.$DISTTAG" \
-      architecture="$ARCH" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME" \
-      help="/help.1"
-
-EXPOSE 5432
-
-ADD root /
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils python2 " && \
-    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    dnf clean all && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
-
-VOLUME ["/var/lib/pgsql/data"]
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/latest/Dockerfile.rhel7 b/latest/Dockerfile.rhel7
deleted file mode 100644
index 0934b6d3..00000000
--- a/latest/Dockerfile.rhel7
+++ /dev/null
@@ -1,81 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary=$SUMMARY \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96,rh-postgresql96" \
-      name="rhscl/postgresql-96-rhel7" \
-      com.redhat.component="rh-postgresql96-docker" \
-      version="1" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    yum clean all && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql96
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/latest/README.md b/latest/README.md
deleted file mode 120000
index d359f030..00000000
--- a/latest/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/latest/cccp.yml b/latest/cccp.yml
deleted file mode 100644
index fb90f577..00000000
--- a/latest/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-96-centos7
diff --git a/latest/root/usr/bin/cgroup-limits b/latest/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/latest/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))
diff --git a/latest/root/usr/bin/container-entrypoint b/latest/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/latest/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/latest/root/usr/bin/run-postgresql b/latest/root/usr/bin/run-postgresql
deleted file mode 100755
index 48ff4258..00000000
--- a/latest/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-pg_ctl -w start -o "-h ''"
-if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
-    migrate_db
-    create_users
-fi
-
-process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/latest/root/usr/bin/run-postgresql-master b/latest/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/latest/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/latest/root/usr/bin/run-postgresql-slave b/latest/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index be327a93..00000000
--- a/latest/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/latest/root/usr/bin/usage b/latest/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/latest/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/latest/root/usr/libexec/check-container b/latest/root/usr/libexec/check-container
deleted file mode 100755
index bee6acc8..00000000
--- a/latest/root/usr/libexec/check-container
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-check=ready
-case $1 in
-    --live) check=live ;;
-esac
-
-while true; do
-    # Wait until the /bin/postgres is executed.
-    case $(readlink -f /proc/1/exe) in
-        *bash) sleep 0.2; continue ;;
-        *) break ;;
-    esac
-done
-
-# Timeout is infinite (openshift template has the timeout pre-set)
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
-rc=$?
-
-# we are ready only if the db accepts connections
-test $rc -eq 0 && exit 0
-
-# container is live also during pg cluster start-up
-test $rc -eq 1 && test $check = live && exit 0
-
-exit 1
diff --git a/latest/root/usr/libexec/fix-permissions b/latest/root/usr/libexec/fix-permissions
deleted file mode 100755
index ebcdd3d4..00000000
--- a/latest/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
diff --git a/latest/root/usr/share/container-scripts/postgresql/README.md b/latest/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 623dc1e9..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,299 +0,0 @@
-PostgreSQL 9.6 SQL Database Server container image
-===============================================
-
-This container image includes PostgreSQL 9.6 SQL database server for OpenShift and general usage.
-Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7)
-as registry.access.redhat.com/rhscl/postgresql-96-rhel7.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/postgresql-96-centos7/)
-as centos/postgresql-96-centos7.
-
-
-Description
------------
-
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
-
-
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-96-rhel7` image.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-96-rhel7
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/9.6/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/9.6/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
-
-
-
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
-       Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
-       Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `docker run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```
-$ setfacl -m u:26:-wx /your/data/dir
-$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-
-Data migration
-----------------------
-
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
-$ docker run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
-```
-
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
-Migration from a different kind of PostgreSQL container can likely fail.
-
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
-
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
-
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
-
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
-
-PostgreSQL auto-tuning
---------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
-
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 9.5 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
-
-
-Extending image
-----------------
-
-This image can be extended using
-[source-to-image](https://github.com/openshift/source-to-image).
-
-For example to build customized image `new-postgresql`
-with configuration in `~/image-configuration/` run:
-
-
-```
-$ s2i build ~/image-configuration/ postgresql new-postgresql
-```
-
-The directory passed to `s2i build` should contain one or more of the
-following directories:
-
-##### `postgresql-cfg/`
-
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
-
-##### `postgresql-init/`
-
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
-
-##### `postgresql-start/`
-
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
-
-
-----------------------------------------------
-
-During `s2i build` all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
-
-
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    docker logs <container>
-
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
-
-
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
-for RHEL is called Dockerfile.rhel7.
diff --git a/latest/root/usr/share/container-scripts/postgresql/common.sh b/latest/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 757b3a1e..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,436 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/9.6/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files finds file for image extending
-function get_matched_files() {
-  local custom_dir default_dir
-  custom_dir="$1"
-  default_dir="$2"
-  files_matched="$3"
-  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-}
-
-# process_extending_files process extending files in $1 and $2 directories
-# - source all *.sh files
-#   (if there are files with same name source only file from $1)
-function process_extending_files() {
-  local custom_dir default_dir
-  custom_dir=$1
-  default_dir=$2
-
-  while read filename ; do
-    echo "=> sourcing $filename ..."
-    # Custom file is prefered
-    if [ -f $custom_dir/$filename ]; then
-      source $custom_dir/$filename
-    elif [ -f $default_dir/$filename ]; then
-      source $default_dir/$filename
-    fi
-  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
-}
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/latest/root/usr/share/container-scripts/postgresql/scl_enable b/latest/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index f14ff46a..00000000
--- a/latest/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
-fi
diff --git a/latest/s2i/bin/assemble b/latest/s2i/bin/assemble
deleted file mode 100755
index c1472bdc..00000000
--- a/latest/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions ./
diff --git a/latest/s2i/bin/run b/latest/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/latest/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/latest/s2i/bin/usage b/latest/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/latest/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/latest/test b/latest/test
deleted file mode 120000
index 419df4f9..00000000
--- a/latest/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file

From 7032ddb3439e53cbb38943e666e9ee08c099fd91 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 13 Mar 2018 09:57:56 +0100
Subject: [PATCH 082/509] add distgen prebuild hook

---
 hooks/pre_build_distgen | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 hooks/pre_build_distgen

diff --git a/hooks/pre_build_distgen b/hooks/pre_build_distgen
new file mode 100644
index 00000000..378ba917
--- /dev/null
+++ b/hooks/pre_build_distgen
@@ -0,0 +1,6 @@
+#!/bin/bash -ex
+yum install epel-release -y
+# our deps
+yum install distgen make -y
+
+make TARGET=centos7 generate

From 5ee84039936a1172eda0078407cdfab0f6b88fa0 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 14 Mar 2018 11:44:34 +0100
Subject: [PATCH 083/509] Make the prebuild hook executable

---
 hooks/pre_build_distgen | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 hooks/pre_build_distgen

diff --git a/hooks/pre_build_distgen b/hooks/pre_build_distgen
old mode 100644
new mode 100755

From e0f1454a095fb6c87a1735b7c33176fae1876092 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 16 Mar 2018 09:51:50 +0100
Subject: [PATCH 084/509] Properly quote SUMMARY label

---
 src/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index d85a08ed..42520ecd 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -21,7 +21,7 @@ ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management sys
 The image contains the client and server programs that you'll need to \
 create, run, maintain and access a PostgreSQL DBMS server."
 
-LABEL summary=$SUMMARY \
+LABEL summary="$SUMMARY" \
       description="$DESCRIPTION" \
       io.k8s.description="$DESCRIPTION" \
       io.k8s.display-name="PostgreSQL {{ spec.version }}" \

From b121b5cc1e1c52ef3942353a535bbc38e1a32989 Mon Sep 17 00:00:00 2001
From: Ben Parees <bparees@redhat.com>
Date: Mon, 19 Mar 2018 17:35:13 -0400
Subject: [PATCH 085/509] use local reference policy for tags

---
 imagestreams/postgresql-centos7.json | 17 ++++++++++++++++-
 imagestreams/postgresql-rhel7.json   | 17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index dc6654fe..7c38d44d 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -21,6 +21,9 @@
         "from": {
           "kind": "ImageStreamTag",
           "name": "9.6"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -36,6 +39,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "docker.io/openshift/postgresql-92-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -45,12 +51,15 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.4 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "hidden,database,postgresql",
           "version": "9.4"
         },
         "from": {
           "kind": "DockerImage",
           "name": "docker.io/centos/postgresql-94-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -66,6 +75,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "docker.io/centos/postgresql-95-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -81,6 +93,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "docker.io/centos/postgresql-96-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       }
     ]
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 3a6374de..8fbe2d7f 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -21,6 +21,9 @@
         "from": {
           "kind": "ImageStreamTag",
           "name": "9.6"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -36,6 +39,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "registry.access.redhat.com/openshift3/postgresql-92-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -45,12 +51,15 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.4 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "hidden,database,postgresql",
           "version": "9.4"
         },
         "from": {
           "kind": "DockerImage",
           "name": "registry.access.redhat.com/rhscl/postgresql-94-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -66,6 +75,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       },
       {
@@ -81,6 +93,9 @@
         "from": {
           "kind": "DockerImage",
           "name": "registry.access.redhat.com/rhscl/postgresql-96-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
         }
       }
     ]

From 0f0b8eaa106f74493dfd3f3c440bbfa1d795461e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 21 Mar 2018 12:32:15 +0100
Subject: [PATCH 086/509] pre-build: init the submodule before calling make

---
 hooks/pre_build_distgen | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hooks/pre_build_distgen b/hooks/pre_build_distgen
index 378ba917..bbbde12d 100755
--- a/hooks/pre_build_distgen
+++ b/hooks/pre_build_distgen
@@ -3,4 +3,6 @@ yum install epel-release -y
 # our deps
 yum install distgen make -y
 
+# common.mk lives in submodule, init first
+git submodule update --init
 make TARGET=centos7 generate

From 732e63b83b8cad721e6546327b5ff889aa043b92 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 19 Mar 2018 08:05:26 +0100
Subject: [PATCH 087/509] Add 'postgresql-pre-start' hook

- also cleanup some stderr output caused by missing '../init' and
  '../pre-start' directory
- add missing double-quotes
---
 src/root/usr/bin/run-postgresql               | 13 ++++-
 .../container-scripts/postgresql/README.md    |  7 +++
 .../container-scripts/postgresql/common.sh    | 51 ++++++++++---------
 3 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/src/root/usr/bin/run-postgresql b/src/root/usr/bin/run-postgresql
index 48ff4258..8af06d39 100755
--- a/src/root/usr/bin/run-postgresql
+++ b/src/root/usr/bin/run-postgresql
@@ -8,6 +8,11 @@ export_vars=$(cgroup-limits) ; export $export_vars
 source "${CONTAINER_SCRIPTS_PATH}/common.sh"
 
 set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
 check_env_vars
 generate_passwd_file
 generate_postgresql_config
@@ -24,12 +29,16 @@ fi
 
 pg_ctl -w start -o "-h ''"
 if $PG_INITIALIZED ; then
-    process_extending_files ${APP_DATA}/src/postgresql-init ${CONTAINER_SCRIPTS_PATH}/init
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
     migrate_db
     create_users
 fi
 
-process_extending_files ${APP_DATA}/src/postgresql-start ${CONTAINER_SCRIPTS_PATH}/start
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
 
 pg_ctl stop
 
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index a24a1cbf..ff9cd849 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -252,6 +252,13 @@ $ s2i build ~/image-configuration/ postgresql new-postgresql
 The directory passed to `s2i build` should contain one or more of the
 following directories:
 
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
 ##### `postgresql-cfg/`
 
 Contained configuration files (`*.conf`) will be included at the end of image
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index bf433987..cdc379b5 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -408,31 +408,34 @@ try_pgupgrade ()
   run_pgupgrade
 }
 
-# get_matched_files finds file for image extending
-function get_matched_files() {
-  local custom_dir default_dir
-  custom_dir="$1"
-  default_dir="$2"
-  files_matched="$3"
-  find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
-  [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n"
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
 }
 
-# process_extending_files process extending files in $1 and $2 directories
-# - source all *.sh files
-#   (if there are files with same name source only file from $1)
-function process_extending_files() {
-  local custom_dir default_dir
-  custom_dir=$1
-  default_dir=$2
-
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
   while read filename ; do
-    echo "=> sourcing $filename ..."
-    # Custom file is prefered
-    if [ -f $custom_dir/$filename ]; then
-      source $custom_dir/$filename
-    elif [ -f $default_dir/$filename ]; then
-      source $default_dir/$filename
-    fi
-  done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)"
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }

From b737ad26db4f8769e775ca165284f62c7f2a66db Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Sun, 11 Mar 2018 11:55:43 +0100
Subject: [PATCH 088/509] postgresql-pre-start hook example and test

- run 'initdb' from 'assemble', and bake the datadir into image
- install hook which extracts the tarball when data is not
  initialized

Fixes: #220
---
 examples/s2i-dump-data/.s2i/bin/assemble      | 36 +++++++++++++++++++
 examples/s2i-dump-data/init/init.sql          |  2 ++
 .../postgresql-pre-start/10_boot.sh           |  3 ++
 test/run_test                                 | 20 +++++++++++
 4 files changed, 61 insertions(+)
 create mode 100755 examples/s2i-dump-data/.s2i/bin/assemble
 create mode 100644 examples/s2i-dump-data/init/init.sql
 create mode 100644 examples/s2i-dump-data/postgresql-pre-start/10_boot.sh

diff --git a/examples/s2i-dump-data/.s2i/bin/assemble b/examples/s2i-dump-data/.s2i/bin/assemble
new file mode 100755
index 00000000..48e9e0c1
--- /dev/null
+++ b/examples/s2i-dump-data/.s2i/bin/assemble
@@ -0,0 +1,36 @@
+#! /usr/bin/bash -x
+
+# fail early
+set -e
+
+# source the convenience tooling
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+# set $PGDATA variable
+set_pgdata
+
+# assert uninitialized data
+test ! -f "$PGDATA/postgresql.conf"
+
+# empty config file is needed after 'initialize_database' call
+touch "$POSTGRESQL_CONFIG_FILE"
+
+initialize_database
+
+# start local PostgreSQL server (wait with '-w')
+pg_ctl -w start -o "-h ''"
+
+# load all sql files
+shopt -s nullglob
+for file in /tmp/src/init/*.sql; do
+    psql -f "$file"
+done
+
+pg_ctl stop
+
+# dump the data into $PWD (in-image storage)
+tar caf data.tar.xz -C "$PGDATA" .
+rm -rf "$PGDATA"
+
+# install pre-start hook
+cp -r /tmp/src/postgresql-pre-start .
diff --git a/examples/s2i-dump-data/init/init.sql b/examples/s2i-dump-data/init/init.sql
new file mode 100644
index 00000000..6cda639c
--- /dev/null
+++ b/examples/s2i-dump-data/init/init.sql
@@ -0,0 +1,2 @@
+CREATE TABLE test (sth TEXT);
+INSERT INTO test VALUES ('hello world');
diff --git a/examples/s2i-dump-data/postgresql-pre-start/10_boot.sh b/examples/s2i-dump-data/postgresql-pre-start/10_boot.sh
new file mode 100644
index 00000000..ad85bcb4
--- /dev/null
+++ b/examples/s2i-dump-data/postgresql-pre-start/10_boot.sh
@@ -0,0 +1,3 @@
+if test ! -f "$PGDATA/postgresql.conf"; then
+    tar xf "$APP_DATA"/src/data.tar.xz -C "$PGDATA"
+fi
diff --git a/test/run_test b/test/run_test
index d7f26da4..2b95e895 100755
--- a/test/run_test
+++ b/test/run_test
@@ -26,6 +26,7 @@ run_master_restart_test
 run_doc_test
 run_s2i_test
 run_test_cfg_hook
+run_s2i_bake_data_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -707,6 +708,25 @@ run_test_cfg_hook()
   assert_runtime_option "$name-3" shared_buffers 111MB
 }
 
+run_s2i_bake_data_test ()
+{
+  local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
+  s2i build "file://$test_dir/../examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name"
+  ct_path_append images_to_clean "$s2i_image_name"
+
+  local container_name=bake-data-test
+
+  DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
+    IMAGE_NAME="$s2i_image_name" create_container "$container_name"
+
+  wait_ready "$container_name"
+
+  test "hello world" == "$(docker exec "$(get_cid "$container_name")" \
+                           bash -c "psql -tA -c 'SELECT * FROM test;'")"
+
+  docker stop "$(get_cid "$container_name")"
+}
+
 function run_all_tests() {
   for test_case in $TEST_LIST; do
     : "Running test $test_case"

From 048ee0dfae404b9c71baa36fdc155bfdbf54c89d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 19 Mar 2018 07:30:20 +0100
Subject: [PATCH 089/509] PostgreSQL 10

- pg_basebackup dropped -x option, use '-X fetch' instead
- rework the Dockerfile.template so Dockerfile.rhel7 can use
  development build-repository (till we release the packages at
  least in beta channel)
- invent NOT_RELEASED_VERSIONS variable to be able to list
  containers' versions which are not yet in docker registry
---
 .gitignore                            |  2 ++
 Makefile                              |  7 +++++--
 specs/multispec.yml                   | 18 +++++++++++++++---
 src/Dockerfile                        | 18 +++++++++++++++---
 src/root/usr/bin/run-postgresql-slave |  2 +-
 test/run-openshift                    | 20 +++++++++++++++++++-
 test/run_test                         |  4 ++--
 7 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index 11e45256..41dd2ca0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
 help.1
 /pagila*.rpm
 /postgresql-container-pagila.sql
+/9.[456]
+/10
diff --git a/Makefile b/Makefile
index 73a47347..af0fabb8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.4 9.5 9.6
+VERSIONS = 9.4 9.5 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
+NOT_RELEASED_VERSIONS = 10
 
 # HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
 # New clones should use '--recursive'.
@@ -9,8 +10,10 @@ OPENSHIFT_NAMESPACES = 9.2
 
 include common/common.mk
 
+script_env += NOT_RELEASED_VERSIONS="$(NOT_RELEASED_VERSIONS)"
+
 # Additional upgrade tests.  Not hooked into CI ATM.
 upgrade-tests: $(VERSIONS)
-	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local
+	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local
 
 build-serial: generate
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 15d28042..1d14a422 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -25,9 +25,8 @@ specs:
        environment_setup: >-4
            yum install -y yum-utils gettext && \
                prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-       staging_repo_setup: ""
-       rhscl3_introduced:
-         - "9.6"
+       rhscl_version:
+         development: 3.1
 
   version:
     "9.4":
@@ -68,3 +67,16 @@ specs:
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
       stable: True
+
+    "10":
+      version: "10"
+      prev_version: "9.6"
+      short: "10"
+      pkgs: "rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql96-postgresql-server"
+      enabled_collection: "rh-postgresql10"
+      openshift_tags: "database,postgresql,postgresql10,rh-postgresql10"
+      redhat_component: "rh-postgresql10-docker"
+      stable: False
+      has_devel_repo:
+        centos: True
+        rhel: brew
diff --git a/src/Dockerfile b/src/Dockerfile
index 42520ecd..7c265dd5 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -29,7 +29,9 @@ LABEL summary="$SUMMARY" \
       io.openshift.tags="{{ spec.openshift_tags }}" \
       name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
       com.redhat.component="{{ spec.redhat_component }}" \
-{%- if spec.version in spec.rhscl3_introduced %}
+{%- if spec.version not in ["9.4", "9.5", "9.6"] %}
+      version="1" \
+{%- elif spec.version == "9.6" and config.os.id == "rhel" %}
       version="1" \
 {%- else %}
       version="{{ spec.version }}" \
@@ -48,8 +50,18 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {{ spec.repo_enable_reason }}
 {%- endif %}
 RUN {{ spec.environment_setup }}
-{%- if not spec.stable and spec.staging_repo_setup %}
-{{ spec.staging_repo_setup }}
+{%- if not spec.stable and spec.has_devel_repo %}
+  {%- if config.os.id == 'centos' and spec.has_devel_repo.centos %}
+    yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql{{ spec.version }}-rh-candidate/x86_64/os/ && \
+    echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql{{ spec.version }}-rh-candidate_x86_64_os_.repo && \
+  {%- elif config.os.id == 'rhel' %}
+    {%- if spec.has_devel_repo.rhel == 'brew' %}
+    yum-config-manager --add-repo http://download.devel.redhat.com/brewroot/repos/rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build/latest/x86_64 && \
+    echo gpgcheck=0 >> /etc/yum.repos.d/download.devel.redhat.com_brewroot_repos_rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build_latest_x86_64.repo && \
+    {%- elif spec.has_devel_repo.rhel == 'beta' %}
+    yum-config-manager --enable rhel-server-rhscl-7-beta-rpms && \
+    {%- endif %}
+  {%- endif %}
 {%- endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/src/root/usr/bin/run-postgresql-slave b/src/root/usr/bin/run-postgresql-slave
index be327a93..82113b76 100755
--- a/src/root/usr/bin/run-postgresql-slave
+++ b/src/root/usr/bin/run-postgresql-slave
@@ -13,7 +13,7 @@ function initialize_replica() {
   echo "Initializing PostgreSQL slave ..."
   # TODO: Validate and reuse existing data?
   rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -x --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
 
   # PostgreSQL recovery configuration.
   generate_postgresql_recovery_config
diff --git a/test/run-openshift b/test/run-openshift
index a4a268e5..04bd65ed 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -147,6 +147,7 @@ function test_postgresql_update() {
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip=""
+  local version released=:
 
   case $OS in
   rhel7)
@@ -158,7 +159,24 @@ function test_postgresql_update() {
   esac
 
   old_image="$registry/$image_name"
-  docker pull "$old_image" 2>/dev/null
+
+  for version in $NOT_RELEASED_VERSIONS; do
+    case $image_name in
+      *$version*)
+        released=false
+        break
+        ;;
+    esac
+  done
+
+  if docker pull "$old_image" 2>/dev/null; then
+    $released
+  else
+    # We can not test against released image.
+    ! $released
+    return
+  fi
+
 
   # Use also remote template to make sure the new image works regardless of
   # template changes
diff --git a/test/run_test b/test/run_test
index 2b95e895..9a4328a4 100755
--- a/test/run_test
+++ b/test/run_test
@@ -569,7 +569,7 @@ $volume_options
 
 run_upgrade_test ()
 {
-    local upgrade_path="none 9.2 9.4 9.5 9.6 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -585,7 +585,7 @@ run_upgrade_test ()
 run_migration_test ()
 {
     local from_version
-    local upgrade_path="9.2 9.4 9.5 9.6"
+    local upgrade_path="9.2 9.4 9.5 9.6 10"
 
     for from_version in $upgrade_path; do
         # Do not test migration from $VERSION:remote to $VERSION:local

From b0d4755dd99b8dc6a4ce21209d9133fc3e6f8211 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 13 Mar 2018 09:27:18 +0100
Subject: [PATCH 090/509] fix locking TODO in pagila.sh

---
 test/pagila.sh | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/test/pagila.sh b/test/pagila.sh
index dd064f84..123c6bb0 100755
--- a/test/pagila.sh
+++ b/test/pagila.sh
@@ -13,20 +13,21 @@ pagila=$pagila_mirror$pagila_base
 pagila_file="$PWD/postgresql-container-pagila.sql"
 pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae802701
 
-if test ! -f "$pagila_file"; then
-    # TODO: better avoid race-conditions
-    touch "$pagila_file"
-
-    ( set -o pipefail
-      curl -s "$pagila" > "$pagila_base"
-      for file in ./usr/share/pagila/pagila-schema.sql \
-          ./usr/share/pagila/pagila-data.sql \
-          ./usr/share/pagila/pagila-insert-data.sql ; \
-      do
-        rpm2cpio "$pagila_base" | cpio --extract --to-stdout "$file"
-      done >"$pagila_file"
-    )
-fi
+(
+  flock --timeout 180 9
+
+  # Already downloaded?
+  test ! -f "$pagila_file" || exit 0
+
+  set -o pipefail
+  curl -s "$pagila" > "$pagila_base"
+  for file in ./usr/share/pagila/pagila-schema.sql \
+      ./usr/share/pagila/pagila-data.sql \
+      ./usr/share/pagila/pagila-insert-data.sql ; \
+  do
+    rpm2cpio "$pagila_base" | cpio --extract --to-stdout "$file"
+  done >"$pagila_file"
+) 9<"$0"
 
 case $(sha256sum "$pagila_file") in
 "$pagila_sha256sum"*) ;;

From 1d6401c16b4c1ffc931b410a484988bab87d1a92 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 7 Mar 2018 15:57:55 +0100
Subject: [PATCH 091/509] run_test: use bash arrays instead of ct_path_foreach

.. for images' garbage collector.  The tests are often used with
IMAGE_NAME=image_name:image_tag, and ':' caused troubles before.

Fixes: #246
---
 test/run_test | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/run_test b/test/run_test
index 9a4328a4..45bc1edc 100755
--- a/test/run_test
+++ b/test/run_test
@@ -37,7 +37,7 @@ test -n "${OS-}" || false 'make sure $OS is defined'
 CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
 volumes_to_clean=
-images_to_clean=
+images_to_clean=()
 files_to_clean=
 test_dir="$(readlink -f "$(dirname "$0")")"
 
@@ -73,8 +73,13 @@ function cleanup() {
   rmdir $CIDFILE_DIR
 
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
-  ct_path_foreach "$images_to_clean" cleanup_image
+
+  for image in "${images_to_clean[@]}"; do
+    docker rmi -f "$image"
+  done
+
   ct_path_foreach "$files_to_clean" rm
+
   echo "$_cleanup_commands" | while read -r line; do
     eval "$line"
   done
@@ -94,11 +99,6 @@ cleanup_volume_dir ()
   rmdir "$1"
 }
 
-cleanup_image ()
-{
-    docker rmi -f "$1"
-}
-
 function get_cid() {
   local id="$1" ; shift || return 1
   echo $(cat "$CIDFILE_DIR/$id")
@@ -651,7 +651,7 @@ run_s2i_test() {
   echo "  Testing s2i build"
 
   local s2i_image_name=$IMAGE_NAME-testapp_$(ct_random_string)
-  ct_path_append images_to_clean "$s2i_image_name"
+  images_to_clean+=( "$s2i_image_name" )
 
   s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name"
   IMAGE_NAME=$s2i_image_name test_the_app_image s2i_config_build ""

From 655cd3541aeec3eb242150f44edbe1fb07a900ab Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 22 Mar 2018 11:21:57 +0100
Subject: [PATCH 092/509] tests: print oc logs on failure

---
 test/run-openshift | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/run-openshift b/test/run-openshift
index 04bd65ed..4986d4e5 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -356,6 +356,9 @@ function test_postgresql_ephemeral_redeploy() {
 }
 
 ct_os_cluster_up
+# Print oc logs on failure
+ct_os_enable_print_logs
+
 test_postgresql_pure_image "${IMAGE_NAME}"
 test_postgresql_template "${IMAGE_NAME}"
 test_postgresql_ephemeral_redeploy "${IMAGE_NAME}"

From f8cc473559066936738f74efbff39b691abbd624 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 21 Mar 2018 14:43:43 +0100
Subject: [PATCH 093/509] Add content_sets.yml

---
 manifest.sh          |  3 +++
 src/content_sets.yml | 10 ++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 src/content_sets.yml

diff --git a/manifest.sh b/manifest.sh
index be08be08..f3fb41fb 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -39,6 +39,9 @@ COPY_RULES="
     dest=root/usr/libexec/fix-permissions
     mode=0755;
 
+    src=src/content_sets.yml
+    dest=content_sets.yml;
+
     src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
     dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template;
 
diff --git a/src/content_sets.yml b/src/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/src/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms

From 050ec7fee5a4bbd1429b5bedbe54a69450a99bb3 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 29 Mar 2018 10:30:12 +0200
Subject: [PATCH 094/509] tests: fix run_s2i_bake_data_test image cleanup

---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 45bc1edc..9ca17667 100755
--- a/test/run_test
+++ b/test/run_test
@@ -712,7 +712,7 @@ run_s2i_bake_data_test ()
 {
   local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
   s2i build "file://$test_dir/../examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name"
-  ct_path_append images_to_clean "$s2i_image_name"
+  images_to_clean+=( "$s2i_image_name" )
 
   local container_name=bake-data-test
 

From 80b565365b9fb573b3b12f9560e780c195a84066 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 4 Apr 2018 11:45:09 +0200
Subject: [PATCH 095/509] Update common submodule to have the option to specify
 oc version

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 6adc2c4c..0ed2139b 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 6adc2c4c58628ece3e9cd78b7fbd1021c3c1dfdd
+Subproject commit 0ed2139bd3ef4758cdc715ba4ebc3c45f648372e

From c6f17c3b7ac257aeb7271c4cc0a6c151d0db4b19 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Sat, 7 Apr 2018 09:42:05 +0200
Subject: [PATCH 096/509] Use symlink for example files so the test works fine
 after moving to dist-git

---
 test/run_test | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index 9ca17667..1ca5703f 100755
--- a/test/run_test
+++ b/test/run_test
@@ -683,7 +683,7 @@ run_test_cfg_hook()
   volume_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
   add_cleanup_command /bin/rm -rf "$volume_dir"
   setfacl -R -m u:26:rwx "$volume_dir"
-  cp -r "$test_dir"/../examples/custom-config/* "$volume_dir"
+  cp -r "$test_dir"/examples/custom-config/* "$volume_dir"
   setfacl -R -m u:26:rwx "$volume_dir"
 
   DOCKER_ARGS="
@@ -711,7 +711,7 @@ run_test_cfg_hook()
 run_s2i_bake_data_test ()
 {
   local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
-  s2i build "file://$test_dir/../examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name"
+  s2i build "file://$test_dir/examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name"
   images_to_clean+=( "$s2i_image_name" )
 
   local container_name=bake-data-test

From 431f159835fb867c327bb5a3909397d42632bc3a Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 10 Apr 2018 12:59:04 +0200
Subject: [PATCH 097/509] readme: add links pointing to postgresql:generated
 for documentation

---
 README.md | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index e74c2701..362605cd 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,9 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently provided are:
-* [postgresql-9.4](9.4)
-* [postgresql-9.5](9.5)
-* [postgresql-9.6](latest)
+* [postgresql-9.4](https://github.com/sclorg/postgresql-container/tree/generated/9.4)
+* [postgresql-9.5](https://github.com/sclorg/postgresql-container/tree/generated/9.5)
+* [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -76,13 +76,13 @@ Usage
 ---------------------------------
 
 For information about usage of Dockerfile for PostgreSQL 9.4,
-see [usage documentation](9.4).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.4).
 
 For information about usage of Dockerfile for PostgreSQL 9.5,
-see [usage documentation](9.5).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.5).
 
 For information about usage of Dockerfile for PostgreSQL 9.6,
-see [usage documentation](latest).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
 
 Test
 ---------------------------------

From 21f4e82338c52a7810ffd07f8f9844f486ade0a4 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Apr 2018 08:34:42 +0200
Subject: [PATCH 098/509] tests: Fix centos failures due to postgresql10 being
 unreleased on rhel

---
 test/run-openshift | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/run-openshift b/test/run-openshift
index 4986d4e5..23295ad7 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -170,7 +170,9 @@ function test_postgresql_update() {
   done
 
   if docker pull "$old_image" 2>/dev/null; then
-    $released
+    # Check if we do not have a stale unreleased versions list
+    # Fail only on rhel, on centos the image is likely already released
+    $released || [ "$OS" = "centos7" ]
   else
     # We can not test against released image.
     ! $released

From 6b1ad1012fe233bc0472870d0c9afa3f8878b243 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 18 Apr 2018 09:46:25 +0200
Subject: [PATCH 099/509] add missing fields to multispec for version 10

---
 specs/multispec.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 1d14a422..24360a0a 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -76,6 +76,9 @@ specs:
       enabled_collection: "rh-postgresql10"
       openshift_tags: "database,postgresql,postgresql10,rh-postgresql10"
       redhat_component: "rh-postgresql10-docker"
+      common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-10-rhel7"
+      centos_image_name: "centos/postgresql-10-centos7"
       stable: False
       has_devel_repo:
         centos: True

From 010e50d32db5ce5d8da58ce668a0fe42d75cc557 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 16 Apr 2018 12:32:37 +0200
Subject: [PATCH 100/509] tests: run openshift tests against both local and
 remote origin templates

Additionally, as the paths to the template files are now held in environment variables,
it is now possible to override the default template configuration by providing different
template files through setting the template envvars before running the test suite.
---
 test/run-openshift | 115 +++++++++++++++++++++++++++------------------
 1 file changed, 70 insertions(+), 45 deletions(-)

diff --git a/test/run-openshift b/test/run-openshift
index 23295ad7..7c9f3644 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -8,6 +8,7 @@
 
 THISDIR=$(dirname ${BASH_SOURCE[0]})
 TEMPLATES="$THISDIR/examples"
+REMOTE_TEMPLATES="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates"
 
 source "$THISDIR"/test-lib-openshift.sh
 
@@ -17,6 +18,19 @@ test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
+# Populate template variables if not set already
+if [ -z "${EPHEMERAL_TEMPLATES:-}" ]; then
+  EPHEMERAL_TEMPLATES="
+$REMOTE_TEMPLATES/postgresql-ephemeral-template.json
+$TEMPLATES/postgresql-ephemeral-template.json"
+fi
+
+if [ -z "${PERSISTENT_TEMPLATES:-}" ]; then
+  PERSISTENT_TEMPLATES="
+$REMOTE_TEMPLATES/postgresql-persistent-template.json
+$TEMPLATES/postgresql-persistent-template.json"
+fi
+
 function assert_cmd_fails() {
   if eval "$@" &>/dev/null; then
     echo " FAIL"
@@ -120,14 +134,15 @@ function test_postgresql_pure_image() {
 }
 
 function test_postgresql_template() {
-  local image_name=${1:-centos/postgresql-96-centos7}
+  local image_name=$1; shift
+  local template=$1
   local image_name_no_namespace=${image_name##*/}
   local service_name=${image_name_no_namespace}
 
   ct_os_new_project
   ct_os_upload_image "${image_name}" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$TEMPLATES/postgresql-ephemeral-template.json" \
+  ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="${service_name}" \
@@ -142,7 +157,8 @@ function test_postgresql_template() {
 }
 
 function test_postgresql_update() {
-  local image_name=$1
+  local image_name=$1; shift
+  local template=$1
   local image_name_no_namespace=${image_name##*/}
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
@@ -180,38 +196,31 @@ function test_postgresql_update() {
   fi
 
 
-  # Use also remote template to make sure the new image works regardless of
-  # template changes
-  for template in \
-        "https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/postgresql-persistent-template.json" \
-        "$TEMPLATES/postgresql-persistent-template.json"
-  do
-    ct_os_new_project
-    ct_os_upload_image "$old_image" "postgresql:$VERSION"
-    ct_os_deploy_template_image "$template" \
-                                NAMESPACE="$(oc project -q)" \
-                                POSTGRESQL_VERSION="$VERSION" \
-                                DATABASE_SERVICE_NAME="$service_name" \
-                                POSTGRESQL_USER="$user" \
-                                POSTGRESQL_PASSWORD="$pass" \
-                                POSTGRESQL_DATABASE="$db"
-
-    ct_os_wait_pod_ready "${service_name}" 60
-    check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-    pod_ip=$(ct_os_get_service_ip "$service_name")
-    insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-
-    ct_os_upload_image "$image_name" "postgresql:$VERSION"
-    : "Waiting for a few seconds while the pods get restarted"
-    sleep 5
-
-    ct_os_wait_pod_ready "$service_name" 60
-    check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-    check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-    ct_os_delete_project
-  done
+  ct_os_new_project
+  ct_os_upload_image "$old_image" "postgresql:$VERSION"
+  ct_os_deploy_template_image "$template" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
+                              DATABASE_SERVICE_NAME="$service_name" \
+                              POSTGRESQL_USER="$user" \
+                              POSTGRESQL_PASSWORD="$pass" \
+                              POSTGRESQL_DATABASE="$db"
+
+  ct_os_wait_pod_ready "${service_name}" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  pod_ip=$(ct_os_get_service_ip "$service_name")
+  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+
+  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  : "Waiting for a few seconds while the pods get restarted"
+  sleep 5
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
+
+  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
+  ct_os_delete_project
 }
 
 function test_postgresql_replication() {
@@ -284,7 +293,8 @@ function test_postgresql_replication() {
 }
 
 function test_postgresql_persistent_redeploy() {
-  local image_name=$1
+  local image_name=$1; shift
+  local template=$1
   local image_name_no_namespace=${image_name##*/}
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
@@ -293,7 +303,7 @@ function test_postgresql_persistent_redeploy() {
   ct_os_new_project
   ct_os_upload_image "$image_name" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$TEMPLATES/postgresql-persistent-template.json" \
+  ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="$service_name" \
@@ -321,7 +331,8 @@ function test_postgresql_persistent_redeploy() {
 }
 
 function test_postgresql_ephemeral_redeploy() {
-  local image_name=$1
+  local image_name=$1; shift
+  local template=$1
   local image_name_no_namespace=${image_name##*/}
   local service_name=$image_name_no_namespace
   local user="testu" pass="testp" db="testdb"
@@ -330,7 +341,7 @@ function test_postgresql_ephemeral_redeploy() {
   ct_os_new_project
   ct_os_upload_image "$image_name" "postgresql:$VERSION"
 
-  ct_os_deploy_template_image "$TEMPLATES/postgresql-ephemeral-template.json" \
+  ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
                               DATABASE_SERVICE_NAME="$service_name" \
@@ -357,13 +368,27 @@ function test_postgresql_ephemeral_redeploy() {
   ct_os_delete_project
 }
 
+function run_ephemeral_tests() {
+  local image_name=$1
+  for template in $EPHEMERAL_TEMPLATES; do
+    test_postgresql_ephemeral_redeploy "$image_name" "$template"
+    test_postgresql_template "$image_name" "$template"
+  done
+}
+
+function run_persistent_tests() {
+  local image_name=$1
+  for template in $PERSISTENT_TEMPLATES; do
+    test_postgresql_persistent_redeploy "$image_name" "$template"
+    test_postgresql_update "$image_name" "$template"
+  done
+}
+
 ct_os_cluster_up
 # Print oc logs on failure
 ct_os_enable_print_logs
 
-test_postgresql_pure_image "${IMAGE_NAME}"
-test_postgresql_template "${IMAGE_NAME}"
-test_postgresql_ephemeral_redeploy "${IMAGE_NAME}"
-test_postgresql_persistent_redeploy "${IMAGE_NAME}"
-test_postgresql_update "${IMAGE_NAME}"
-test_postgresql_replication "${IMAGE_NAME}"
+test_postgresql_pure_image "$IMAGE_NAME"
+test_postgresql_replication "$IMAGE_NAME"
+run_ephemeral_tests "$IMAGE_NAME"
+run_persistent_tests "$IMAGE_NAME"

From 4a7ce3eef2b322882c4a14b863aa81fc0cd4dab9 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 25 Apr 2018 20:18:14 +0200
Subject: [PATCH 101/509] templates: compat fix with distgen >= v1.0

---
 src/Dockerfile                                | 28 +++++++++----------
 .../container-scripts/postgresql/common.sh    |  4 +--
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index 7c265dd5..3cdeef6a 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -29,13 +29,13 @@ LABEL summary="$SUMMARY" \
       io.openshift.tags="{{ spec.openshift_tags }}" \
       name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
       com.redhat.component="{{ spec.redhat_component }}" \
-{%- if spec.version not in ["9.4", "9.5", "9.6"] %}
+{% if spec.version not in ["9.4", "9.5", "9.6"] %}
       version="1" \
-{%- elif spec.version == "9.6" and config.os.id == "rhel" %}
+{% elif spec.version == "9.6" and config.os.id == "rhel" %}
       version="1" \
-{%- else %}
+{% else %}
       version="{{ spec.version }}" \
-{%- endif %}
+{% endif %}
       usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
@@ -46,23 +46,23 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-{%- if spec.repo_enable_reason %}
+{% if spec.repo_enable_reason %}
 {{ spec.repo_enable_reason }}
-{%- endif %}
+{% endif %}
 RUN {{ spec.environment_setup }}
-{%- if not spec.stable and spec.has_devel_repo %}
-  {%- if config.os.id == 'centos' and spec.has_devel_repo.centos %}
+{% if not spec.stable and spec.has_devel_repo %}
+  {% if config.os.id == 'centos' and spec.has_devel_repo.centos %}
     yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql{{ spec.version }}-rh-candidate/x86_64/os/ && \
     echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql{{ spec.version }}-rh-candidate_x86_64_os_.repo && \
-  {%- elif config.os.id == 'rhel' %}
-    {%- if spec.has_devel_repo.rhel == 'brew' %}
+  {% elif config.os.id == 'rhel' %}
+    {% if spec.has_devel_repo.rhel == 'brew' %}
     yum-config-manager --add-repo http://download.devel.redhat.com/brewroot/repos/rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build/latest/x86_64 && \
     echo gpgcheck=0 >> /etc/yum.repos.d/download.devel.redhat.com_brewroot_repos_rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build_latest_x86_64.repo && \
-    {%- elif spec.has_devel_repo.rhel == 'beta' %}
+    {% elif spec.has_devel_repo.rhel == 'beta' %}
     yum-config-manager --enable rhel-server-rhscl-7-beta-rpms && \
-    {%- endif %}
-  {%- endif %}
-{%- endif %}
+    {% endif %}
+  {% endif %}
+{% endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index cdc379b5..5f99484d 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -70,10 +70,10 @@ function check_env_vars() {
     [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
     [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
     [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
-{%- raw %}
+{% raw %}
     [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
     [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-{%- endraw %}
+{% endraw %}
     postinitdb_actions+=",simple_db"
   fi
 

From 0f18019279392e07fe082d3c0ce237ce624f1250 Mon Sep 17 00:00:00 2001
From: Michal Cyprian <m.cyprian@gmail.com>
Date: Wed, 4 Apr 2018 07:43:41 +0200
Subject: [PATCH 102/509] Divide distgen rules in manifest into simple and
 multi rules

---
 manifest.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/manifest.sh b/manifest.sh
index f3fb41fb..b83176b4 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -5,12 +5,6 @@ DESTDIR='' # optional, defaults to $PWD
 
 # Files containing distgen directives
 DISTGEN_RULES="
-    src=src/Dockerfile
-    dest=Dockerfile;
-
-    src=src/Dockerfile
-    dest=Dockerfile.rhel7;
-
     src=src/cccp.yml
     dest=cccp.yml;
 
@@ -21,6 +15,16 @@ DISTGEN_RULES="
     dest=root/usr/share/container-scripts/postgresql/common.sh
 "
 
+# Files containing distgen directives, which are used for each
+# (distro, version) combination not excluded in multispec
+DISTGEN_MULTI_RULES="
+    src=src/Dockerfile
+    dest=Dockerfile;
+
+    src=src/Dockerfile
+    dest=Dockerfile.rhel7
+"
+
 # Symbolic links
 SYMLINK_RULES="
     link_target=root/usr/share/container-scripts/postgresql/README.md

From 840e8b1994f62659404f89c69222236947bd6353 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 3 May 2018 08:51:31 +0200
Subject: [PATCH 103/509] Update to latest common scripts

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 0ed2139b..d7a8ea22 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0ed2139bd3ef4758cdc715ba4ebc3c45f648372e
+Subproject commit d7a8ea221b082bfc2fc7415279811225a259e30d

From 7ce001687bafc3386deb0bfd0979ce6f1410afcb Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 3 May 2018 08:54:03 +0200
Subject: [PATCH 104/509] Makefile: add clean-hook for removing versioned dirs

---
 Makefile | 2 ++
 common   | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index af0fabb8..7495e890 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,8 @@ BASE_IMAGE_NAME = postgresql
 VERSIONS = 9.4 9.5 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS = 10
+# use clean-versions provided by common.mk
+clean-hook = clean-versions
 
 # HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
 # New clones should use '--recursive'.
diff --git a/common b/common
index d7a8ea22..38564360 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit d7a8ea221b082bfc2fc7415279811225a259e30d
+Subproject commit 385643601dd4136a31abeaedd493e7909770beef

From a389cfc86c5cb031c89bff44960fc0dc7d3a5d03 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 3 May 2018 13:41:19 +0200
Subject: [PATCH 105/509] clean-hook target instead of variable

Per sclorg/container-common-scripts#85.
---
 Makefile | 5 +++--
 common   | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 7495e890..a1929393 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,6 @@ BASE_IMAGE_NAME = postgresql
 VERSIONS = 9.4 9.5 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS = 10
-# use clean-versions provided by common.mk
-clean-hook = clean-versions
 
 # HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
 # New clones should use '--recursive'.
@@ -12,6 +10,9 @@ clean-hook = clean-versions
 
 include common/common.mk
 
+# use clean-versions provided by common.mk
+clean-hook: clean-versions
+
 script_env += NOT_RELEASED_VERSIONS="$(NOT_RELEASED_VERSIONS)"
 
 # Additional upgrade tests.  Not hooked into CI ATM.
diff --git a/common b/common
index 38564360..cd94f2d9 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 385643601dd4136a31abeaedd493e7909770beef
+Subproject commit cd94f2d9d72ea54d49aa4acdab3e8bb55bc519b6

From 13b2a28054193d20285f5149683eb290ad3b0f0e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 11 May 2018 10:34:56 +0200
Subject: [PATCH 106/509] Remove brew repositories from postgresql 10

---
 Makefile            | 2 +-
 specs/multispec.yml | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a1929393..ce62423a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 BASE_IMAGE_NAME = postgresql
 VERSIONS = 9.4 9.5 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
-NOT_RELEASED_VERSIONS = 10
+NOT_RELEASED_VERSIONS =
 
 # HACK:  Ensure that 'git pull' for old clones doesn't cause confusion.
 # New clones should use '--recursive'.
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 24360a0a..f0fb43ab 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -82,4 +82,3 @@ specs:
       stable: False
       has_devel_repo:
         centos: True
-        rhel: brew

From e7eb6d600ed0b7aa0c516f98ce3500534b72922d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 11 May 2018 10:56:42 +0200
Subject: [PATCH 107/509] run-openshift: better check whether image was
 released

Needed because `! true` actually doesn't exit with `set -e` shell.
---
 test/run-openshift | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/run-openshift b/test/run-openshift
index 7c9f3644..8df7e273 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -189,10 +189,10 @@ function test_postgresql_update() {
     # Check if we do not have a stale unreleased versions list
     # Fail only on rhel, on centos the image is likely already released
     $released || [ "$OS" = "centos7" ]
+  elif $released; then
+    false "image '$old_image' should already be available"
   else
-    # We can not test against released image.
-    ! $released
-    return
+    return # not yet released image, skip
   fi
 
 

From 56f58d6c568f0687393c7579b1aa5621025c76db Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 11 May 2018 15:00:26 +0200
Subject: [PATCH 108/509] multispec: drop redundant 'spec.stable' flag

---
 specs/multispec.yml | 4 ----
 src/Dockerfile      | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index f0fb43ab..8f22974d 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -40,7 +40,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-94-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-94-rhel7"
       centos_image_name: "centos/postgresql-94-centos7"
-      stable: True
 
     "9.5":
       version: "9.5"
@@ -53,7 +52,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-95-rhel7"
       centos_image_name: "centos/postgresql-95-centos7"
-      stable: True
 
     "9.6":
       version: "9.6"
@@ -66,7 +64,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
-      stable: True
 
     "10":
       version: "10"
@@ -79,6 +76,5 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos/postgresql-10-centos7"
-      stable: False
       has_devel_repo:
         centos: True
diff --git a/src/Dockerfile b/src/Dockerfile
index 3cdeef6a..e73707f1 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -50,7 +50,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {{ spec.repo_enable_reason }}
 {% endif %}
 RUN {{ spec.environment_setup }}
-{% if not spec.stable and spec.has_devel_repo %}
+{% if spec.has_devel_repo %}
   {% if config.os.id == 'centos' and spec.has_devel_repo.centos %}
     yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql{{ spec.version }}-rh-candidate/x86_64/os/ && \
     echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql{{ spec.version }}-rh-candidate_x86_64_os_.repo && \

From 5a7a34a73cc200bb4aaf7bb698d5aedffb3c2d25 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 May 2018 14:47:07 +0200
Subject: [PATCH 109/509] Add postgresql 10 imagestreams

---
 imagestreams/postgresql-centos7.json | 20 +++++++++++++++++++-
 imagestreams/postgresql-rhel7.json   | 20 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index 7c38d44d..7c30214e 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -20,7 +20,7 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "9.6"
+          "name": "10"
         },
         "referencePolicy": {
           "type": "Local"
@@ -97,6 +97,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/10/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-10-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 8fbe2d7f..9ee7f847 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -20,7 +20,7 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "9.6"
+          "name": "10"
         },
         "referencePolicy": {
           "type": "Local"
@@ -97,6 +97,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/10/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.access.redhat.com/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }

From c76d9193e46b1699a9b5b422cff2163b2fc7ec8a Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 May 2018 14:51:03 +0200
Subject: [PATCH 110/509] Use working readme links in the description for
 imagestreams

---
 imagestreams/postgresql-centos7.json | 8 ++++----
 imagestreams/postgresql-rhel7.json   | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index 7c30214e..4577ef65 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
@@ -67,7 +67,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.5",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.5/README.md.",
+          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.5/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.5"
@@ -85,7 +85,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.6/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.6"
@@ -103,7 +103,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/10/README.md.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "10"
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 9ee7f847..2da626bc 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
@@ -67,7 +67,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.5",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.5/README.md.",
+          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.5/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.5"
@@ -85,7 +85,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.6/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.6/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.6"
@@ -103,7 +103,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/10/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "10"

From e54b34a6ab3959b8997238077a09083dbcae225d Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 May 2018 13:12:57 +0200
Subject: [PATCH 111/509] Deprecate version 9.4

Mention version 10 in the README
---
 Makefile  |  2 +-
 README.md | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index ce62423a..364e1c71 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.4 9.5 9.6 10
+VERSIONS = 9.5 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index 362605cd..0633c7ff 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,9 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently provided are:
-* [postgresql-9.4](https://github.com/sclorg/postgresql-container/tree/generated/9.4)
 * [postgresql-9.5](https://github.com/sclorg/postgresql-container/tree/generated/9.5)
 * [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
+* [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -33,10 +33,10 @@ Choose either the CentOS7 or RHEL7 based image:
 
 *  **RHEL7 based image**
 
-    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-96-rhel7).
+    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-10-rhel7).
     To download it run:
     ```
-    docker pull registry.access.redhat.com/rhscl/postgresql-96-rhel7
+    docker pull registry.access.redhat.com/rhscl/postgresql-10-rhel7
     ```
 
     To build a RHEL7 based image, you need to run Docker build on a properly
@@ -45,7 +45,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONS=9.6
+    $ make build TARGET=rhel7 VERSIONS=10
     ```
 
 *  **CentOS7 based image**
@@ -53,7 +53,7 @@ Choose either the CentOS7 or RHEL7 based image:
     These images are available on DockerHub. To download it run:
 
     ```
-    $ docker pull centos/postgresql-96-centos7
+    $ docker pull centos/postgresql-10-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -61,7 +61,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSIONS=9.6
+    $ make build TARGET=centos7 VERSIONS=10
     ```
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
@@ -75,15 +75,15 @@ In this repository [distgen](https://github.com/devexp-db/distgen/) is used for
 Usage
 ---------------------------------
 
-For information about usage of Dockerfile for PostgreSQL 9.4,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.4).
-
 For information about usage of Dockerfile for PostgreSQL 9.5,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.5).
 
 For information about usage of Dockerfile for PostgreSQL 9.6,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
 
+For information about usage of Dockerfile for PostgreSQL 10,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
+
 Test
 ---------------------------------
 
@@ -99,19 +99,19 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSIONS=9.6
+    $ make test TARGET=rhel7 VERSIONS=10
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSIONS=9.6
+    $ make test TARGET=centos7 VERSIONS=10
     ```
 +By using the `TEST_CASE` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSIONS=9.6 TEST_CASE="run_general_tests run_replication_test"
+    $ make test VERSIONS=10 TEST_CASE="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed

From 2eae0672868187d01d3a821b81c848877d8454b0 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 May 2018 14:32:10 +0200
Subject: [PATCH 112/509] Remove version 9.4 from multispec as well

---
 specs/multispec.yml | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 8f22974d..c14323c0 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -29,18 +29,6 @@ specs:
          development: 3.1
 
   version:
-    "9.4":
-      version: "9.4"
-      prev_version: "9.2"
-      short: "94"
-      pkgs: "rh-postgresql94 rh-postgresql94-postgresql-contrib postgresql92-postgresql-server rh-postgresql94-postgresql-upgrade"
-      enabled_collection: "rh-postgresql94"
-      openshift_tags: "database,postgresql,postgresql94,rh-postgresql94"
-      redhat_component: "rh-postgresql94-docker"
-      common_image_name: "{{ spec.org }}/postgresql-94-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-94-rhel7"
-      centos_image_name: "centos/postgresql-94-centos7"
-
     "9.5":
       version: "9.5"
       prev_version: "9.4"

From 7ac561c00b407ef5925f8db54c2729392253510d Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 May 2018 15:54:43 +0200
Subject: [PATCH 113/509] Update to latest common scripts

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index cd94f2d9..962ec058 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit cd94f2d9d72ea54d49aa4acdab3e8bb55bc519b6
+Subproject commit 962ec058e47619871d57570eeba3a8f109e24099

From 61b7b2c218146fc083158b055346d529c3eea965 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 25 May 2018 08:52:20 +0200
Subject: [PATCH 114/509] Fix README comment about distgen

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 0633c7ff..b3b51c3c 100644
--- a/README.md
+++ b/README.md
@@ -70,7 +70,7 @@ on all provided versions of PostgreSQL.**
 Contributing
 --------------------------------
 
-In this repository [distgen](https://github.com/devexp-db/distgen/) is used for generating Dockerfiles. If you'd like update a Dockerfile, please make changes in specs/multispec.yml and/or Dockerfile.template (or other distgen file) and run `make generate_dockerfiles`.
+In this repository [distgen](https://github.com/devexp-db/distgen/) is used for generating image source files. If you'd like update a Dockerfile, please make changes in specs/multispec.yml and/or Dockerfile.template (or other distgen file) and run `make generate`.
 
 Usage
 ---------------------------------

From 673cd38014d195149d020c633f192e230602b59e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 14 Jun 2018 10:22:52 +0200
Subject: [PATCH 115/509] Update dockerfiles to use new BZ components

---
 specs/multispec.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index c14323c0..bed4ae35 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -36,7 +36,7 @@ specs:
       pkgs: "rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server"
       enabled_collection: "rh-postgresql95"
       openshift_tags: "database,postgresql,postgresql95,rh-postgresql95"
-      redhat_component: "rh-postgresql95-docker"
+      redhat_component: "rh-postgresql95-container"
       common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-95-rhel7"
       centos_image_name: "centos/postgresql-95-centos7"
@@ -48,7 +48,7 @@ specs:
       pkgs: "rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server"
       enabled_collection: "rh-postgresql96"
       openshift_tags: "database,postgresql,postgresql96,rh-postgresql96"
-      redhat_component: "rh-postgresql96-docker"
+      redhat_component: "rh-postgresql96-container"
       common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
@@ -60,7 +60,7 @@ specs:
       pkgs: "rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql96-postgresql-server"
       enabled_collection: "rh-postgresql10"
       openshift_tags: "database,postgresql,postgresql10,rh-postgresql10"
-      redhat_component: "rh-postgresql10-docker"
+      redhat_component: "rh-postgresql10-container"
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos/postgresql-10-centos7"

From 406027cd695f244bce398a2d7d9a35317a364d5c Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 22 Aug 2018 07:22:28 +0200
Subject: [PATCH 116/509] README: simplify searching for older documentation

Complements #290, so users can easily search even documentation
for older images.
---
 README.md | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index b3b51c3c..db780b20 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ For more information about concepts used in these container images, see the
 
 Versions
 ---------------
-PostgreSQL versions currently provided are:
+PostgreSQL versions currently supported are:
 * [postgresql-9.5](https://github.com/sclorg/postgresql-container/tree/generated/9.5)
 * [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
@@ -84,6 +84,11 @@ see [usage documentation](https://github.com/sclorg/postgresql-container/tree/ge
 For information about usage of Dockerfile for PostgreSQL 10,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
 
+For versions which are not supported anymore:
+[PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
+and
+[PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4).
+
 Test
 ---------------------------------
 

From d9eec303fbfb0fd509777f0f9a207c679d1b6170 Mon Sep 17 00:00:00 2001
From: Ben Parees <bparees@redhat.com>
Date: Sun, 19 Aug 2018 23:35:55 -0400
Subject: [PATCH 117/509] fix documentation links

---
 imagestreams/postgresql-centos7.json | 12 ++++++------
 imagestreams/postgresql-rhel7.json   | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index 4577ef65..a82b0a8e 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
@@ -31,7 +31,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.2",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.2 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.2/README.md.",
+          "description": "Provides a PostgreSQL 9.2 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "hidden,postgresql",
           "version": "9.2"
@@ -49,7 +49,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.4",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.4 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
+          "description": "Provides a PostgreSQL 9.4 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "hidden,database,postgresql",
           "version": "9.4"
@@ -67,7 +67,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.5",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.5/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.5"
@@ -85,7 +85,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.6/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.6"
@@ -103,7 +103,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "10"
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 2da626bc..f8910fdd 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
@@ -31,7 +31,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.2",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.2 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.2/README.md.",
+          "description": "Provides a PostgreSQL 9.2 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "hidden,postgresql",
           "version": "9.2"
@@ -49,7 +49,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.4",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.4 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/tree/master/9.4/README.md.",
+          "description": "Provides a PostgreSQL 9.4 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "hidden,database,postgresql",
           "version": "9.4"
@@ -67,7 +67,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL 9.5",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.5/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.5"
@@ -85,7 +85,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/9.6/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "9.6"
@@ -103,7 +103,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/generated/10/root/usr/share/container-scripts/postgresql/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
           "version": "10"

From f16db9ecc25f692d6f9f7000456177da45a29669 Mon Sep 17 00:00:00 2001
From: Ben Parees <bparees@redhat.com>
Date: Wed, 15 Aug 2018 14:41:22 -0400
Subject: [PATCH 118/509] update imagestreams to registry.redhat.io

registry.redhat.io is the future of the redhat container catalog, registry.access.redhat.com is going to be shut down at some point in the future. The new registry requires authentication and the local reference policy allows the openshift internal registry to perform that authentication on the user's behalf so that every use on a cluster doesn't have to provide their own registry.redhat.io credentials.
---
 imagestreams/postgresql-rhel7.json | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index f8910fdd..15e26822 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -38,7 +38,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.access.redhat.com/openshift3/postgresql-92-rhel7:latest"
+          "name": "registry.redhat.io/openshift3/postgresql-92-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -56,7 +56,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.access.redhat.com/rhscl/postgresql-94-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-94-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -74,7 +74,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.access.redhat.com/rhscl/postgresql-95-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-95-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -92,7 +92,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.access.redhat.com/rhscl/postgresql-96-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -110,7 +110,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.access.redhat.com/rhscl/postgresql-10-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"

From cbca1c1d8c77fbb49b35868915c8d358a5458cf0 Mon Sep 17 00:00:00 2001
From: root <root@c.c.test.com>
Date: Tue, 7 Aug 2018 14:20:07 -0400
Subject: [PATCH 119/509] Edit existing examples to only include imagestream
 versions that support both x86 and ppc64le.

---
 examples/postgresql-ephemeral-template.json  |  4 +-
 examples/postgresql-persistent-template.json |  4 +-
 imagestreams/postgresql-rhel7-ppc64le.json   | 49 ++++++++++++++++++++
 3 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 imagestreams/postgresql-rhel7-ppc64le.json

diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index d4b58608..adf65bff 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -245,8 +245,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
-      "value": "9.6",
+      "description": "Version of PostgreSQL image to be used (10 or latest).",
+      "value": "10",
       "required": true
     }
   ]
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index abfe6d66..5ba3aa19 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -269,8 +269,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
-      "value": "9.6",
+      "description": "Version of PostgreSQL image to be used (10 or latest).",
+      "value": "10",
       "required": true
     }
   ]
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel7-ppc64le.json
new file mode 100644
index 00000000..021ed019
--- /dev/null
+++ b/imagestreams/postgresql-rhel7-ppc64le.json
@@ -0,0 +1,49 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "10"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      }
+    ]
+  }
+}

From 8121b7925073e0ad764e7b7068f393f1e552fe4c Mon Sep 17 00:00:00 2001
From: liangxia <lxia@redhat.com>
Date: Wed, 19 Sep 2018 12:23:16 +0800
Subject: [PATCH 120/509] URL of OKD is docs.okd.io now

---
 README.md                                    |  2 +-
 examples/postgresql-ephemeral-template.json  |  2 +-
 examples/postgresql-persistent-template.json |  2 +-
 examples/replica/README.md                   | 10 +++++-----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index db780b20..40990933 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.
 
 For more information about using these images with OpenShift, please see the
-official [OpenShift Documentation](https://docs.openshift.org/latest/using_images/db_images/postgresql.html).
+official [OpenShift Documentation](https://docs.okd.io/latest/using_images/db_images/postgresql.html).
 
 For more information about contributing, see
 [the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index d4b58608..41b026c6 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -10,7 +10,7 @@
       "tags": "database,postgresql",
       "openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is not stored on persistent storage, so any restart of the service will result in all data being lost.  The database name, username, and password are chosen via parameters when provisioning this service.",
       "openshift.io/provider-display-name": "Red Hat, Inc.",
-      "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "openshift.io/documentation-url": "https://docs.okd.io/latest/using_images/db_images/postgresql.html",
       "openshift.io/support-url": "https://access.redhat.com"
     }
   },
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index abfe6d66..11efe3d9 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -10,7 +10,7 @@
       "tags": "database,postgresql",
       "openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created.  The database is stored on persistent storage.  The database name, username, and password are chosen via parameters when provisioning this service.",
       "openshift.io/provider-display-name": "Red Hat, Inc.",
-      "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/postgresql.html",
+      "openshift.io/documentation-url": "https://docs.okd.io/latest/using_images/db_images/postgresql.html",
       "openshift.io/support-url": "https://access.redhat.com"
     }
   },
diff --git a/examples/replica/README.md b/examples/replica/README.md
index 8f7accac..b7c546d1 100644
--- a/examples/replica/README.md
+++ b/examples/replica/README.md
@@ -23,7 +23,7 @@ A standby server can also be used for read-only queries.
 
 ## Deployment
 
-This example uses a [PersistentVolumeClaim](https://docs.openshift.org/latest/architecture/additional_concepts/storage.html#persistent-volume-claims)
+This example uses a [PersistentVolumeClaim](https://docs.okd.io/latest/architecture/additional_concepts/storage.html#persistent-volume-claims)
 to request persistent storage for the primary PostgreSQL server.
 
 You need to have persistent volumes configured and available in your project in
@@ -53,7 +53,7 @@ $ oc create -f - <<EOF
 EOF
 ```
 
-It is recommended, however, that you use other [type of PersistentVolume](https://docs.openshift.org/latest/architecture/additional_concepts/storage.html#types-of-persistent-volumes)
+It is recommended, however, that you use other [type of PersistentVolume](https://docs.okd.io/latest/architecture/additional_concepts/storage.html#types-of-persistent-volumes)
 such as NFS.
 
 Now you can create a new database deployment:
@@ -81,7 +81,7 @@ $ dig postgresql-slave A +search +short
 
 ### DeploymentConfig 'postgresql-master'
 
-This resource defines a [deployment configuration](https://docs.openshift.org/latest/architecture/core_concepts/deployments.html#deployments-and-deployment-configurations)
+This resource defines a [deployment configuration](https://docs.okd.io/latest/architecture/core_concepts/deployments.html#deployments-and-deployment-configurations)
 to spawn the PostgreSQL primary database server, or master.
 
 Once the master is started, it works as a standalone database server, fully
@@ -89,7 +89,7 @@ independent  of the slaves.
 
 ### DeploymentConfig 'postgresql-slave'
 
-This resource defines a [deployment configuration](https://docs.openshift.org/latest/architecture/core_concepts/deployments.html#deployments-and-deployment-configurations)
+This resource defines a [deployment configuration](https://docs.okd.io/latest/architecture/core_concepts/deployments.html#deployments-and-deployment-configurations)
 to spawn PostgreSQL standby servers, the slaves.
 
 Upon startup, each slave waits for the master server to become available (via
@@ -224,7 +224,7 @@ deploymentconfigs/postgresql-slave
 This will trigger the redeployment of both primary and standby servers.
 
 Note that, as a current limitation in this example, the standby servers store
-replicated data in an an ephemeral [emptyDir](https://docs.openshift.org/latest/dev_guide/volumes.html).
+replicated data in an an ephemeral [emptyDir](https://docs.okd.io/latest/dev_guide/volumes.html).
 This means that redeploying a standby server will cause it to start replicating
 again from scratch.
 

From 7be27111df0bca5eb9f078d7675cf56024360f64 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 20 Sep 2018 14:12:52 +0200
Subject: [PATCH 121/509] test: use ct_s2i functions

---
 common        | 2 +-
 test/run_test | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common b/common
index 962ec058..45fd8b10 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 962ec058e47619871d57570eeba3a8f109e24099
+Subproject commit 45fd8b10d0b10d6a3808a58612fc6de4fb0368a3
diff --git a/test/run_test b/test/run_test
index 1ca5703f..eb45c1d7 100755
--- a/test/run_test
+++ b/test/run_test
@@ -646,14 +646,14 @@ ${mount_opts}
 run_s2i_test() {
   local temp_file
   echo "  Testing s2i usage"
-  s2i usage --pull-policy=never "${IMAGE_NAME}" &>/dev/null
+  ct_s2i_usage "${IMAGE_NAME}" --pull-policy=never 1>/dev/null
 
   echo "  Testing s2i build"
 
   local s2i_image_name=$IMAGE_NAME-testapp_$(ct_random_string)
   images_to_clean+=( "$s2i_image_name" )
 
-  s2i build "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name"
+  ct_s2i_build_as_df "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
   IMAGE_NAME=$s2i_image_name test_the_app_image s2i_config_build ""
 
   echo "  Testing s2i mount"
@@ -711,7 +711,7 @@ run_test_cfg_hook()
 run_s2i_bake_data_test ()
 {
   local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
-  s2i build "file://$test_dir/examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name"
+  ct_s2i_build_as_df "file://$test_dir/examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
   images_to_clean+=( "$s2i_image_name" )
 
   local container_name=bake-data-test

From b3d22e2365ceaf616c7de5fc4e6e99c84c833094 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 4 Oct 2018 09:45:11 +0200
Subject: [PATCH 122/509] tests: Do not rely on docker/podman re-using IPs in
 master restart

Podman does not re-use the same IP at all and docker documentation says it is not ensured
anyway so the best thing to do is to change the master server address manually during testing.

Modifying the /etc/hosts has been chosen as podman has very limited networking capabilities
compared to docker (eg. no 'podman network' or 'podman run --link ...').
---
 test/run_test | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/test/run_test b/test/run_test
index eb45c1d7..b49d447b 100755
--- a/test/run_test
+++ b/test/run_test
@@ -370,7 +370,7 @@ function run_tests() {
 
 function run_slave() {
   local suffix="$1"; shift
-  docker run $cluster_args -e POSTGRESQL_MASTER_IP=${master_ip} \
+  docker run $cluster_args -e POSTGRESQL_MASTER_IP=${master_hostname} \
     -d --cidfile ${CIDFILE_DIR}/slave-${suffix}.cid $IMAGE_NAME run-postgresql-slave
 }
 
@@ -386,6 +386,12 @@ function test_slave_visibility() {
 
   for slave in $slave_cids; do
     slave_ip=$(get_ip_from_cid $slave)
+    if [ -z "$slave_ip" ]; then
+        echo "Failed to get IP for slave $slave."
+        echo "Dumping logs for $slave"
+        docker logs "$slave"
+        return 1
+    fi
     for i in $(seq $max_attempts); do
       result="$(postgresql_cmd -c "select client_addr from pg_stat_replication;" | grep "$slave_ip" || true)"
       if [[ -n "${result}" ]]; then
@@ -434,11 +440,13 @@ function test_value_replication() {
 
 function setup_replication_cluster() {
   # Run the PostgreSQL master
-  run_master $cid_suffix
-  master_ip=$(get_container_ip master-$cid_suffix.cid)
+  run_master "$cid_suffix"
 
   # Run the PostgreSQL slaves
   local i
+  master_ip=$(get_container_ip "master-$cid_suffix.cid")
+  local cluster_args="$cluster_args --add-host postgresql-master:$master_ip"
+  local master_hostname="postgresql-master"
   for i in $(seq ${slave_num:-1}); do
     slave_cids="$slave_cids $(run_slave $cid_suffix-$i)"
   done
@@ -476,6 +484,11 @@ function run_master_restart_test() {
   run_master $cid_suffix
   CONTAINER_IP=$(get_container_ip master-$cid_suffix.cid)
 
+  # Update master_ip in slaves
+  for slave in $slave_cids; do
+    docker exec -u 0 $slave bash -c "sed \"s/$master_ip/$CONTAINER_IP/g\" /etc/hosts >/tmp/hosts && cp /tmp/hosts /etc/hosts"
+  done
+  master_ip=$CONTAINER_IP
   # Check if the new master sees existing slaves
   test_slave_visibility
 

From df5f0984f76ea1dc581e349447645fb689333387 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Thu, 29 Mar 2018 09:48:25 +0200
Subject: [PATCH 123/509] Let the username/password validation on PostgreSQL

Remove the artificial limitations for the username/password format
given by our scripting, and start using 'psql --set' feature to
avoid sql injection (previously we guarded against sql injection
by the regexps).  Benefits sum-up:

 - protection against sql injection for free
 - our passwords can contain spaces and other special characters,
   using them in passwords is generally considered to be good
   practice
 - simplified, more readable "usage" output

The downside is that the rejection of the wrongly specified
passwords/usernames is a bit delayed (till the PostgreSQL is is
running to perform the actual validation).  But because PostgreSQL
itself doesn't create any unexpected requirements on the values,
it is newly more unlikely to get such failure.
---
 .../container-scripts/postgresql/common.sh    | 13 +---
 .../postgresql/start/set_passwords.sh         | 17 ++++--
 test/run_test                                 | 61 +++++++++++++++++--
 3 files changed, 70 insertions(+), 21 deletions(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 5f99484d..b44611a5 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -23,9 +23,6 @@ export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
 postinitdb_actions=
 
-psql_identifier_regex='^[a-zA-Z_][a-zA-Z0-9_]*$'
-psql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$'
-
 # match . files when moving userdata below
 shopt -s dotglob
 # extglob enables the !(userdata) glob pattern below.
@@ -39,11 +36,9 @@ function usage() {
   cat >&2 <<EOF
 For general container run, you must either specify the following environment
 variables:
-  POSTGRESQL_USER (regex: '$psql_identifier_regex')
-  POSTGRESQL_PASSWORD (regex: '$psql_password_regex')
-  POSTGRESQL_DATABASE (regex: '$psql_identifier_regex')
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
 Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD (regex: '$psql_password_regex')
+  POSTGRESQL_ADMIN_PASSWORD
 Or both.
 
 To migrate data from different PostgreSQL container:
@@ -67,9 +62,6 @@ function check_env_vars() {
   if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
     # one var means all three must be specified
     [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-    [[ "$POSTGRESQL_USER"     =~ $psql_identifier_regex ]] || usage
-    [[ "$POSTGRESQL_PASSWORD" =~ $psql_password_regex   ]] || usage
-    [[ "$POSTGRESQL_DATABASE" =~ $psql_identifier_regex ]] || usage
 {% raw %}
     [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
     [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
@@ -78,7 +70,6 @@ function check_env_vars() {
   fi
 
   if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    [[ "$POSTGRESQL_ADMIN_PASSWORD" =~ $psql_password_regex ]] || usage
     postinitdb_actions+=",admin_pass"
   fi
 
diff --git a/src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
index f14ff46a..60d70e36 100644
--- a/src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ b/src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -1,14 +1,23 @@
 #!/bin/bash
 
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
 if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-psql --command "ALTER USER \"${POSTGRESQL_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_PASSWORD}';"
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
 fi
 
 if [ -v POSTGRESQL_MASTER_USER ]; then
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH REPLICATION;"
-psql --command "ALTER USER \"${POSTGRESQL_MASTER_USER}\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_MASTER_PASSWORD}';"
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
 fi
 
 if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';"
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
 fi
diff --git a/test/run_test b/test/run_test
index b49d447b..036a0872 100755
--- a/test/run_test
+++ b/test/run_test
@@ -115,7 +115,7 @@ function get_ip_from_cid() {
 }
 
 function postgresql_cmd() {
-  docker run --rm -e PGPASSWORD="${PASS}" $IMAGE_NAME psql postgresql://$PGUSER@$CONTAINER_IP:5432/"${DB-db}" "$@"
+  docker run --rm -e PGPASSWORD="$PASS" "$IMAGE_NAME" psql "postgresql://$PGUSER@$CONTAINER_IP:5432/${DB-db}" "$@"
 }
 
 function test_connection() {
@@ -160,9 +160,12 @@ function test_postgresql() {
 function create_container() {
   local name=$1 ; shift
   local cargs=${DOCKER_ARGS:-}
+  # TODO: fix all create_container() invocations so that we don't need this,
+  # e.g. multiline DOCKER_ARGS var should end by trailing backslashes
+  cargs=$(echo "$cargs" | tr  '\n' ' ')
   cidfile="$CIDFILE_DIR/$name"
   # create container with a cidfile in a directory for cleanup
-  docker run $cargs --cidfile $cidfile -d $IMAGE_NAME "$@"
+  eval "docker run $cargs --cidfile \$cidfile -d \$IMAGE_NAME \"\$@\""
   echo "Created container $(cat $cidfile)"
 }
 
@@ -228,6 +231,49 @@ function assert_container_creation_fails() {
   fi
 }
 
+
+# assert_container_creation_succeeds NAME [ARGS]
+# ----------------------------------------------
+# Chcek that 'docker run' with IMAGE_NAME succeeds with docker arguments
+# specified as ARGS.
+assert_container_creation_succeeds ()
+{
+  local check_env=false
+  local name=pg-success-"$(ct_random_string)"
+  local PGUSER='' PGPASS=''  DB=''  ADMIN_PASS=
+  local docker_args=
+
+  for arg; do
+    docker_args+=" $(printf "%q" "$arg")"
+    if $check_env; then
+      local env=${arg//=*/}
+      local val=${arg//$env=/}
+      case $env in
+        POSTGRESQL_ADMIN_PASSWORD)  ADMIN_PASS=$val ;;
+        POSTGRESQL_USER)            PGUSER=$val ;;
+        POSTGRESQL_PASSWORD)        PGPASS=$val ;;
+        POSTGRESQL_DATABASE)        DB=$val ;;
+      esac
+      check_env=false
+    elif test "$arg" = -e; then
+      check_env=:
+    fi
+  done
+
+  DOCKER_ARGS=$docker_args create_container "$name"
+
+  if test -n "$PGUSER" && test -n "$PGPASS"; then
+    PGUSER=$PGUSER PASS=$PGPASS DB=$DB test_connection "$name"
+  fi
+
+  if test -n "$ADMIN_PASS"; then
+    PGUSER=postgres PASS=$ADMIN_PASS DB=$DB test_connection "$name"
+  fi
+
+  docker stop "$(get_cid "$name")"
+}
+
+
 function try_image_invalid_combinations() {
   assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass "$@"
   assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_DATABASE=db "$@"
@@ -240,13 +286,16 @@ function run_container_creation_tests() {
   try_image_invalid_combinations  -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
 
   VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-  assert_container_creation_fails -e POSTGRESQL_USER=0invalid -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
+  assert_container_creation_fails -e POSTGRESQL_USER= -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
   assert_container_creation_fails -e POSTGRESQL_USER=$VERY_LONG_IDENTIFIER -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
   assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=$VERY_LONG_IDENTIFIER -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\""
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\""
   echo "  Success!"
+
+  assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD="the @password"
+  assert_container_creation_succeeds -e POSTGRESQL_PASSWORD="the pass" -e POSTGRESQL_USER="the user" -e POSTGRESQL_DATABASE="the db"
 }
 
 function test_config_option() {

From fd9d6b6d10f486981562c86788372207451184c3 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 5 Oct 2018 11:59:38 +0200
Subject: [PATCH 124/509] tests: fix cleanup hook for empty images_to_clean
 array

---
 test/run_test | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/run_test b/test/run_test
index 036a0872..66ea57c8 100755
--- a/test/run_test
+++ b/test/run_test
@@ -74,9 +74,13 @@ function cleanup() {
 
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
 
-  for image in "${images_to_clean[@]}"; do
-    docker rmi -f "$image"
-  done
+  if test -n "${images_to_clean-}"; then
+    # Workaround for RHEL 7 bash bug:
+    # https://bugzilla.redhat.com/show_bug.cgi?id=1636393
+    for image in "${images_to_clean[@]}"; do
+      docker rmi -f "$image"
+    done
+  fi
 
   ct_path_foreach "$files_to_clean" rm
 

From d9fe71d5a1f0fd23173f96a1c62a0237c8659e13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Skalick=C3=BD?= <MSkalicky@seznam.cz>
Date: Mon, 5 Nov 2018 09:58:10 +0000
Subject: [PATCH 125/509] Generate Fedora Dockerfile using distgen. (#298)

* Generate Fedora Dockerfile using distgen.

Remove release label - in Fedora it's updated automatically by
build system.

Remove arch label - 'Optional: if omitted, it will be built for
all supported Fedora Architectures'

Skip upgrade and migration test for Fedora images - uses
completely different system how to get name of an image which
contains previous version of postgresql

+ make fedora Dockerfile more similar to other OSes

* Don't generate Fedora dockerfile for 9.5 - F25 is EOL

* Fix replication test to expect built images in format localhost/<NAMESPACE>/<NAME>
---
 common                |  2 +-
 manifest.sh           |  7 +++++--
 specs/multispec.yml   | 12 ++++++++++++
 src/Dockerfile.fedora | 33 +++++++++++++++++++--------------
 test/run-openshift    |  6 +++---
 test/run_test         |  4 ++++
 6 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/common b/common
index 45fd8b10..ff5003c7 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 45fd8b10d0b10d6a3808a58612fc6de4fb0368a3
+Subproject commit ff5003c72f2cfdfbb905c1bca19d22c381d810fc
diff --git a/manifest.sh b/manifest.sh
index b83176b4..f86ce80d 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -12,7 +12,7 @@ DISTGEN_RULES="
     dest=root/usr/share/container-scripts/postgresql/README.md;
 
     src=src/root/usr/share/container-scripts/postgresql/common.sh
-    dest=root/usr/share/container-scripts/postgresql/common.sh
+    dest=root/usr/share/container-scripts/postgresql/common.sh;
 "
 
 # Files containing distgen directives, which are used for each
@@ -22,7 +22,10 @@ DISTGEN_MULTI_RULES="
     dest=Dockerfile;
 
     src=src/Dockerfile
-    dest=Dockerfile.rhel7
+    dest=Dockerfile.rhel7;
+
+    src=src/Dockerfile.fedora
+    dest=Dockerfile.fedora;
 "
 
 # Symbolic links
diff --git a/specs/multispec.yml b/specs/multispec.yml
index bed4ae35..571bc351 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -27,6 +27,9 @@ specs:
                prepare-yum-repositories rhel-server-rhscl-7-rpms && \
        rhscl_version:
          development: 3.1
+    fedora:
+      distros:
+        - fedora-29-x86_64
 
   version:
     "9.5":
@@ -40,6 +43,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-95-rhel7"
       centos_image_name: "centos/postgresql-95-centos7"
+      latest_fedora: "f25"
 
     "9.6":
       version: "9.6"
@@ -52,6 +56,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
+      latest_fedora: "f27"
 
     "10":
       version: "10"
@@ -64,5 +69,12 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos/postgresql-10-centos7"
+      latest_fedora: "f29"
       has_devel_repo:
         centos: True
+
+matrix:
+  exclude:
+    - distros:
+        - fedora-29-x86_64
+      version: "9.5"
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 71f78a10..1d7dd8dc 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM registry.fedoraproject.org/fedora:26
+FROM registry.fedoraproject.org/{{ spec.latest_fedora }}/s2i-core:latest
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -12,43 +12,40 @@ FROM registry.fedoraproject.org/fedora:26
 
 ENV NAME=postgresql \
     VERSION=0 \
-    RELEASE=1 \
     ARCH=x86_64 \
     \
-    POSTGRESQL_VERSION=9.6 \
-    POSTGRESQL_PREV_VERSION=9.5 \
+    POSTGRESQL_VERSION={{ spec.version }} \
+    POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
     HOME=/var/lib/pgsql \
-    PGUSER=postgres
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
 
 ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
     DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
 The image contains the client and server programs that you'll need to \
 create, run, maintain and access a PostgreSQL DBMS server."
 
-LABEL summary=$SUMMARY \
+LABEL summary="$SUMMARY" \
       description="$DESCRIPTION" \
       io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 9.6" \
+      io.k8s.display-name="PostgreSQL {{ spec.version }}" \
       io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql96" \
+      io.openshift.tags="database,postgresql,postgresql{{ spec.short }}" \
       com.redhat.component="$NAME" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
       name="$FGC/$NAME" \
       version="0" \
-      release="$RELEASE.$DISTTAG" \
-      architecture="$ARCH" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME" \
-      help="/help.1"
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME"
 
 EXPOSE 5432
 
-ADD root /
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils python2 " && \
+    INSTALL_PKGS+="findutils python2 xz" && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     dnf clean all && \
@@ -60,8 +57,16 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
 VOLUME ["/var/lib/pgsql/data"]
 
+# {APP_DATA} needs to be accessed by postgres user while s2i assembling
+# postgres user changes permissions of files in APP_DATA during assembling
+RUN /usr/libexec/fix-permissions ${APP_DATA} && \
+    usermod -a -G root postgres
+
 USER 26
 
 ENTRYPOINT ["container-entrypoint"]
diff --git a/test/run-openshift b/test/run-openshift
index 8df7e273..ef6254d5 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -159,8 +159,8 @@ function test_postgresql_template() {
 function test_postgresql_update() {
   local image_name=$1; shift
   local template=$1
-  local image_name_no_namespace=${image_name##*/}
-  local service_name=$image_name_no_namespace
+  local image_name_no_registry=${image_name#*/}
+  local service_name=${image_name_no_registry#*/}
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip=""
   local version released=:
@@ -174,7 +174,7 @@ function test_postgresql_update() {
       ;;
   esac
 
-  old_image="$registry/$image_name"
+  old_image="$registry/$image_name_no_registry"
 
   for version in $NOT_RELEASED_VERSIONS; do
     case $image_name in
diff --git a/test/run_test b/test/run_test
index 66ea57c8..6557737d 100755
--- a/test/run_test
+++ b/test/run_test
@@ -635,6 +635,8 @@ $volume_options
 
 run_upgrade_test ()
 {
+    [ "${OS}" == "fedora" ] && return 0
+
     local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
@@ -650,6 +652,8 @@ run_upgrade_test ()
 
 run_migration_test ()
 {
+    [ "${OS}" == "fedora" ] && return 0
+
     local from_version
     local upgrade_path="9.2 9.4 9.5 9.6 10"
 

From 6a79ef48541d6652bc1f9ef0f30e95fafbfd2987 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 4 Dec 2018 11:49:53 +0100
Subject: [PATCH 126/509] Do not test upgrades from 9.2 image (temporarily?)

Workaround for BZ#1655214
Fixes: #303
---
 test/run_test | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index 6557737d..c849bb9b 100755
--- a/test/run_test
+++ b/test/run_test
@@ -637,7 +637,7 @@ run_upgrade_test ()
 {
     [ "${OS}" == "fedora" ] && return 0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
+    local upgrade_path="none 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -655,7 +655,7 @@ run_migration_test ()
     [ "${OS}" == "fedora" ] && return 0
 
     local from_version
-    local upgrade_path="9.2 9.4 9.5 9.6 10"
+    local upgrade_path="9.4 9.5 9.6 10"
 
     for from_version in $upgrade_path; do
         # Do not test migration from $VERSION:remote to $VERSION:local

From 4ba9f459b6c8bcc9dc3327cde94a3bf1bab26dde Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 13 Dec 2018 09:00:19 +0100
Subject: [PATCH 127/509] exclude container user's id when setting up passwd
 file

When a container is run with a recent enough podman version and using the --user
cli argument the /etc/passwd file inside the container includes a line with
the user defined via --user.

$ podman run --rm -ti --user 1001 rhel7 bash -c "cat /etc/passwd | grep 1001"
  1001:x:1001:0:container user:/:/bin/sh

Since postgresql creates a postgres user with the user id of the container user
we need to exclude the passwd line containing said user from the generated
passwd file else the initial database will not be owned by the postgres user.
---
 common                                                    | 2 +-
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common b/common
index ff5003c7..37fcee39 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit ff5003c72f2cfdfbb905c1bca19d22c381d810fc
+Subproject commit 37fcee39105a99be0dd52db2f4768010a588c826
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index b44611a5..0d7b8dd4 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -137,7 +137,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v ^postgres /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd

From 2d1488703bffe1f5ee8d5cace41dbc52afd3fb93 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 17 Jan 2019 09:04:49 +0100
Subject: [PATCH 128/509] tests: `oc deploy` is deprecated, use `oc rollout`
 instead

---
 test/run-openshift | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/run-openshift b/test/run-openshift
index ef6254d5..3345a147 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -273,7 +273,7 @@ function test_postgresql_replication() {
   check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
 
   : "Redeploying slave node"
-  oc deploy "$slave_service_name" --latest
+  oc rollout latest "$slave_service_name"
   ct_os_wait_pod_ready "$slave_service_name-3" 60
   slave_name=$(ct_os_get_pod_name "$slave_service_name")
   slave_ip=$(ct_os_get_pod_ip "$slave_name")
@@ -318,7 +318,7 @@ function test_postgresql_persistent_redeploy() {
   insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
 
   : "Redeploying pod"
-  oc deploy "$service_name" --latest
+  oc rollout latest "$service_name"
   : "Waiting for a few seconds while the pod gets restarted"
   sleep 5
 
@@ -356,7 +356,7 @@ function test_postgresql_ephemeral_redeploy() {
   insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
 
   : "Redeploying pod"
-  oc deploy "$service_name" --latest
+  oc rollout latest "$service_name"
   : "Waiting for a few seconds while the pod gets restarted"
   sleep 5
 

From cc80439c305cdefb688a02181bbc0389c9809c15 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 17 Jan 2019 12:42:45 +0100
Subject: [PATCH 129/509] tests: do not strip registry in openshift postgreqsl
 update

This is related to the revert of `localhost/` tagging in common scripts
https://github.com/sclorg/container-common-scripts/pull/106
---
 test/run-openshift | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run-openshift b/test/run-openshift
index 3345a147..ef01a05d 100755
--- a/test/run-openshift
+++ b/test/run-openshift
@@ -174,7 +174,7 @@ function test_postgresql_update() {
       ;;
   esac
 
-  old_image="$registry/$image_name_no_registry"
+  old_image="$registry/$image_name"
 
   for version in $NOT_RELEASED_VERSIONS; do
     case $image_name in

From 2461c5e9e851ca00e0ba471029641fce0d5419cb Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 12 Dec 2018 12:15:42 +0100
Subject: [PATCH 130/509] Add rhel8 version for postgresql 9.6 and 10

---
 manifest.sh                    |  7 ++-
 specs/multispec.yml            | 43 +++++++++++-----
 src/Dockerfile                 | 12 +++--
 src/cccp.yml                   |  2 +-
 src/root/usr/bin/cgroup-limits | 92 ----------------------------------
 5 files changed, 44 insertions(+), 112 deletions(-)
 delete mode 100755 src/root/usr/bin/cgroup-limits

diff --git a/manifest.sh b/manifest.sh
index f86ce80d..16e02891 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -24,6 +24,9 @@ DISTGEN_MULTI_RULES="
     src=src/Dockerfile
     dest=Dockerfile.rhel7;
 
+    src=src/Dockerfile
+    dest=Dockerfile.rhel8;
+
     src=src/Dockerfile.fedora
     dest=Dockerfile.fedora;
 "
@@ -58,10 +61,6 @@ COPY_RULES="
     src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
     dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
 
-    src=src/root/usr/bin/cgroup-limits
-    dest=root/usr/bin/cgroup-limits
-    mode=0755;
-
     src=src/root/usr/share/container-scripts/postgresql/scl_enable
     dest=root/usr/share/container-scripts/postgresql/scl_enable;
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 571bc351..add682d2 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -8,6 +8,11 @@ specs:
       s2i_base: centos/s2i-core-centos7
       org: "centos"
       prod: "centos7"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
+      redhat_component: "rh-postgresql{{ spec.short }}-container"
+      enabled_collection: "rh-postgresql{{ spec.short }}"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.prev_short }}-postgresql-server"
       repo_enable_reason: ""
       environment_setup: yum install -y centos-release-scl-rh && \
       staging_repo_setup: >-4
@@ -19,6 +24,11 @@ specs:
        s2i_base: rhscl/s2i-core-rhel7
        org: "rhscl"
        prod: "rhel7"
+       openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
+       redhat_component: "rh-postgresql{{ spec.short }}-container"
+       enabled_collection: "rh-postgresql{{ spec.short }}"
+       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.prev_short }}-postgresql-server"
        repo_enable_reason: |-
          # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
          # in base RHEL
@@ -27,6 +37,20 @@ specs:
                prepare-yum-repositories rhel-server-rhscl-7-rpms && \
        rhscl_version:
          development: 3.1
+    rhel8:
+       distros:
+         - rhel-8-x86_64
+       s2i_base: rhel8/s2i-core
+       org: "rhel8"
+       prod: "rhel8"
+       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+       redhat_component: "postgresql-{{ spec.short }}-container"
+       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
+       pkgs: "postgresql-server postgresql-contrib"
+       environment_setup: >-4
+            yum -y module enable postgresql:{{ spec.version }} && \
+       post_install: >-4
+           yum -y reinstall tzdata && \
     fedora:
       distros:
         - fedora-29-x86_64
@@ -36,39 +60,33 @@ specs:
       version: "9.5"
       prev_version: "9.4"
       short: "95"
-      pkgs: "rh-postgresql95 rh-postgresql95-postgresql-contrib rh-postgresql94-postgresql-server"
-      enabled_collection: "rh-postgresql95"
-      openshift_tags: "database,postgresql,postgresql95,rh-postgresql95"
-      redhat_component: "rh-postgresql95-container"
+      prev_short: "94"
       common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-95-rhel7"
       centos_image_name: "centos/postgresql-95-centos7"
+      cccp_job: "postgresql-95-centos7"
       latest_fedora: "f25"
 
     "9.6":
       version: "9.6"
       prev_version: "9.5"
       short: "96"
-      pkgs: "rh-postgresql96 rh-postgresql96-postgresql-contrib rh-postgresql95-postgresql-server"
-      enabled_collection: "rh-postgresql96"
-      openshift_tags: "database,postgresql,postgresql96,rh-postgresql96"
-      redhat_component: "rh-postgresql96-container"
+      prev_short: "95"
       common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
+      cccp_job: "postgresql-96-centos7"
       latest_fedora: "f27"
 
     "10":
       version: "10"
       prev_version: "9.6"
       short: "10"
-      pkgs: "rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql96-postgresql-server"
-      enabled_collection: "rh-postgresql10"
-      openshift_tags: "database,postgresql,postgresql10,rh-postgresql10"
-      redhat_component: "rh-postgresql10-container"
+      prev_short: "96"
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos/postgresql-10-centos7"
+      cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
       has_devel_repo:
         centos: True
@@ -77,4 +95,5 @@ matrix:
   exclude:
     - distros:
         - fedora-29-x86_64
+        - rhel-8-x86_64
       version: "9.5"
diff --git a/src/Dockerfile b/src/Dockerfile
index e73707f1..af630c4e 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -11,7 +11,9 @@ FROM {{ spec.s2i_base }}
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION={{ spec.version }} \
+    {% if spec.version not in ["9.6", "10"] or spec.prod != "rhel8" %}
     POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
+    {% endif %}
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
@@ -27,7 +29,7 @@ LABEL summary="$SUMMARY" \
       io.k8s.display-name="PostgreSQL {{ spec.version }}" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="{{ spec.openshift_tags }}" \
-      name="{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
+      name="{{ spec.img_name }}" \
       com.redhat.component="{{ spec.redhat_component }}" \
 {% if spec.version not in ["9.4", "9.5", "9.6"] %}
       version="1" \
@@ -36,7 +38,7 @@ LABEL summary="$SUMMARY" \
 {% else %}
       version="{{ spec.version }}" \
 {% endif %}
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.img_name }}" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432
@@ -66,6 +68,9 @@ RUN {{ spec.environment_setup }}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    {% if spec.post_install %}
+    {{ spec.post_install }}
+    {% endif %}
     yum clean all && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
@@ -80,13 +85,14 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+{% if spec.prod != "rhel8" and config.os.id != "fedora" %}
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
 ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
+{% endif %}
 VOLUME ["/var/lib/pgsql/data"]
 
 # {APP_DATA} needs to be accessed by postgres user while s2i assembling
diff --git a/src/cccp.yml b/src/cccp.yml
index 6c36ace9..c49e80d4 100644
--- a/src/cccp.yml
+++ b/src/cccp.yml
@@ -1 +1 @@
-job-id: postgresql-{{ spec.short }}-{{ spec.prod }}
+job-id: {{ spec.cccp_job }}
diff --git a/src/root/usr/bin/cgroup-limits b/src/root/usr/bin/cgroup-limits
deleted file mode 100755
index b9d4edc2..00000000
--- a/src/root/usr/bin/cgroup-limits
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/python
-
-"""
-Script for parsing cgroup information
-
-This script will read some limits from the cgroup system and parse
-them, printing out "VARIABLE=VALUE" on each line for every limit that is
-successfully read. Output of this script can be directly fed into
-bash's export command. Recommended usage from a bash script:
-
-    set -o errexit
-    export_vars=$(cgroup-limits) ; export $export_vars
-
-Variables currently supported:
-    MAX_MEMORY_LIMIT_IN_BYTES
-        Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
-        currently constant value of 9223372036854775807.
-    MEMORY_LIMIT_IN_BYTES
-        Maximum amount of user memory in bytes. If this value is set
-        to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
-        there is no limit set. The value is taken from
-        /sys/fs/cgroup/memory/memory.limit_in_bytes
-    NUMBER_OF_CORES
-        Number of detected CPU cores that can be used. This value is
-        calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
-    NO_MEMORY_LIMIT
-        Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
-        can act as if no memory limit was set. Undefined otherwise.
-"""
-
-from __future__ import print_function
-import sys
-
-
-def _read_file(path):
-    try:
-        with open(path, 'r') as f:
-            return f.read().strip()
-    except IOError:
-        return None
-
-
-def get_memory_limit():
-    """
-    Read memory limit, in bytes.
-    """
-
-    limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
-    if limit is None or not limit.isdigit():
-        print("Warning: Can't detect memory limit from cgroups",
-              file=sys.stderr)
-        return None
-    return int(limit)
-
-
-def get_number_of_cores():
-    """
-    Read number of CPU cores.
-    """
-
-    core_count = 0
-
-    line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
-    if line is None:
-        print("Warning: Can't detect number of CPU cores from cgroups",
-              file=sys.stderr)
-        return None
-
-    for group in line.split(','):
-        core_ids = list(map(int, group.split('-')))
-        if len(core_ids) == 2:
-            core_count += core_ids[1] - core_ids[0] + 1
-        else:
-            core_count += 1
-
-    return core_count
-
-
-if __name__ == "__main__":
-    env_vars = {
-        "MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
-        "MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
-        "NUMBER_OF_CORES": get_number_of_cores()
-    }
-
-    env_vars = {k: v for k, v in env_vars.items() if v is not None}
-
-    if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
-        env_vars["NO_MEMORY_LIMIT"] = "true"
-
-    for key, value in env_vars.items():
-        print("{0}={1}".format(key, value))

From f743a2ea66d088b6d9ca2b3ba5592ef4ac8f8e42 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 29 Jan 2019 09:53:09 +0100
Subject: [PATCH 131/509] fix whitespace issues

---
 specs/multispec.yml | 2 +-
 src/Dockerfile      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index add682d2..80ef5d31 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -48,7 +48,7 @@ specs:
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
        environment_setup: >-4
-            yum -y module enable postgresql:{{ spec.version }} && \
+           yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
            yum -y reinstall tzdata && \
     fedora:
diff --git a/src/Dockerfile b/src/Dockerfile
index af630c4e..55b05c27 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -92,6 +92,7 @@ COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
 {% endif %}
 VOLUME ["/var/lib/pgsql/data"]
 

From c2b705aae2f62b1f1d3864fd66c7457507a98186 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 29 Jan 2019 12:06:19 +0100
Subject: [PATCH 132/509] update common

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 37fcee39..a7759b99 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 37fcee39105a99be0dd52db2f4768010a588c826
+Subproject commit a7759b99a4e5fd63b6d29c93131b62b02e2c35d4

From c7a348648da0dff0c80f5bc4e102c0d4f1507dae Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 1 Feb 2019 22:54:02 +0100
Subject: [PATCH 133/509] Rename run-openshift to run-openshift-local-cluster

---
 test/{run-openshift => run-openshift-local-cluster} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename test/{run-openshift => run-openshift-local-cluster} (100%)

diff --git a/test/run-openshift b/test/run-openshift-local-cluster
similarity index 100%
rename from test/run-openshift
rename to test/run-openshift-local-cluster

From 7efb6ea10248ba8f7142c11c055a791f3c1897e4 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 1 Feb 2019 23:01:35 +0100
Subject: [PATCH 134/509] Add integration tests

---
 Makefile                          |  1 +
 common                            |  2 +-
 test/run-openshift                |  1 +
 test/run-openshift-local-cluster  | 18 ++++++++++++++++++
 test/run-openshift-remote-cluster | 30 ++++++++++++++++++++++++++++++
 test/test-lib-postgresql.sh       | 31 +++++++++++++++++++++++++++++++
 6 files changed, 82 insertions(+), 1 deletion(-)
 create mode 120000 test/run-openshift
 create mode 100755 test/run-openshift-remote-cluster
 create mode 100644 test/test-lib-postgresql.sh

diff --git a/Makefile b/Makefile
index 364e1c71..a35e7fdb 100644
--- a/Makefile
+++ b/Makefile
@@ -20,3 +20,4 @@ upgrade-tests: $(VERSIONS)
 	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local
 
 build-serial: generate
+test-openshift-remote-cluster: generate
diff --git a/common b/common
index a7759b99..fcb9c14c 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a7759b99a4e5fd63b6d29c93131b62b02e2c35d4
+Subproject commit fcb9c14cc732b4c292aaba3cd8b82a023e7dd128
diff --git a/test/run-openshift b/test/run-openshift
new file mode 120000
index 00000000..d84575f7
--- /dev/null
+++ b/test/run-openshift
@@ -0,0 +1 @@
+run-openshift-local-cluster
\ No newline at end of file
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index ef01a05d..22b70c4f 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -11,6 +11,7 @@ TEMPLATES="$THISDIR/examples"
 REMOTE_TEMPLATES="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates"
 
 source "$THISDIR"/test-lib-openshift.sh
+source "$THISDIR"/test-lib-postgresql.sh
 
 set -exo nounset
 
@@ -392,3 +393,20 @@ test_postgresql_pure_image "$IMAGE_NAME"
 test_postgresql_replication "$IMAGE_NAME"
 run_ephemeral_tests "$IMAGE_NAME"
 run_persistent_tests "$IMAGE_NAME"
+
+# test with the just built image and an integrated template
+test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql
+
+# test with a released image and an integrated template
+if [ "${OS}" == "rhel7" ] ; then
+  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.access.redhat.com/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
+else
+  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
+fi
+
+export CT_SKIP_UPLOAD_IMAGE=true
+test_postgresql_integration postgresql "${VERSION}" "${PUBLIC_IMAGE_NAME}"
+
+OS_TESTSUITE_RESULT=0
+
+ct_os_cluster_down
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
new file mode 100755
index 00000000..447d4bf9
--- /dev/null
+++ b/test/run-openshift-remote-cluster
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Test the PostgreSQL image in OpenShift (remote cluster)
+#
+# IMAGE_NAME specifies a name of the candidate image used for testing.
+# The image has to be available before this script is executed.
+# VERSION specifies the major version of the PostgreSQL in format of X.Y
+# OS specifies RHEL version (e.g. OS=rhel7)
+#
+
+THISDIR=$(dirname ${BASH_SOURCE[0]})
+
+source ${THISDIR}/test-lib-postgresql.sh
+
+set -eo nounset
+
+trap ct_os_cleanup EXIT SIGINT
+
+ct_os_check_compulsory_vars
+
+oc status || false "It looks like oc is not properly logged in."
+
+export CT_SKIP_NEW_PROJECT=true
+export CT_SKIP_UPLOAD_IMAGE=true
+export CT_NAMESPACE=openshift
+
+test_postgresql_integration postgresql ${VERSION} "${IMAGE_NAME}"
+
+OS_TESTSUITE_RESULT=0
+
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
new file mode 100644
index 00000000..711a8657
--- /dev/null
+++ b/test/test-lib-postgresql.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Functions for tests for the PostgreSQL image in OpenShift.
+#
+# IMAGE_NAME specifies a name of the candidate image used for testing.
+# The image has to be available before this script is executed.
+#
+
+THISDIR=$(dirname ${BASH_SOURCE[0]})
+
+source ${THISDIR}/test-lib.sh
+source ${THISDIR}/test-lib-openshift.sh
+
+function test_postgresql_integration() {
+  local image_name=$1
+  local VERSION=$2
+  local import_image=$3
+  local service_name=${import_image##*/}
+  ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent
+  ct_os_test_template_app_func "${image_name}" \
+                               "${t}" \
+                               "${service_name}" \
+                               "ct_os_check_cmd_internal '${import_image}' '${service_name}' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
+                               "-p POSTGRESQL_VERSION=${VERSION} \
+                                -p DATABASE_SERVICE_NAME="${service_name}-testing" \
+                                -p POSTGRESQL_USER=testu \
+                                -p POSTGRESQL_PASSWORD=testp \
+                                -p POSTGRESQL_DATABASE=testdb" "" "${import_image}"
+}
+
+# vim: set tabstop=2:shiftwidth=2:expandtab:

From 02c2777d70c4bc7464bb35ca61f5f29af87f38ff Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 6 Mar 2019 15:33:38 +0100
Subject: [PATCH 135/509] Ensure we have enough time to do crash recovery

Fixes: #297
---
 src/root/usr/bin/run-postgresql | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/root/usr/bin/run-postgresql b/src/root/usr/bin/run-postgresql
index 8af06d39..2367e57e 100755
--- a/src/root/usr/bin/run-postgresql
+++ b/src/root/usr/bin/run-postgresql
@@ -27,7 +27,18 @@ else
   try_pgupgrade
 fi
 
-pg_ctl -w start -o "-h ''"
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
 if $PG_INITIALIZED ; then
     process_extending_files \
         "${APP_DATA}/src/postgresql-init" \

From 40af10e3fc8442c211cc5372226f7d26dc58abd7 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 20 Mar 2019 11:49:39 +0100
Subject: [PATCH 136/509] make livenessProbe to return always true

Since we have no real deadlocks to be detected in livenessProbe
for now, lets have it (effectively) disabled for now.

The liveness probe used to cause issues before, namely because it:
- killed initdb on a rather slow storage
- would pg_upgrade for rather large data directory
- killed pod when PostgreSQL was in crash recovery

Fixes: #313, #309
Relates: #316
---
 src/root/usr/libexec/check-container | 34 +++++++++-------------------
 1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/src/root/usr/libexec/check-container b/src/root/usr/libexec/check-container
index bee6acc8..04a5b625 100755
--- a/src/root/usr/libexec/check-container
+++ b/src/root/usr/libexec/check-container
@@ -9,31 +9,19 @@
 
 test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
 
-check=ready
-case $1 in
-    --live) check=live ;;
-esac
-
-while true; do
-    # Wait until the /bin/postgres is executed.
-    case $(readlink -f /proc/1/exe) in
-        *bash) sleep 0.2; continue ;;
-        *) break ;;
-    esac
-done
-
-# Timeout is infinite (openshift template has the timeout pre-set)
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
 pg_isready -q \
     -h 127.0.0.1 \
     ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
     ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
     --timeout 0
-rc=$?
-
-# we are ready only if the db accepts connections
-test $rc -eq 0 && exit 0
-
-# container is live also during pg cluster start-up
-test $rc -eq 1 && test $check = live && exit 0
-
-exit 1

From 88ba23b019d7723b9401522d77f8d582d7fa8960 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 6 Mar 2019 15:47:05 +0100
Subject: [PATCH 137/509] re-set 'set -e' after sourcing extension-hooks

Related: #297
---
 src/root/usr/share/container-scripts/postgresql/common.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 0d7b8dd4..44c1cb62 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -425,6 +425,7 @@ process_extending_files()
       if test -f "$file"; then
         echo "=> sourcing $file ..."
         source "$file"
+        set -e # ensure that users don't mistakenly change this
         break
       fi
     done

From 005fc8959f47b2dc5ab12b4c306ef04200e2b47d Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 5 Apr 2019 06:15:46 +0200
Subject: [PATCH 138/509] common: update to get date+short_commit image tag

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index fcb9c14c..0fd64b85 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit fcb9c14cc732b4c292aaba3cd8b82a023e7dd128
+Subproject commit 0fd64b85d1885ccca57846ab60adfda5b1897d70

From 1457eeb14a991a0eaa454d0c727a970912e79336 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 27 Mar 2019 09:53:52 +0100
Subject: [PATCH 139/509] set assemble user label for openshift

Since latest openshift defaults to running the assemble script under
the default s2i user (1001) when this label is not provided by the image
---
 src/Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Dockerfile b/src/Dockerfile
index 55b05c27..a4239646 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -29,6 +29,7 @@ LABEL summary="$SUMMARY" \
       io.k8s.display-name="PostgreSQL {{ spec.version }}" \
       io.openshift.expose-services="5432:postgresql" \
       io.openshift.tags="{{ spec.openshift_tags }}" \
+      io.openshift.s2i.assemble-user="26" \
       name="{{ spec.img_name }}" \
       com.redhat.component="{{ spec.redhat_component }}" \
 {% if spec.version not in ["9.4", "9.5", "9.6"] %}

From cabe6cb4a269d3bd35b16319a507040f576f0f82 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 27 Mar 2019 11:52:57 +0100
Subject: [PATCH 140/509] change the README.md to use examples with oc/podman

---
 README.md                                     |  6 +-
 .../container-scripts/postgresql/README.md    | 56 ++++++++++++-------
 2 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/README.md b/README.md
index 40990933..0ff10c3d 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ Choose either the CentOS7 or RHEL7 based image:
     These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-10-rhel7).
     To download it run:
     ```
-    docker pull registry.access.redhat.com/rhscl/postgresql-10-rhel7
+    podman pull registry.access.redhat.com/rhscl/postgresql-10-rhel7
     ```
 
     To build a RHEL7 based image, you need to run Docker build on a properly
@@ -53,7 +53,7 @@ Choose either the CentOS7 or RHEL7 based image:
     These images are available on DockerHub. To download it run:
 
     ```
-    $ docker pull centos/postgresql-10-centos7
+    $ podman pull centos/postgresql-10-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -64,6 +64,8 @@ Choose either the CentOS7 or RHEL7 based image:
     $ make build TARGET=centos7 VERSIONS=10
     ```
 
+Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments.
+
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
 on all provided versions of PostgreSQL.**
 
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index ff9cd849..dc5485a2 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -2,11 +2,13 @@ PostgreSQL {{ spec.version }} SQL Database Server container image
 ===============================================
 
 This container image includes PostgreSQL {{ spec.version }} SQL database server for OpenShift and general usage.
-Users can choose between RHEL and CentOS based images.
-The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/{{ spec.rhel_image_name }})
-as registry.access.redhat.com/{{ spec.rhel_image_name }}.
-The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/{{ spec.centos_image_name }}/)
-as {{ spec.centos_image_name }}.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Docker Hub](https://hub.docker.com/r/centos/),
+and the Fedora images are available in [Fedora Registry](https://registry.fedoraproject.org/).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
 
 
 Description
@@ -22,12 +24,12 @@ You can find more information on the PostgreSQL project from the project Web sit
 Usage
 -----
 
-For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image.
+For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image, available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
 If you want to set only the mandatory environment variables and not store the database
 in a host directory, execute the following command:
 
 ```
-$ docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.rhel_image_name }}
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.rhel_image_name }}
 ```
 
 This will create a container named `postgresql_database` running PostgreSQL with
@@ -36,12 +38,18 @@ and mapped to the host. If you want your database to be persistent across contai
 executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
 below). This will be the PostgreSQL database cluster directory.
 
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION={{ spec.version }} -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
 If the database cluster directory is not initialized, the entrypoint script will
 first run [`initdb`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-initdb.html)
 and setup necessary database users and passwords. After the database is initialized,
 or if it was already present, [`postgres`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-postgres.html)
 is executed and will run as PID 1. You can stop the detached container by running
-`docker stop postgresql_database`.
+`podman stop postgresql_database`.
 
 
 
@@ -101,13 +109,13 @@ You can also set the following mount points by passing the `-v /host/dir:/contai
 directory has the appropriate permissions and that the owner and group of the directory
 matches the user UID or name which is running inside the container.**
 
-Typically (unless you use `docker run -u` option) processes in container
+Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
 ```
 $ setfacl -m u:26:-wx /your/data/dir
-$ docker run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
 
@@ -118,7 +126,7 @@ PostgreSQL container supports migration of data from remote PostgreSQL server.
 You can run it like:
 
 ```
-$ docker run -d --name postgresql_database \
+$ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
@@ -238,18 +246,25 @@ lead to data loss.
 Extending image
 ----------------
 
-This image can be extended using
-[source-to-image](https://github.com/openshift/source-to-image).
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image,
+available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
 
 For example to build customized image `new-postgresql`
-with configuration in `~/image-configuration/` run:
+with configuration in `image-configuration/` run:
+
+```
+$ oc new-app postgresql:9.6~./image-configuration/ --name new-postgresql
+```
 
+or via `s2i`:
 
 ```
-$ s2i build ~/image-configuration/ postgresql new-postgresql
+$ s2i build ./image-configuration/ {{ spec.rhel_image_name }} new-postgresql
 ```
 
-The directory passed to `s2i build` should contain one or more of the
+The directory passed to Openshift should contain one or more of the
 following directories:
 
 
@@ -282,7 +297,7 @@ always sourced (after `postgresql-init/` scripts, if they exist).
 
 ----------------------------------------------
 
-During `s2i build` all provided files are copied into `/opt/app-root/src`
+During the s2i build all provided files are copied into `/opt/app-root/src`
 directory in the new image. Only one
 file with the same name can be used for customization and user provided files
 are preferred over default files in `/usr/share/container-scripts/`-
@@ -293,7 +308,7 @@ Troubleshooting
 ---------------
 At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
 
-    docker logs <container>
+    podman logs <container>
 
 Then log output is redirected to logging collector process and will appear in directory "pg_log".
 
@@ -302,5 +317,6 @@ See also
 --------
 Dockerfile and other sources for this container image are available on
 https://github.com/sclorg/postgresql-container.
-In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
-for RHEL is called Dockerfile.rhel7.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+and the Dockerfile for Fedora is called Dockerfile.fedora.

From c5b350a24af4181f3dd3b63e46ed6d65c6b54ae7 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 8 Apr 2019 10:04:45 +0200
Subject: [PATCH 141/509] README: add a better oc example

---
 .../usr/share/container-scripts/postgresql/README.md  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index dc5485a2..a5e9e65d 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -252,16 +252,21 @@ For this, we will assume that you are using the `{{ spec.rhel_image_name }}` ima
 available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
 
 For example to build customized image `new-postgresql`
-with configuration in `image-configuration/` run:
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
 
 ```
-$ oc new-app postgresql:9.6~./image-configuration/ --name new-postgresql
+$ oc new-app postgresql:{{ spec.version }}~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
 ```
 
 or via `s2i`:
 
 ```
-$ s2i build ./image-configuration/ {{ spec.rhel_image_name }} new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git {{ spec.rhel_image_name }} new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the

From e2af3e8e527af640c1524489d925b9bb300c4df5 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 4 Mar 2019 16:29:26 +0100
Subject: [PATCH 142/509] Tighten (and document) the permission setup by
 fix-permissions

There's no need to have write-able $APP_DATA, so tighten this.
Also, I keep re-observing the reasons why we add 'postgres' user
into 'root' group all the time -- so let's have this documented as
well.
---
 src/Dockerfile                       | 20 +++++++++----
 src/Dockerfile.fedora                | 20 +++++++++----
 src/root/usr/libexec/fix-permissions | 44 ++++++++++++++++++++++++----
 src/s2i/bin/assemble                 |  2 +-
 4 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index a4239646..798688e6 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -76,8 +76,7 @@ RUN {{ spec.environment_setup }}
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
@@ -97,10 +96,19 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
 {% endif %}
 VOLUME ["/var/lib/pgsql/data"]
 
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
 
 USER 26
 
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 1d7dd8dc..aaae692b 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -51,8 +51,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql && \
-    /usr/libexec/fix-permissions /var/run/postgresql
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
@@ -62,10 +61,19 @@ COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
 VOLUME ["/var/lib/pgsql/data"]
 
-# {APP_DATA} needs to be accessed by postgres user while s2i assembling
-# postgres user changes permissions of files in APP_DATA during assembling
-RUN /usr/libexec/fix-permissions ${APP_DATA} && \
-    usermod -a -G root postgres
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
 
 USER 26
 
diff --git a/src/root/usr/libexec/fix-permissions b/src/root/usr/libexec/fix-permissions
index ebcdd3d4..f4b2f86d 100755
--- a/src/root/usr/libexec/fix-permissions
+++ b/src/root/usr/libexec/fix-permissions
@@ -1,7 +1,39 @@
 #!/bin/sh
-# Fix permissions on the given directory to allow group read/write of 
-# regular files and execute of directories.
-find "$1" -exec chown postgres {} \;
-find "$1" -exec chgrp 0 {} \;
-find "$1" -exec chmod g+rw {} \;
-find "$1" -type d -exec chmod g+x {} +
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/src/s2i/bin/assemble b/src/s2i/bin/assemble
index c1472bdc..6ed8f7aa 100755
--- a/src/s2i/bin/assemble
+++ b/src/s2i/bin/assemble
@@ -11,4 +11,4 @@ echo "---> Installing application source ..."
 mv /tmp/src/* ./
 
 # Fix source directory permissions
-/usr/libexec/fix-permissions ./
+/usr/libexec/fix-permissions --read-only ./

From abe16a00fa39c7da4d4f268cb94dd6e8dd6e3604 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 10 Jun 2019 09:50:50 +0200
Subject: [PATCH 143/509] rhel8: sync with downstream changes

move the image to ubi8 s2i-core
use podman instead of docker in usage
---
 specs/multispec.yml | 2 +-
 src/Dockerfile      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 80ef5d31..86c4aed1 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -40,7 +40,7 @@ specs:
     rhel8:
        distros:
          - rhel-8-x86_64
-       s2i_base: rhel8/s2i-core
+       s2i_base: ubi8/s2i-core
        org: "rhel8"
        prod: "rhel8"
        openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
diff --git a/src/Dockerfile b/src/Dockerfile
index 798688e6..2a6731f5 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -39,7 +39,7 @@ LABEL summary="$SUMMARY" \
 {% else %}
       version="{{ spec.version }}" \
 {% endif %}
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.img_name }}" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.img_name }}" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"
 
 EXPOSE 5432

From fcc4ddc6e2454710cbc95dddef5be900876d0838 Mon Sep 17 00:00:00 2001
From: danielhelfand <helfand.4@gmail.com>
Date: Tue, 11 Jun 2019 08:25:53 -0400
Subject: [PATCH 144/509] removing version typo from imagestream descriptions

---
 imagestreams/postgresql-centos7.json       | 2 +-
 imagestreams/postgresql-rhel7-ppc64le.json | 2 +-
 imagestreams/postgresql-rhel7.json         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index a82b0a8e..6b9bcdec 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel7-ppc64le.json
index 021ed019..133b962c 100644
--- a/imagestreams/postgresql-rhel7-ppc64le.json
+++ b/imagestreams/postgresql-rhel7-ppc64le.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,ppc64le"
         },
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 15e26822..1a13e6f7 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -14,7 +14,7 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major versions updates.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },

From 7bb9501b7c09687f27caeb7359f6208a5b37552f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 17 Jun 2019 10:34:04 +0200
Subject: [PATCH 145/509] deprecate version 9.5

---
 Makefile                             | 2 +-
 README.md                            | 4 ----
 imagestreams/postgresql-centos7.json | 2 +-
 imagestreams/postgresql-rhel7.json   | 2 +-
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index a35e7fdb..48ca7948 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.5 9.6 10
+VERSIONS = 9.6 10
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index 0ff10c3d..7df4f85f 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,6 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently supported are:
-* [postgresql-9.5](https://github.com/sclorg/postgresql-container/tree/generated/9.5)
 * [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 
@@ -77,9 +76,6 @@ In this repository [distgen](https://github.com/devexp-db/distgen/) is used for
 Usage
 ---------------------------------
 
-For information about usage of Dockerfile for PostgreSQL 9.5,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.5).
-
 For information about usage of Dockerfile for PostgreSQL 9.6,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
 
diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index 6b9bcdec..afe7d801 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -69,7 +69,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "hidden,database,postgresql",
           "version": "9.5"
         },
         "from": {
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 1a13e6f7..e3920ef6 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -69,7 +69,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "hidden,database,postgresql",
           "version": "9.5"
         },
         "from": {

From e42c1d705b228905579c442de11638734a832772 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 12 Jun 2019 13:50:17 +0200
Subject: [PATCH 146/509] rhel8: enable migration test for version 10

---
 src/Dockerfile      |  6 ++++--
 test/pg-test-lib.sh |  4 ++++
 test/run_test       | 14 ++++++++++----
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index 2a6731f5..6fcc0b21 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -11,7 +11,7 @@ FROM {{ spec.s2i_base }}
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION={{ spec.version }} \
-    {% if spec.version not in ["9.6", "10"] or spec.prod != "rhel8" %}
+    {% if spec.prod != "rhel8" or spec.version == "10" %}
     POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
     {% endif %}
     HOME=/var/lib/pgsql \
@@ -94,7 +94,9 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
     PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
 
 {% endif %}
-VOLUME ["/var/lib/pgsql/data"]
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
 # --------------------
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index dc8d2b2c..2347438f 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -35,6 +35,10 @@ get_image_id ()
                 fi
                 local image=docker.io/$ns/postgresql-${1//\./}-centos7
                 ;;
+            rhel8)
+                ns=rhel8
+                local image=registry.redhat.io/$ns/postgresql-${version}
+                ;;
             esac
             docker pull "$image" >/dev/null
             echo "$image"
diff --git a/test/run_test b/test/run_test
index c849bb9b..fa6c217e 100755
--- a/test/run_test
+++ b/test/run_test
@@ -16,8 +16,6 @@ shopt -s nullglob
 . test/pg-test-lib.sh
 
 TEST_LIST="\
-run_upgrade_test
-run_migration_test
 run_container_creation_tests
 run_general_tests
 run_change_password_test
@@ -27,6 +25,8 @@ run_doc_test
 run_s2i_test
 run_test_cfg_hook
 run_s2i_bake_data_test
+run_upgrade_test
+run_migration_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -635,7 +635,9 @@ $volume_options
 
 run_upgrade_test ()
 {
-    [ "${OS}" == "fedora" ] && return 0
+    # Do not run on Fedora or RHEL8 until the upgrade script
+    # is fixed for non-SCL use cases
+    [ "${OS}" == "fedora" or "${OS}" == "rhel8" ] && return 0
 
     local upgrade_path="none 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do
@@ -655,7 +657,11 @@ run_migration_test ()
     [ "${OS}" == "fedora" ] && return 0
 
     local from_version
-    local upgrade_path="9.4 9.5 9.6 10"
+    if [ "${OS}" == "rhel8" ]; then
+        local upgrade_path="9.6 10"
+    else
+        local upgrade_path="9.4 9.5 9.6 10"
+    fi
 
     for from_version in $upgrade_path; do
         # Do not test migration from $VERSION:remote to $VERSION:local

From a6efdca58ba38b849fd3ce558d78b5f1a73a9ee6 Mon Sep 17 00:00:00 2001
From: gabemontero <gmontero@redhat.com>
Date: Mon, 8 Jul 2019 17:02:03 -0400
Subject: [PATCH 147/509] remove versions that are EOL

---
 imagestreams/postgresql-centos7.json | 54 ----------------------------
 imagestreams/postgresql-rhel7.json   | 54 ----------------------------
 2 files changed, 108 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index afe7d801..d12fe9be 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -26,60 +26,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "9.2",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.2",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.2 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,postgresql",
-          "version": "9.2"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/openshift/postgresql-92-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.4",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.4",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.4 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,database,postgresql",
-          "version": "9.4"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-94-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.5",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.5",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,database,postgresql",
-          "version": "9.5"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-95-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "9.6",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index e3920ef6..69dd7fb1 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -26,60 +26,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "9.2",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.2",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.2 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,postgresql",
-          "version": "9.2"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/openshift3/postgresql-92-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.4",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.4",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.4 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,database,postgresql",
-          "version": "9.4"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-94-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.5",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.5",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.5 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "hidden,database,postgresql",
-          "version": "9.5"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-95-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "9.6",
         "annotations": {

From b91db203846e597aff5a8256a2c50a919af501ec Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 18 Jul 2019 08:56:22 +0200
Subject: [PATCH 148/509] Clean yum cache for every available repository

---
 src/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index 6fcc0b21..92715880 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -72,7 +72,7 @@ RUN {{ spec.environment_setup }}
     {% if spec.post_install %}
     {{ spec.post_install }}
     {% endif %}
-    yum clean all && \
+    yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \

From 8f5fe94935b945c30e6b1f4ad9cdf9ebd35f790f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 3 Sep 2019 09:36:35 +0200
Subject: [PATCH 149/509] add license terms for rhel based images

---
 src/Dockerfile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/Dockerfile b/src/Dockerfile
index 92715880..1100d4ee 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -38,6 +38,9 @@ LABEL summary="$SUMMARY" \
       version="1" \
 {% else %}
       version="{{ spec.version }}" \
+{% endif %}
+{% if config.os.id == 'rhel' %}
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
 {% endif %}
       usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.img_name }}" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>"

From 81b8a3a60bb70e1496d79f25e69f17a6575b5fe9 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 30 Aug 2019 09:08:52 +0200
Subject: [PATCH 150/509] tests: change lower-or-equal to eq in get_image_id

We only need to work with postgresql92 image now
(to test upgrade from RHEL7) and not with older images.
This fixes get_image_id for versions 10+ as they would get
the "openshift3" namespaced image names generated.
---
 test/pg-test-lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 2347438f..e8f9ef45 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -23,14 +23,14 @@ get_image_id ()
             case $OS in
             rhel7)
                 ns=rhscl
-                if test "$version" -le 92; then
+                if test "$version" -eq 92; then
                     ns=openshift3
                 fi
                 image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7
                 ;;
             centos7)
                 ns=centos
-                if test "$version" -le 92; then
+                if test "$version" -eq 92; then
                     ns=openshift
                 fi
                 local image=docker.io/$ns/postgresql-${1//\./}-centos7

From 1aa205ce17ff39fd6878492fd4d3fdd27ef14f99 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 16 Sep 2019 13:36:44 +0200
Subject: [PATCH 151/509] add example for enabling ssl connections

---
 common                                        |  2 +-
 examples/enable-ssl/postgresql-cfg/ssl.conf   |  5 ++
 .../postgresql-pre-start/enable_ssl.sh        |  4 +
 examples/enable-ssl/server.crt                | 77 +++++++++++++++++++
 examples/enable-ssl/server.key                | 28 +++++++
 5 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100644 examples/enable-ssl/postgresql-cfg/ssl.conf
 create mode 100644 examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
 create mode 100644 examples/enable-ssl/server.crt
 create mode 100644 examples/enable-ssl/server.key

diff --git a/common b/common
index 0fd64b85..b2886e2f 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0fd64b85d1885ccca57846ab60adfda5b1897d70
+Subproject commit b2886e2ffee3810fad7aae495b72571e3a3be7b2
diff --git a/examples/enable-ssl/postgresql-cfg/ssl.conf b/examples/enable-ssl/postgresql-cfg/ssl.conf
new file mode 100644
index 00000000..7237ac05
--- /dev/null
+++ b/examples/enable-ssl/postgresql-cfg/ssl.conf
@@ -0,0 +1,5 @@
+ssl = on
+ssl_cert_file = '/opt/app-root/src/server.crt' # server certificate
+ssl_key_file =  '/opt/app-root/src/server.key' # server private key
+#ssl_ca_file                                   # trusted certificate authorities
+#ssl_crl_file                                  # certificates revoked by certificate authorities
diff --git a/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh b/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
new file mode 100644
index 00000000..68369121
--- /dev/null
+++ b/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Postgresql server will reject key files with liberal permissions
+chmod og-rwx server.key
diff --git a/examples/enable-ssl/server.crt b/examples/enable-ssl/server.crt
new file mode 100644
index 00000000..aabcc98d
--- /dev/null
+++ b/examples/enable-ssl/server.crt
@@ -0,0 +1,77 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            2c:86:f9:22:0f:0c:ed:2b:e8:a3:f1:cf:9e:2b:09:82:22:76:ec:2b
+        Signature Algorithm: sha256WithRSAEncryption
+        Issuer: CN = testing
+        Validity
+            Not Before: Sep 16 11:39:01 2019 GMT
+            Not After : Sep 13 11:39:01 2029 GMT
+        Subject: CN = testing
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                RSA Public-Key: (2048 bit)
+                Modulus:
+                    00:d9:0f:25:ca:d9:32:4d:db:95:f5:5f:09:5a:2b:
+                    e2:f7:ae:6a:b3:43:ce:1c:35:60:bd:cc:01:3f:f2:
+                    0f:eb:20:da:55:8b:42:95:da:a5:0a:c8:c5:43:54:
+                    64:85:e7:5b:2c:77:6a:1f:db:9f:56:39:35:e4:0f:
+                    b0:1c:2b:a6:73:46:e8:27:2b:9f:62:5c:bf:7f:48:
+                    5a:99:e1:8d:73:fe:d6:3a:ec:25:35:07:ad:69:f3:
+                    95:81:ea:8a:20:50:fd:fc:e9:c0:b5:ac:f7:21:af:
+                    37:2c:8e:23:51:74:fa:75:b2:48:c4:6e:95:f1:2d:
+                    bc:af:ff:f4:eb:da:a3:78:fe:e9:c9:c0:ef:21:b5:
+                    46:f5:e9:8c:9a:f9:94:84:a7:63:be:d6:fe:eb:31:
+                    fb:ca:87:2e:e6:43:53:bd:3c:09:7f:cc:7b:9d:e2:
+                    b9:0a:49:a5:5c:61:6e:94:f9:75:85:e3:41:e7:92:
+                    24:84:9f:61:c7:d4:cc:b5:26:8a:c1:db:bf:a5:ce:
+                    43:72:61:04:2f:bf:21:c4:d1:73:dd:b4:f8:37:bf:
+                    85:0d:0e:92:8d:22:33:4b:ed:6d:55:2d:0b:42:c4:
+                    23:e8:30:f3:86:2b:99:ba:e5:ba:ef:54:b4:40:29:
+                    2d:53:7c:d4:59:72:20:65:88:9d:68:5a:fc:25:a8:
+                    13:0d
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Subject Key Identifier: 
+                17:77:65:09:AD:ED:EE:02:01:AB:09:FE:1E:FD:AB:4E:F2:4D:0A:23
+            X509v3 Authority Key Identifier: 
+                keyid:17:77:65:09:AD:ED:EE:02:01:AB:09:FE:1E:FD:AB:4E:F2:4D:0A:23
+
+            X509v3 Basic Constraints: critical
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         14:67:98:15:fa:57:88:75:89:9a:0b:f0:e1:94:dd:dc:12:ab:
+         a0:2a:20:6d:38:64:39:39:58:4f:4d:2d:16:1d:e2:e2:d3:56:
+         35:2e:3c:f5:be:7e:16:fb:87:a1:b9:27:e6:d4:52:e8:1e:c5:
+         c7:b7:74:b5:15:53:6d:b0:90:34:8c:ce:20:82:62:60:1e:f2:
+         21:f9:22:a5:cb:17:a7:a9:55:71:cb:66:f5:dd:c2:85:6a:e1:
+         a7:35:d0:b9:09:6a:ae:4d:a5:32:34:fa:2a:cc:10:85:6c:95:
+         50:50:2c:e9:59:d1:40:78:16:d3:87:c3:31:cb:33:7b:0f:3a:
+         ef:51:c1:2e:0c:eb:38:61:de:01:42:0e:1d:cc:7d:b1:24:4b:
+         ef:ce:9d:c6:b0:97:51:c9:cc:23:d6:5d:4e:cf:68:06:c2:47:
+         94:c5:80:df:07:bc:72:cc:79:3d:94:be:6d:c8:b3:17:e6:5e:
+         52:38:c4:6b:a9:ee:ad:94:f9:74:bf:8a:95:12:06:b4:4d:17:
+         ca:72:a5:61:90:b7:c0:0f:d0:04:e1:39:3c:75:d5:8a:5c:11:
+         96:f7:fe:82:5a:e6:30:2c:2f:94:4e:bb:1e:8e:d8:0b:6e:1e:
+         e4:5f:f6:c9:a3:4d:2f:58:ee:ad:b7:cd:53:3f:f1:dc:1e:d2:
+         06:a0:03:58
+-----BEGIN CERTIFICATE-----
+MIIDBTCCAe2gAwIBAgIULIb5Ig8M7Svoo/HPnisJgiJ27CswDQYJKoZIhvcNAQEL
+BQAwEjEQMA4GA1UEAwwHdGVzdGluZzAeFw0xOTA5MTYxMTM5MDFaFw0yOTA5MTMx
+MTM5MDFaMBIxEDAOBgNVBAMMB3Rlc3RpbmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB
+DwAwggEKAoIBAQDZDyXK2TJN25X1XwlaK+L3rmqzQ84cNWC9zAE/8g/rINpVi0KV
+2qUKyMVDVGSF51ssd2of259WOTXkD7AcK6ZzRugnK59iXL9/SFqZ4Y1z/tY67CU1
+B61p85WB6oogUP386cC1rPchrzcsjiNRdPp1skjEbpXxLbyv//Tr2qN4/unJwO8h
+tUb16Yya+ZSEp2O+1v7rMfvKhy7mQ1O9PAl/zHud4rkKSaVcYW6U+XWF40HnkiSE
+n2HH1My1JorB27+lzkNyYQQvvyHE0XPdtPg3v4UNDpKNIjNL7W1VLQtCxCPoMPOG
+K5m65brvVLRAKS1TfNRZciBliJ1oWvwlqBMNAgMBAAGjUzBRMB0GA1UdDgQWBBQX
+d2UJre3uAgGrCf4e/atO8k0KIzAfBgNVHSMEGDAWgBQXd2UJre3uAgGrCf4e/atO
+8k0KIzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAUZ5gV+leI
+dYmaC/DhlN3cEqugKiBtOGQ5OVhPTS0WHeLi01Y1Ljz1vn4W+4ehuSfm1FLoHsXH
+t3S1FVNtsJA0jM4ggmJgHvIh+SKlyxenqVVxy2b13cKFauGnNdC5CWquTaUyNPoq
+zBCFbJVQUCzpWdFAeBbTh8MxyzN7DzrvUcEuDOs4Yd4BQg4dzH2xJEvvzp3GsJdR
+ycwj1l1Oz2gGwkeUxYDfB7xyzHk9lL5tyLMX5l5SOMRrqe6tlPl0v4qVEga0TRfK
+cqVhkLfAD9AE4Tk8ddWKXBGW9/6CWuYwLC+UTrsejtgLbh7kX/bJo00vWO6tt81T
+P/HcHtIGoANY
+-----END CERTIFICATE-----
diff --git a/examples/enable-ssl/server.key b/examples/enable-ssl/server.key
new file mode 100644
index 00000000..5a93b484
--- /dev/null
+++ b/examples/enable-ssl/server.key
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDZDyXK2TJN25X1
+XwlaK+L3rmqzQ84cNWC9zAE/8g/rINpVi0KV2qUKyMVDVGSF51ssd2of259WOTXk
+D7AcK6ZzRugnK59iXL9/SFqZ4Y1z/tY67CU1B61p85WB6oogUP386cC1rPchrzcs
+jiNRdPp1skjEbpXxLbyv//Tr2qN4/unJwO8htUb16Yya+ZSEp2O+1v7rMfvKhy7m
+Q1O9PAl/zHud4rkKSaVcYW6U+XWF40HnkiSEn2HH1My1JorB27+lzkNyYQQvvyHE
+0XPdtPg3v4UNDpKNIjNL7W1VLQtCxCPoMPOGK5m65brvVLRAKS1TfNRZciBliJ1o
+WvwlqBMNAgMBAAECggEAKvM8Xy8rLQzOV4c+qoEUoD37Dw3TsvE8+1FqzeRwEe6m
+RVcRDeX90mx33CLO4VAuUlYuwa8LkFwxtbcE+g4JGbZmKZoQJ76ChgUjKF/hRZqf
+eXlQw3WJcvWoF9T5D/v2xhza7RgUrq2lFUPq6Stkg/WLQJNBSD/snkbfh+vzfPVW
+slg2zo1o9dMe53AOzjMkQ8RljbOfd+KZE340ZzftPxcTyrE9VaQqGLNtRiehhXPJ
+dB7Kmc+/Pm1OkmpblnSAIJudsMNelUYsadYFgjtEgYYXFcuqNrCWeNRmMl5I/vEp
+xnVf+gQfldJ+zAbkB4+nxMCOn1tqS2nOJRGW6xu4YQKBgQDt97CAAceXnRYoraqy
+1ff5K8WxxCmcD0TcX/EfYXj1Qaex979x2SpftsrBTclkOxoTPv+OfrKZ1/Eq4a8z
+0onP/lRGRxQ95gPvwFzQldKzmQVsoW6odZqMPO6hYJ0SsiZTwzc82IEXPA1QJJ6E
+n3OggTLs0iCW3uLyXFL8npaL4wKBgQDpgdvSU82ipiEntMpqUuQdhw1TvnYwcSaC
+GTUl4Uhwfdxmb424cqHiDoBKitd6DjHo20MshA/6WhWYq/dMz7ueEBu9cCKe85En
+RzX0InCV26K1zBBbwMXGJGquIaQeha1GmOkpgORHjNwdwKZkZ/DJOHYOsjwGyQ22
+H8cC6MX4TwKBgQCpqQ+ApEQuN0QmKnNqX50VXHztmeLkrgo1aH3cFr2LdozeGLm4
+rNFGPmfeW9w7Btw3XpILgQ9LGieKoC8urmutDDH/jQvEeerSk35ZBIidnXq9kXb4
+yigu1f54tg4m1zb2P1dxnRakfx8qxYDzI0/n3lV1fPbZOf3qN6K/Ez5YawKBgHQi
+rQTvvz+c5rKL3XyCG4iACeXTvY6cSC2+gcuEP3YLcxnTc6YABXmcAryQT1kaREJv
+AvrZ9+Ro94LGTKn8S3DyzAktA1sRAumJJlF064/s/AD1LFGmD/dbV1+hxbGUhLiv
+BpAo1eCsMzHtBhS8CWra1QS8KtSpHFOvfFh7EzNLAoGBANyGrLj6qzywdSV7ccnd
+sWg5U7Jgzuonb3K8LAc9NTnGn9C093RGY5HhsS1kTew01QRfxR7IdtSI9Q0vO/6I
+stLGSa9fpn4leu2P6iF8r640xx02UFhKyf8wpM2RF38hHjAWRW/BaUEfnECeDi5A
+yWuW6DFMAuJ80LdwyMPGkkt2
+-----END PRIVATE KEY-----

From c5c15919327597aa71d923497cd0454ef66791a7 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Sep 2019 11:20:47 +0200
Subject: [PATCH 152/509] add test case for enabling ssl using s2i

---
 test/run_test | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/run_test b/test/run_test
index fa6c217e..3dfec736 100755
--- a/test/run_test
+++ b/test/run_test
@@ -25,6 +25,7 @@ run_doc_test
 run_s2i_test
 run_test_cfg_hook
 run_s2i_bake_data_test
+run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 "
@@ -784,6 +785,28 @@ run_test_cfg_hook()
   assert_runtime_option "$name-3" shared_buffers 111MB
 }
 
+run_s2i_ssl_enable_test()
+{
+  local s2i_image_name="$IMAGE_NAME-ssl_$(ct_random_string)"
+  ct_s2i_build_as_df "file://$test_dir/examples/enable-ssl" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
+  images_to_clean+=( "$s2i_image_name" )
+
+  local container_name=enable-ssl-test
+
+  DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
+    IMAGE_NAME="$s2i_image_name" create_container "$container_name"
+
+  wait_ready "$container_name"
+  CONTAINER_IP=$(get_container_ip $container_name)
+
+  DB=postgres assert_login_access postgres password true
+
+  docker run --rm -e PGPASSWORD="password" "$IMAGE_NAME" psql "postgresql://postgres@$CONTAINER_IP:5432/postgres?sslmode=require" || \
+    false "FAIL: Did not manage to connect using SSL only."
+
+  docker stop "$(get_cid "$container_name")"
+}
+
 run_s2i_bake_data_test ()
 {
   local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"

From 5dd95d97616de82b987a92fa2cf90a797e9f76ec Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 4 Oct 2019 09:52:58 +0200
Subject: [PATCH 153/509] Revert "Do not test upgrades from 9.2 image
 (temporarily?)"

This reverts commit 6a79ef48541d6652bc1f9ef0f30e95fafbfd2987.
Resolves: #304
---
 test/run_test | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index 3dfec736..edceae19 100755
--- a/test/run_test
+++ b/test/run_test
@@ -640,7 +640,7 @@ run_upgrade_test ()
     # is fixed for non-SCL use cases
     [ "${OS}" == "fedora" or "${OS}" == "rhel8" ] && return 0
 
-    local upgrade_path="none 9.4 9.5 9.6 10 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -661,7 +661,7 @@ run_migration_test ()
     if [ "${OS}" == "rhel8" ]; then
         local upgrade_path="9.6 10"
     else
-        local upgrade_path="9.4 9.5 9.6 10"
+        local upgrade_path="9.2 9.4 9.5 9.6 10"
     fi
 
     for from_version in $upgrade_path; do

From 10ed490d49f7ca5337df55dfaae8371eb4a90b8b Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 4 Oct 2019 14:26:09 +0200
Subject: [PATCH 154/509] replace TEST_CASE by TESTS in README

Resolves: #178
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7df4f85f..9b30a352 100644
--- a/README.md
+++ b/README.md
@@ -111,10 +111,10 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
     $ cd postgresql
     $ make test TARGET=centos7 VERSIONS=10
     ```
-+By using the `TEST_CASE` parameter you can choose a test case subset to be run against the image, eg:
++By using the `TESTS` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSIONS=10 TEST_CASE="run_general_tests run_replication_test"
+    $ make test VERSIONS=10 TESTS="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed

From be29b9bb766ed20dc8548145831e1c33aff9e694 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 4 Oct 2019 14:02:43 +0200
Subject: [PATCH 155/509] tests: fix function name for enable ssl test case

---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index edceae19..f5b167dc 100755
--- a/test/run_test
+++ b/test/run_test
@@ -785,7 +785,7 @@ run_test_cfg_hook()
   assert_runtime_option "$name-3" shared_buffers 111MB
 }
 
-run_s2i_ssl_enable_test()
+run_s2i_enable_ssl_test()
 {
   local s2i_image_name="$IMAGE_NAME-ssl_$(ct_random_string)"
   ct_s2i_build_as_df "file://$test_dir/examples/enable-ssl" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null

From a77fe07d3eb4ea29e2acb0aa4cb8f2e7f71dc4a1 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 4 Oct 2019 15:07:39 +0200
Subject: [PATCH 156/509] rebase against latest container-common-scripts

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index b2886e2f..aaab8970 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit b2886e2ffee3810fad7aae495b72571e3a3be7b2
+Subproject commit aaab8970c072927fccfa0f9c9af278b6b55714b8

From 1cbbb075fc005e01dad2e4a5abb6d85213b90600 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 10 Oct 2019 07:50:47 +0200
Subject: [PATCH 157/509] tests: fix check for rhel8/fedora

---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index f5b167dc..d58276bc 100755
--- a/test/run_test
+++ b/test/run_test
@@ -638,7 +638,7 @@ run_upgrade_test ()
 {
     # Do not run on Fedora or RHEL8 until the upgrade script
     # is fixed for non-SCL use cases
-    [ "${OS}" == "fedora" or "${OS}" == "rhel8" ] && return 0
+    { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
 
     local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
     for act in $upgrade_path; do

From 076d50ec848f5ef61be05f3da227e0ed9eed383e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 23 Oct 2019 14:06:22 +0200
Subject: [PATCH 158/509] check if the image is available first in
 upgrade/migration tests

only check a subset of the migration path on non-intel architectures
as postgresql images older than v10 only support x86_64

Resolves: #300
---
 test/run_test | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/test/run_test b/test/run_test
index d58276bc..7411c186 100755
--- a/test/run_test
+++ b/test/run_test
@@ -648,6 +648,8 @@ run_upgrade_test ()
         prev=$act
     done
     test "$prev" != none
+    # Check if the previous image is available in the registry
+    docker pull "$(get_image_id "$prev:remote")" || return 0
 
     # TODO: We run this script from $VERSION directory, through test/run symlink.
     test/run_upgrade_test "$prev:remote" "$VERSION:local"
@@ -658,16 +660,19 @@ run_migration_test ()
     [ "${OS}" == "fedora" ] && return 0
 
     local from_version
-    if [ "${OS}" == "rhel8" ]; then
-        local upgrade_path="9.6 10"
-    else
+    # Only test a subset of the migration path on non-intel hosts
+    if [ "$(uname -i)" == "x86_64" ]; then
         local upgrade_path="9.2 9.4 9.5 9.6 10"
+    else
+        local upgrade_path="10"
     fi
 
     for from_version in $upgrade_path; do
         # Do not test migration from $VERSION:remote to $VERSION:local
         test $(version2number $from_version) -lt $(version2number "$VERSION") \
             || break
+        # Skip if the previous image is not available in the registry
+        docker pull "$(get_image_id "$from_version:remote")" || continue
         test/run_migration_test $from_version:remote $VERSION:local
     done
 }

From a2a34179a7941f1bcb61655e6142539c38f40e0e Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 4 Nov 2019 09:39:22 +0100
Subject: [PATCH 159/509] remove centos candidate repos in postgresql10

---
 specs/multispec.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 86c4aed1..f32891fa 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -88,8 +88,6 @@ specs:
       centos_image_name: "centos/postgresql-10-centos7"
       cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
-      has_devel_repo:
-        centos: True
 
 matrix:
   exclude:

From 871b80caa6a3c386071b84eac3888008bc918636 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 19 Nov 2019 11:15:28 +0100
Subject: [PATCH 160/509] follow symlinks when looking for files

Resolves: #325
---
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 44c1cb62..d89f3423 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -408,7 +408,7 @@ get_matched_files ()
   shift
   for dir; do
     test -d "$dir" || continue
-    find "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
   done
 }
 

From 4f61804e905985cfd1e6677eff2b7a7c97c773d5 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 20 Nov 2019 08:55:25 +0100
Subject: [PATCH 161/509] add tests for postgresql-start via configMap

---
 test/run-openshift-local-cluster | 41 ++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index 22b70c4f..095053c6 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -369,6 +369,46 @@ function test_postgresql_ephemeral_redeploy() {
   ct_os_delete_project
 }
 
+function test_postgresql_configmap_start() {
+  local image_name=$1; shift
+  local template="$TEMPLATES/postgresql-ephemeral-template.json"
+  local image_name_no_namespace=${image_name##*/}
+  local service_name=$image_name_no_namespace
+  local user="testu" pass="testp" db="testdb"
+  local registry="" old_image="" pod_ip="" tmpdir=""
+  local test_string=""
+
+  ct_os_new_project
+  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+
+  ct_os_deploy_template_image "$template" \
+                              NAMESPACE="$(oc project -q)" \
+                              POSTGRESQL_VERSION="$VERSION" \
+                              DATABASE_SERVICE_NAME="$service_name" \
+                              POSTGRESQL_USER="$user" \
+                              POSTGRESQL_PASSWORD="$pass" \
+                              POSTGRESQL_DATABASE="$db"
+
+  ct_os_wait_pod_ready "$service_name" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
+
+  # Create a simple configMap with a start.sh script
+  tmpdir=$(mktemp -d)
+  test_string="Start is working"
+  echo "echo $test_string" >> "$tmpdir/start.sh"
+  oc create configmap postgresql-start --from-file="$tmpdir/start.sh"
+  oc set volume "dc/$service_name" --add -t configmap --configmap-name=postgresql-start -m /opt/app-root/src/postgresql-start --name postgresql-start
+
+  # Wait for redeploy
+  ct_os_wait_pod_ready "$service_name-2" 60
+  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
+
+  # Check logs for the test string
+  oc logs "$(ct_os_get_pod_name "$service_name")" | grep "$test_string"
+
+  ct_os_delete_project
+}
+
 function run_ephemeral_tests() {
   local image_name=$1
   for template in $EPHEMERAL_TEMPLATES; do
@@ -393,6 +433,7 @@ test_postgresql_pure_image "$IMAGE_NAME"
 test_postgresql_replication "$IMAGE_NAME"
 run_ephemeral_tests "$IMAGE_NAME"
 run_persistent_tests "$IMAGE_NAME"
+test_postgresql_configmap_start "$IMAGE_NAME"
 
 # test with the just built image and an integrated template
 test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql

From 32c7dcd8a0731c33e430ef386726d8374216affd Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 4 Oct 2019 08:51:16 +0200
Subject: [PATCH 162/509] add postgresql12 for rhscl

Some changes needed from v10:
replication configuration has been moved from recovery.conf to postgresql.conf
standby.signal file is now used to switch into non-primary mode
---
 Makefile                                      |  2 +-
 manifest.sh                                   | 14 ++++++-------
 specs/multispec.yml                           | 20 ++++++++++++++++++-
 src/root/usr/bin/run-postgresql-slave         |  8 ++++++++
 .../openshift-custom-recovery.conf.template   |  2 ++
 test/run_test                                 |  6 +++---
 6 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 48ca7948..5870c0ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.6 10
+VERSIONS = 9.6 10 12
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/manifest.sh b/manifest.sh
index 16e02891..f93f4b3b 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -13,6 +13,13 @@ DISTGEN_RULES="
 
     src=src/root/usr/share/container-scripts/postgresql/common.sh
     dest=root/usr/share/container-scripts/postgresql/common.sh;
+
+    src=src/root/usr/bin/run-postgresql-slave
+    dest=root/usr/bin/run-postgresql-slave
+    mode=0755;
+
+    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+    dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
 "
 
 # Files containing distgen directives, which are used for each
@@ -58,9 +65,6 @@ COPY_RULES="
     src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
     dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template;
 
-    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
-    dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
-
     src=src/root/usr/share/container-scripts/postgresql/scl_enable
     dest=root/usr/share/container-scripts/postgresql/scl_enable;
 
@@ -72,10 +76,6 @@ COPY_RULES="
     dest=root/usr/bin/run-postgresql-master
     mode=0755;
 
-    src=src/root/usr/bin/run-postgresql-slave
-    dest=root/usr/bin/run-postgresql-slave
-    mode=0755;
-
     src=src/root/usr/bin/container-entrypoint
     dest=root/usr/bin/container-entrypoint
     mode=0755;
diff --git a/specs/multispec.yml b/specs/multispec.yml
index f32891fa..44cd41cd 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -36,7 +36,7 @@ specs:
            yum install -y yum-utils gettext && \
                prepare-yum-repositories rhel-server-rhscl-7-rpms && \
        rhscl_version:
-         development: 3.1
+         development: 3.4
     rhel8:
        distros:
          - rhel-8-x86_64
@@ -89,9 +89,27 @@ specs:
       cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
 
+    "12":
+      version: "12"
+      prev_version: "10"
+      short: "12"
+      prev_short: "10"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
+      centos_image_name: "centos/postgresql-{{ spec.short }}-centos7"
+      cccp_job: "postgresql-{{ spec.short }}-centos7"
+      latest_fedora: "rawhide"
+      has_devel_repo:
+        centos: True
+
 matrix:
   exclude:
     - distros:
         - fedora-29-x86_64
         - rhel-8-x86_64
       version: "9.5"
+    - distros:
+        - rhel-8-x86_64
+        - centos-7-x86_64
+        - fedora-29-x86_64
+      version: "12"
diff --git a/src/root/usr/bin/run-postgresql-slave b/src/root/usr/bin/run-postgresql-slave
index 82113b76..165014e8 100755
--- a/src/root/usr/bin/run-postgresql-slave
+++ b/src/root/usr/bin/run-postgresql-slave
@@ -17,11 +17,19 @@ function initialize_replica() {
 
   # PostgreSQL recovery configuration.
   generate_postgresql_recovery_config
+{% if spec.version not in ["9.4", "9.5", "9.6", "10"] %}
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+{% else %}
   cat >> "$PGDATA/recovery.conf" <<EOF
+{% endif %}
 
 # Custom OpenShift recovery configuration:
 include '${POSTGRESQL_RECOVERY_FILE}'
 EOF
+{% if spec.version not in ["9.4", "9.5", "9.6", "10"] %}
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+{% endif %}
 }
 
 check_env_vars
diff --git a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
index 26d56693..bd49c4b7 100644
--- a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -5,5 +5,7 @@
 #       Changes to this file will be overwritten.
 #
 
+{% if spec.version in ["9.4", "9.5", "9.6", "10"] %}
 standby_mode = on
+{% endif %}
 primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/test/run_test b/test/run_test
index 7411c186..66526f12 100755
--- a/test/run_test
+++ b/test/run_test
@@ -640,7 +640,7 @@ run_upgrade_test ()
     # is fixed for non-SCL use cases
     { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -662,9 +662,9 @@ run_migration_test ()
     local from_version
     # Only test a subset of the migration path on non-intel hosts
     if [ "$(uname -i)" == "x86_64" ]; then
-        local upgrade_path="9.2 9.4 9.5 9.6 10"
+        local upgrade_path="9.2 9.4 9.5 9.6 10 12"
     else
-        local upgrade_path="10"
+        local upgrade_path="10 12"
     fi
 
     for from_version in $upgrade_path; do

From 3ffec6bed78a5f598dda5fae5656bb929b391c18 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 14 Oct 2019 14:47:55 +0200
Subject: [PATCH 163/509] add pgaudit extension

---
 examples/pgaudit/README                       | 10 ++++
 .../pgaudit/postgresql-cfg/10_pgaudit.conf    |  1 +
 src/Dockerfile                                |  3 ++
 test/run_test                                 | 52 +++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 examples/pgaudit/README
 create mode 100644 examples/pgaudit/postgresql-cfg/10_pgaudit.conf

diff --git a/examples/pgaudit/README b/examples/pgaudit/README
new file mode 100644
index 00000000..5ae67dce
--- /dev/null
+++ b/examples/pgaudit/README
@@ -0,0 +1,10 @@
+The PostgreSQL Audit Extension (or pgaudit) provides detailed session and/or object
+audit logging via the standard logging facility provided by PostgreSQL.
+
+Bind-mount this directory under /opt/app-root/src in the container, and all the
+*.conf files from postgresql-cfg/ files will be included to postgresql.conf.
+
+This config file enables the pgaudit extensions that is available in the container
+image, but needs to be enabled.
+
+More about pgaudit extension at https://www.pgaudit.org.
diff --git a/examples/pgaudit/postgresql-cfg/10_pgaudit.conf b/examples/pgaudit/postgresql-cfg/10_pgaudit.conf
new file mode 100644
index 00000000..47329c40
--- /dev/null
+++ b/examples/pgaudit/postgresql-cfg/10_pgaudit.conf
@@ -0,0 +1 @@
+shared_preload_libraries = 'pgaudit'
diff --git a/src/Dockerfile b/src/Dockerfile
index 1100d4ee..5fff7a45 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -70,6 +70,9 @@ RUN {{ spec.environment_setup }}
   {% endif %}
 {% endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+{% if spec.version in ["12"] %}
+    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
+{% endif %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     {% if spec.post_install %}
diff --git a/test/run_test b/test/run_test
index 66526f12..4f6d275d 100755
--- a/test/run_test
+++ b/test/run_test
@@ -28,6 +28,7 @@ run_s2i_bake_data_test
 run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
+run_pgaudit_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -831,6 +832,57 @@ run_s2i_bake_data_test ()
   docker stop "$(get_cid "$container_name")"
 }
 
+run_pgaudit_test()
+{
+  # extension pgaudit is not available for older versions
+  case ${VERSION} in
+    9.2|9.4|9.5|9.6|10) echo "pgaudit not expected, test skipped."; return ;;
+    *) ;;
+  esac
+
+  local config_dir data_dir name=pg-test-pgaudit
+
+  # create a dir for config
+  config_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
+  add_cleanup_command /bin/rm -rf "$config_dir"
+  cp -r "$test_dir"/examples/pgaudit/* "$config_dir"
+  setfacl -R -m u:26:rwx "$config_dir"
+
+  # create a dir for data
+  create_volume_dir
+  data_dir="${volume_dir}"
+
+  DOCKER_ARGS="
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-v ${config_dir}:/opt/app-root/src:Z
+-v ${data_dir}:/var/lib/pgsql/data:Z
+  " create_container "$name"
+
+  assert_runtime_option "$name" shared_preload_libraries pgaudit
+  wait_ready "$name"
+
+  # enable the pgaudit extension
+  docker exec -i $(get_cid "$name") bash -c psql <<EOSQL
+CREATE EXTENSION pgaudit;
+SET pgaudit.log = 'read, ddl';
+CREATE DATABASE pgaudittest;
+EOSQL
+
+  # simulate some trafic that should be audited
+  docker exec -i $(get_cid "$name") bash -c psql pgaudittest <<EOSQL
+SET pgaudit.log = 'read, ddl';
+CREATE TABLE account (id int, name text, password text, description text);
+INSERT INTO account (id, name, password, description) VALUES (1, 'user1', 'HASH1', 'blah, blah');
+SELECT * FROM account;
+EOSQL
+
+  # give server some time for write all audit messages
+  sleep 1
+
+  grep -E 'AUDIT: SESSION,.*,.*,DDL,CREATE DATABASE,,,CREATE DATABASE pgaudittest' "${data_dir}"/userdata/log/postgresql-*.log
+  grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
+}
+
 function run_all_tests() {
   for test_case in $TEST_LIST; do
     : "Running test $test_case"

From 0763907348e036913eecf3fd6c88e3e85ec9f312 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Dec 2019 08:10:30 +0000
Subject: [PATCH 164/509] remove EOL versions from distgen template additions

Co-Authored-By: Petr Hracek <phracek@redhat.com>
---
 src/root/usr/bin/run-postgresql-slave                         | 4 ++--
 .../postgresql/openshift-custom-recovery.conf.template        | 2 +-
 test/run_test                                                 | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/root/usr/bin/run-postgresql-slave b/src/root/usr/bin/run-postgresql-slave
index 165014e8..f3a63bef 100755
--- a/src/root/usr/bin/run-postgresql-slave
+++ b/src/root/usr/bin/run-postgresql-slave
@@ -17,7 +17,7 @@ function initialize_replica() {
 
   # PostgreSQL recovery configuration.
   generate_postgresql_recovery_config
-{% if spec.version not in ["9.4", "9.5", "9.6", "10"] %}
+{% if spec.version not in ["9.6", "10"] %}
   cat >> "$PGDATA/postgresql.auto.conf" <<EOF
 {% else %}
   cat >> "$PGDATA/recovery.conf" <<EOF
@@ -26,7 +26,7 @@ function initialize_replica() {
 # Custom OpenShift recovery configuration:
 include '${POSTGRESQL_RECOVERY_FILE}'
 EOF
-{% if spec.version not in ["9.4", "9.5", "9.6", "10"] %}
+{% if spec.version not in ["9.6", "10"] %}
   # activate standby mode
   touch "$PGDATA/standby.signal"
 {% endif %}
diff --git a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
index bd49c4b7..4d711c9b 100644
--- a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -5,7 +5,7 @@
 #       Changes to this file will be overwritten.
 #
 
-{% if spec.version in ["9.4", "9.5", "9.6", "10"] %}
+{% if spec.version in ["9.6", "10"] %}
 standby_mode = on
 {% endif %}
 primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/test/run_test b/test/run_test
index 4f6d275d..d4321064 100755
--- a/test/run_test
+++ b/test/run_test
@@ -836,7 +836,7 @@ run_pgaudit_test()
 {
   # extension pgaudit is not available for older versions
   case ${VERSION} in
-    9.2|9.4|9.5|9.6|10) echo "pgaudit not expected, test skipped."; return ;;
+    9.6|10) echo "pgaudit not expected, test skipped."; return ;;
     *) ;;
   esac
 

From 5cac1fc74bbfb4696c95a13ba461b9511dc7db6b Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Dec 2019 09:22:44 +0100
Subject: [PATCH 165/509] generate v12 for centos7 as well

---
 specs/multispec.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 44cd41cd..25352850 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -110,6 +110,5 @@ matrix:
       version: "9.5"
     - distros:
         - rhel-8-x86_64
-        - centos-7-x86_64
         - fedora-29-x86_64
       version: "12"

From 2a5a59362e8d88e672c4b272dc5dea4a7a650447 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Dec 2019 11:49:59 +0100
Subject: [PATCH 166/509] use pg-test-lib to get released image name

---
 test/run-openshift-local-cluster | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index 095053c6..845ed82d 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -10,6 +10,7 @@ THISDIR=$(dirname ${BASH_SOURCE[0]})
 TEMPLATES="$THISDIR/examples"
 REMOTE_TEMPLATES="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates"
 
+source "$THISDIR"/pg-test-lib.sh
 source "$THISDIR"/test-lib-openshift.sh
 source "$THISDIR"/test-lib-postgresql.sh
 
@@ -166,16 +167,7 @@ function test_postgresql_update() {
   local registry="" old_image="" pod_ip=""
   local version released=:
 
-  case $OS in
-  rhel7)
-      registry=registry.access.redhat.com
-      ;;
-  centos7)
-      registry=docker.io
-      ;;
-  esac
-
-  old_image="$registry/$image_name"
+  old_image=$(get_image_id "$VERSION:remote")
 
   for version in $NOT_RELEASED_VERSIONS; do
     case $image_name in

From e358a975d1009292445309366cb950db9b41b0d8 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 17 Dec 2019 13:09:26 +0100
Subject: [PATCH 167/509] use registry.redhat.io for released rhel7 images

---
 test/pg-test-lib.sh              | 2 +-
 test/run-openshift-local-cluster | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index e8f9ef45..71e8d5c4 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -26,7 +26,7 @@ get_image_id ()
                 if test "$version" -eq 92; then
                     ns=openshift3
                 fi
-                image=registry.access.redhat.com/$ns/postgresql-${version}-rhel7
+                image=registry.redhat.io/$ns/postgresql-${version}-rhel7
                 ;;
             centos7)
                 ns=centos
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index 845ed82d..dc78b2b0 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -432,7 +432,7 @@ test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql
 
 # test with a released image and an integrated template
 if [ "${OS}" == "rhel7" ] ; then
-  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.access.redhat.com/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
+  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.redhat.io/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
 else
   PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
 fi

From bb0825eeef6142a1034e3eb79d52b47ecc4b89ef Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 18 Dec 2019 09:08:38 +0100
Subject: [PATCH 168/509] do not fail centos7 tests if image is not yet
 released

---
 test/run-openshift-local-cluster | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index dc78b2b0..79c592f6 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -431,14 +431,23 @@ test_postgresql_configmap_start "$IMAGE_NAME"
 test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql
 
 # test with a released image and an integrated template
+# ignore possible failure of this test for centos images
+fail_not_released=true
 if [ "${OS}" == "rhel7" ] ; then
   PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.redhat.io/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
 else
   PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
+  fail_not_released=false
 fi
 
 export CT_SKIP_UPLOAD_IMAGE=true
-test_postgresql_integration postgresql "${VERSION}" "${PUBLIC_IMAGE_NAME}"
+# Try pulling the image first to see if it is accessible
+if docker pull "${PUBLIC_IMAGE_NAME}"; then
+  test_postgresql_integration postgresql "${VERSION}" "${PUBLIC_IMAGE_NAME}"
+else
+  echo "Warning: ${PUBLIC_IMAGE_NAME} could not be downloaded via 'docker'"
+  ! $fail_not_released || false "ERROR: Failed to pull image"
+fi
 
 OS_TESTSUITE_RESULT=0
 

From 4e75f23db227dd6570b1f992020a76a52cee78e5 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 18 Dec 2019 09:27:27 +0100
Subject: [PATCH 169/509] add mention of version 12 to root README

---
 README.md | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 9b30a352..83722c29 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ Versions
 PostgreSQL versions currently supported are:
 * [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
+* [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -32,10 +33,10 @@ Choose either the CentOS7 or RHEL7 based image:
 
 *  **RHEL7 based image**
 
-    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-10-rhel7).
+    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-12-rhel7).
     To download it run:
     ```
-    podman pull registry.access.redhat.com/rhscl/postgresql-10-rhel7
+    podman pull registry.redhat.io/rhscl/postgresql-12-rhel7
     ```
 
     To build a RHEL7 based image, you need to run Docker build on a properly
@@ -44,7 +45,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONS=10
+    $ make build TARGET=rhel7 VERSIONS=12
     ```
 
 *  **CentOS7 based image**
@@ -52,7 +53,7 @@ Choose either the CentOS7 or RHEL7 based image:
     These images are available on DockerHub. To download it run:
 
     ```
-    $ podman pull centos/postgresql-10-centos7
+    $ podman pull centos/postgresql-12-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -60,7 +61,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSIONS=10
+    $ make build TARGET=centos7 VERSIONS=12
     ```
 
 Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments.
@@ -82,6 +83,9 @@ see [usage documentation](https://github.com/sclorg/postgresql-container/tree/ge
 For information about usage of Dockerfile for PostgreSQL 10,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
 
+For information about usage of Dockerfile for PostgreSQL 12,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/12).
+
 For versions which are not supported anymore:
 [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
 and
@@ -102,19 +106,19 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSIONS=10
+    $ make test TARGET=rhel7 VERSIONS=12
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSIONS=10
+    $ make test TARGET=centos7 VERSIONS=12
     ```
 +By using the `TESTS` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSIONS=10 TESTS="run_general_tests run_replication_test"
+    $ make test VERSIONS=12 TESTS="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed

From 27dc82474524491e53772126b14c37a2ce5210b8 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 15 Jan 2020 20:36:41 +0100
Subject: [PATCH 170/509] Add imagestream file for s390x and add v12 image

---
 imagestreams/postgresql-centos7.json       | 20 ++++++-
 imagestreams/postgresql-rhel7-ppc64le.json | 20 ++++++-
 imagestreams/postgresql-rhel7-s390x.json   | 67 ++++++++++++++++++++++
 imagestreams/postgresql-rhel7.json         | 20 ++++++-
 4 files changed, 124 insertions(+), 3 deletions(-)
 create mode 100644 imagestreams/postgresql-rhel7-s390x.json

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index d12fe9be..c8b70dae 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -20,7 +20,7 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "10"
+          "name": "12"
         },
         "referencePolicy": {
           "type": "Local"
@@ -61,6 +61,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "12",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-12-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel7-ppc64le.json
index 133b962c..aba189cf 100644
--- a/imagestreams/postgresql-rhel7-ppc64le.json
+++ b/imagestreams/postgresql-rhel7-ppc64le.json
@@ -20,7 +20,7 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "10"
+          "name": "12"
         },
         "referencePolicy": {
           "type": "Local"
@@ -43,6 +43,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "12",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel7-s390x.json b/imagestreams/postgresql-rhel7-s390x.json
new file mode 100644
index 00000000..f0c29e70
--- /dev/null
+++ b/imagestreams/postgresql-rhel7-s390x.json
@@ -0,0 +1,67 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "12"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      }
+    ]
+  }
+}
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 69dd7fb1..47007597 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -20,7 +20,7 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "10"
+          "name": "12"
         },
         "referencePolicy": {
           "type": "Local"
@@ -61,6 +61,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "12",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }

From 9211bb6edd2848a2dbdcd91b17438dee1068bef9 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 3 Dec 2019 07:11:00 +0100
Subject: [PATCH 171/509] On non-intel arches, data_sync_retry = off (default
 since v11) does not work

It might be related to the issue we recently saw in nodejs, because using unconfined
seccomp profile (--security-opt=seccomp=unconfined as a docker option) works.

RHBZ with most information:
https://bugzilla.redhat.com/show_bug.cgi?id=1779150

The nodejs issue resulted in a kernel bug fix:
https://bugzilla.redhat.com/show_bug.cgi?id=1760294

Original nodejs report:
https://bugzilla.redhat.com/show_bug.cgi?id=1759152#c34

Also reported for libseccomp:
https://bugzilla.redhat.com/show_bug.cgi?id=1762578#c12

PostgreSQL Upstream discussion relevant for the changes in data_sync_retry:
https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com

Upstream changes that caused this issue:
https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
---
 .../container-scripts/postgresql/common.sh     | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index d89f3423..b6abb690 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -119,6 +119,16 @@ function generate_postgresql_config() {
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  if [ "$POSTGRESQL_VERSION" -ge 12 ] && [ "$(uname -p)" != 'x86_64' ] && [[ "$(. /etc/os-release ; echo $VERSION_ID)" =~ 7.* ]] ; then
+    # On non-intel arches, data_sync_retry = off does not work
+    # Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+    # Upstream changes that caused this issue:
+    # https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+    # https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+    # RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -310,6 +320,9 @@ run_pgupgrade ()
   # User-specififed options for pg_upgrade.
   eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
 
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
   # the upgrade
   info_msg "Starting the pg_upgrade process."
 
@@ -317,7 +330,7 @@ run_pgupgrade ()
   # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
   # that we don't need to fiddle with unix_socket_director{y,ies} option.
   REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { rm -rf "$PGDATA_new" && false ; }
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
 
   # Move the important configuration and remove old data.  This is highly
   # careless, but we can't do more for this over-automatized process.
@@ -326,6 +339,9 @@ run_pgupgrade ()
   rm -rf "$PGDATA"
   mv "$PGDATA_new" "$PGDATA"
 
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
   info_msg "Upgrade DONE."
 )
 

From e6683d26ddc7418377d661b707b31abbdf890bea Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 3 Dec 2019 16:36:38 +0100
Subject: [PATCH 172/509] Run all tests by default, allow to fail immediately
 and improve results reporting

---
 test/run_test | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index d4321064..6667e5c7 100755
--- a/test/run_test
+++ b/test/run_test
@@ -5,6 +5,9 @@
 # IMAGE_NAME specifies the name of the candidate image used for testing.
 # The image has to be available before this script is executed.
 #
+# By default, all the tests are run. For debugging purposes, FAIL_QUICKLY
+# variable can be set to 1, which makes the test-suite to fail right after any
+# of the tests fails.
 
 set -exo nounset
 shopt -s nullglob
@@ -42,6 +45,8 @@ volumes_to_clean=
 images_to_clean=()
 files_to_clean=
 test_dir="$(readlink -f "$(dirname "$0")")"
+test_short_summary=''
+TESTSUITE_RESULT=1
 
 _cleanup_commands_space=
 _cleanup_commands=
@@ -89,6 +94,14 @@ function cleanup() {
   echo "$_cleanup_commands" | while read -r line; do
     eval "$line"
   done
+
+  echo "$test_short_summary"
+
+  if [ $TESTSUITE_RESULT -eq 0 ] ; then
+    echo "Tests for ${IMAGE_NAME} succeeded."
+  else
+    echo "Tests for ${IMAGE_NAME} failed."
+  fi
 }
 trap cleanup EXIT
 
@@ -884,10 +897,18 @@ EOSQL
 }
 
 function run_all_tests() {
+  local suite_result=0
   for test_case in $TEST_LIST; do
     : "Running test $test_case"
-    $test_case
+    if $test_case ; then
+      printf -v test_short_summary "${test_short_summary}[PASSED] $test_case\n"
+    else
+      printf -v test_short_summary "${test_short_summary}[FAILED] $test_case\n"
+      suite_result=1
+      [ -n "${FAIL_QUICKLY:-}" ] && echo "$sum" && return $suite_result
+    fi
   done;
+  return $suite_result
 }
 
 # configuration defaults
@@ -897,3 +918,6 @@ POSTGRESQL_SHARED_BUFFERS=32MB
 
 # Run the chosen tests
 TEST_LIST=${TESTS:-$TEST_LIST} run_all_tests
+
+TESTSUITE_RESULT=0
+echo "All tests passed."

From f809bbbd6cb9c12af274ff51ab44c0f9479b387f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 4 Feb 2020 13:31:21 +0100
Subject: [PATCH 173/509] do not generate 9.5 anymore

---
 specs/multispec.yml | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 25352850..bb674d13 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -56,17 +56,6 @@ specs:
         - fedora-29-x86_64
 
   version:
-    "9.5":
-      version: "9.5"
-      prev_version: "9.4"
-      short: "95"
-      prev_short: "94"
-      common_image_name: "{{ spec.org }}/postgresql-95-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-95-rhel7"
-      centos_image_name: "centos/postgresql-95-centos7"
-      cccp_job: "postgresql-95-centos7"
-      latest_fedora: "f25"
-
     "9.6":
       version: "9.6"
       prev_version: "9.5"
@@ -104,10 +93,6 @@ specs:
 
 matrix:
   exclude:
-    - distros:
-        - fedora-29-x86_64
-        - rhel-8-x86_64
-      version: "9.5"
     - distros:
         - rhel-8-x86_64
         - fedora-29-x86_64

From 983fea588bcd6f3db3496f24346c574ef3d1cf46 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 4 Feb 2020 13:31:40 +0100
Subject: [PATCH 174/509] fix Fedora builds

move to latest stable (f31) s2i-core base image
use modules for postgresql builds
install pgaudit in postgresq 12 and later
---
 specs/multispec.yml   | 3 +--
 src/Dockerfile.fedora | 6 +++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index bb674d13..4b032c80 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -53,7 +53,7 @@ specs:
            yum -y reinstall tzdata && \
     fedora:
       distros:
-        - fedora-29-x86_64
+        - fedora-31-x86_64
 
   version:
     "9.6":
@@ -95,5 +95,4 @@ matrix:
   exclude:
     - distros:
         - rhel-8-x86_64
-        - fedora-29-x86_64
       version: "12"
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index aaae692b..939e53c9 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM registry.fedoraproject.org/{{ spec.latest_fedora }}/s2i-core:latest
+FROM registry.fedoraproject.org/f{{ config.os.version }}/s2i-core:latest
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -46,6 +46,10 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
     INSTALL_PKGS+="findutils python2 xz" && \
+{% if spec.version not in ["9.6", "10"] %}
+    INSTALL_PKGS+=" pgaudit" && \
+{% endif %}
+    dnf -y module enable postgresql:{{ spec.version }} && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     dnf clean all && \

From f0939080c023f38d9a12783080058965d5a22687 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Mon, 10 Feb 2020 14:35:20 +0100
Subject: [PATCH 175/509] move to latest common scripts

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index aaab8970..7cc9c7d2 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit aaab8970c072927fccfa0f9c9af278b6b55714b8
+Subproject commit 7cc9c7d22bc8cdd3e7b34fad1f5c96a8d0898664

From f1bccd79c53ea0f4580f8f0f9183bb7c9c9d5118 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 11 Feb 2020 09:11:03 +0100
Subject: [PATCH 176/509] do not install python2 in Fedora images

---
 src/Dockerfile.fedora | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 939e53c9..b2008572 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -45,7 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils python2 xz" && \
+    INSTALL_PKGS+="findutils xz" && \
 {% if spec.version not in ["9.6", "10"] %}
     INSTALL_PKGS+=" pgaudit" && \
 {% endif %}

From fcbc03a6564711381c51cdfc23a96d62e5f28271 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 4 Feb 2020 09:56:58 +0100
Subject: [PATCH 177/509] add syspath packages for easier work with postgresql
 SCLs

---
 specs/multispec.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 4b032c80..26bce0c5 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -12,7 +12,7 @@ specs:
       redhat_component: "rh-postgresql{{ spec.short }}-container"
       enabled_collection: "rh-postgresql{{ spec.short }}"
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.prev_short }}-postgresql-server"
+      pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
       repo_enable_reason: ""
       environment_setup: yum install -y centos-release-scl-rh && \
       staging_repo_setup: >-4
@@ -28,7 +28,7 @@ specs:
        redhat_component: "rh-postgresql{{ spec.short }}-container"
        enabled_collection: "rh-postgresql{{ spec.short }}"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.prev_short }}-postgresql-server"
+       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
        repo_enable_reason: |-
          # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
          # in base RHEL

From dd96bc4600bdd68b2bc451072ddc4bd608542f7c Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 17 Mar 2020 15:50:06 +0100
Subject: [PATCH 178/509] Remove FAIL_QUICKLY feature because it hides failures
 in the test functions

There is a problem in the way test cases could be run all, even if they failed. Running the test function inside an IF statment disables 'set -e' in the function and cannot be re-set. The problem is demonstrated in https://github.com/sclorg/postgresql-container/pull/363 which added 'false' call in the beginning of the test functions, but the test suite still passed.
---
 test/run_test | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/test/run_test b/test/run_test
index 6667e5c7..5fe68361 100755
--- a/test/run_test
+++ b/test/run_test
@@ -5,9 +5,6 @@
 # IMAGE_NAME specifies the name of the candidate image used for testing.
 # The image has to be available before this script is executed.
 #
-# By default, all the tests are run. For debugging purposes, FAIL_QUICKLY
-# variable can be set to 1, which makes the test-suite to fail right after any
-# of the tests fails.
 
 set -exo nounset
 shopt -s nullglob
@@ -897,18 +894,10 @@ EOSQL
 }
 
 function run_all_tests() {
-  local suite_result=0
   for test_case in $TEST_LIST; do
     : "Running test $test_case"
-    if $test_case ; then
-      printf -v test_short_summary "${test_short_summary}[PASSED] $test_case\n"
-    else
-      printf -v test_short_summary "${test_short_summary}[FAILED] $test_case\n"
-      suite_result=1
-      [ -n "${FAIL_QUICKLY:-}" ] && echo "$sum" && return $suite_result
-    fi
+    $test_case
   done;
-  return $suite_result
 }
 
 # configuration defaults

From f4310a3d3ab9346241c72e17ffadc2360cfa018f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 24 Mar 2020 10:07:09 +0000
Subject: [PATCH 179/509] add version 11 for use in Fedora (#367)

* add version 11 for use in Fedora

* do not build for EOL Fedoras

* fix generation for version 11
---
 Makefile                                      |  2 +-
 specs/multispec.yml                           | 22 ++++++++++++++++++-
 src/Dockerfile.fedora                         |  4 ++--
 src/root/usr/bin/run-postgresql-slave         |  4 ++--
 .../openshift-custom-recovery.conf.template   |  2 +-
 test/run_test                                 |  2 +-
 6 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 5870c0ba..14ddf7e5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.6 10 12
+VERSIONS = 9.6 10 11 12
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 26bce0c5..b3a26fe3 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -78,6 +78,15 @@ specs:
       cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
 
+    "11":
+      version: "11"
+      prev_version: "10"
+      short: "11"
+      prev_short: "10"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      cccp_job: "postgresql-{{ spec.short }}-centos7"
+      latest_fedora: "f31"
+
     "12":
       version: "12"
       prev_version: "10"
@@ -87,12 +96,23 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos/postgresql-{{ spec.short }}-centos7"
       cccp_job: "postgresql-{{ spec.short }}-centos7"
-      latest_fedora: "rawhide"
+      latest_fedora: "f32"
       has_devel_repo:
         centos: True
 
 matrix:
   exclude:
+    - distros:
+        - fedora-31-x86_64
+      version: "9.6"
+    - distros:
+        - fedora-31-x86_64
+      version: "10"
+    - distros:
+        - rhel-7-x86_64
+        - rhel-8-x86_64
+        - centos-7-x86_64
+      version: "11"
     - distros:
         - rhel-8-x86_64
       version: "12"
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index b2008572..a53ae6aa 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM registry.fedoraproject.org/f{{ config.os.version }}/s2i-core:latest
+FROM registry.fedoraproject.org/{{ spec.latest_fedora }}/s2i-core:latest
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -46,7 +46,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
     INSTALL_PKGS+="findutils xz" && \
-{% if spec.version not in ["9.6", "10"] %}
+{% if spec.version not in ["9.6", "10", "11"] %}
     INSTALL_PKGS+=" pgaudit" && \
 {% endif %}
     dnf -y module enable postgresql:{{ spec.version }} && \
diff --git a/src/root/usr/bin/run-postgresql-slave b/src/root/usr/bin/run-postgresql-slave
index f3a63bef..6a70d831 100755
--- a/src/root/usr/bin/run-postgresql-slave
+++ b/src/root/usr/bin/run-postgresql-slave
@@ -17,7 +17,7 @@ function initialize_replica() {
 
   # PostgreSQL recovery configuration.
   generate_postgresql_recovery_config
-{% if spec.version not in ["9.6", "10"] %}
+{% if spec.version not in ["9.6", "10", "11"] %}
   cat >> "$PGDATA/postgresql.auto.conf" <<EOF
 {% else %}
   cat >> "$PGDATA/recovery.conf" <<EOF
@@ -26,7 +26,7 @@ function initialize_replica() {
 # Custom OpenShift recovery configuration:
 include '${POSTGRESQL_RECOVERY_FILE}'
 EOF
-{% if spec.version not in ["9.6", "10"] %}
+{% if spec.version not in ["9.6", "10", "11"] %}
   # activate standby mode
   touch "$PGDATA/standby.signal"
 {% endif %}
diff --git a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
index 4d711c9b..641e618c 100644
--- a/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ b/src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -5,7 +5,7 @@
 #       Changes to this file will be overwritten.
 #
 
-{% if spec.version in ["9.6", "10"] %}
+{% if spec.version in ["9.6", "10", "11"] %}
 standby_mode = on
 {% endif %}
 primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/test/run_test b/test/run_test
index 5fe68361..2c687309 100755
--- a/test/run_test
+++ b/test/run_test
@@ -846,7 +846,7 @@ run_pgaudit_test()
 {
   # extension pgaudit is not available for older versions
   case ${VERSION} in
-    9.6|10) echo "pgaudit not expected, test skipped."; return ;;
+    9.6|10|11) echo "pgaudit not expected, test skipped."; return ;;
     *) ;;
   esac
 

From 7a943a3803b8d8883b9cfc29f79fe29105ffbe1f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 26 Mar 2020 10:18:33 +0100
Subject: [PATCH 180/509] remove centos7 testing repositories

---
 specs/multispec.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index b3a26fe3..624db016 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -97,8 +97,6 @@ specs:
       centos_image_name: "centos/postgresql-{{ spec.short }}-centos7"
       cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f32"
-      has_devel_repo:
-        centos: True
 
 matrix:
   exclude:

From dfadb800eecab85647fa74c4d4566c892c59257d Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 1 Apr 2020 20:32:29 +0200
Subject: [PATCH 181/509] Turn the data_sync_retry to on for all versions

Because the change was done for all supported versions in upstream:
https://www.postgresql.org/about/news/1920/

Previously work-arounded for PostgreSQL v12 only:
https://github.com/sclorg/postgresql-container/pull/354

We hit this with the 10.12 version
Resolves: #1819122
---
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index b6abb690..624a7065 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -119,7 +119,7 @@ function generate_postgresql_config() {
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
 
-  if [ "$POSTGRESQL_VERSION" -ge 12 ] && [ "$(uname -p)" != 'x86_64' ] && [[ "$(. /etc/os-release ; echo $VERSION_ID)" =~ 7.* ]] ; then
+  if [ "$(uname -p)" != 'x86_64' ] && [[ "$(. /etc/os-release ; echo $VERSION_ID)" =~ 7.* ]] ; then
     # On non-intel arches, data_sync_retry = off does not work
     # Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
     # Upstream changes that caused this issue:

From 85dbcb374dc9784d5e305dec5d93072d0ff55b45 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Tue, 7 Apr 2020 11:11:58 +0200
Subject: [PATCH 182/509] turn on data_sync_retry in rhel8 images as well

---
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 624a7065..424ccd0f 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -119,7 +119,7 @@ function generate_postgresql_config() {
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
 
-  if [ "$(uname -p)" != 'x86_64' ] && [[ "$(. /etc/os-release ; echo $VERSION_ID)" =~ 7.* ]] ; then
+  if [ "$(uname -p)" != 'x86_64' ]; then
     # On non-intel arches, data_sync_retry = off does not work
     # Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
     # Upstream changes that caused this issue:

From 4b2460dde65d5bd6edc0dec7ca385ad3ba760e5a Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 23 Apr 2020 19:40:10 +0200
Subject: [PATCH 183/509] Use the hack with the data_sync_retry only on version
 that support that option

---
 .../container-scripts/postgresql/common.sh    | 45 ++++++++++++++++---
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 424ccd0f..a8592ffe 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -106,6 +106,43 @@ function postgresql_master_addr() {
   echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
 }
 
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -119,13 +156,7 @@ function generate_postgresql_config() {
         >> "${POSTGRESQL_CONFIG_FILE}"
   fi
 
-  if [ "$(uname -p)" != 'x86_64' ]; then
-    # On non-intel arches, data_sync_retry = off does not work
-    # Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
-    # Upstream changes that caused this issue:
-    # https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
-    # https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
-    # RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+  if should_hack_data_sync_retry ; then
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 

From c5c869b69828020aec7084762e6775566c157314 Mon Sep 17 00:00:00 2001
From: bscheshirwork <bscheshir.work@gmail.com>
Date: Tue, 14 Apr 2020 16:41:17 +0300
Subject: [PATCH 184/509] add note about reserved user

---
 src/root/usr/share/container-scripts/postgresql/README.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index a5e9e65d..ea0a6428 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -33,7 +33,10 @@ $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL
 ```
 
 This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. Port 5432 will be exposed
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
 and mapped to the host. If you want your database to be persistent across container
 executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
 below). This will be the PostgreSQL database cluster directory.

From 132f8a783601582347b99d5d24271ed124dc7e71 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 7 May 2020 10:27:56 +0200
Subject: [PATCH 185/509] Move input into the container (#375)

* Move input into the container

Otherwise it does not work in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324

* Add a comment about unusual heredoc usage

* Use the podman workaround for exec and redirection in migration test

For the migration test, the change is more complicated because there is no
easy way to direct longer text into the psql input from file, when redirecting
does not work with exec and the container itself does not have the file.

It was solved by running a separate container, because with podman run
the problem with redirection does not occur.

Co-authored-by: root <root@ci-vm-10-0-138-242.hosted.upshift.rdu2.redhat.com>
---
 test/pagila.sh      |  7 ++++++-
 test/pg-test-lib.sh | 18 ++++++++++++------
 test/run_test       | 13 +++++++++----
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/test/pagila.sh b/test/pagila.sh
index 123c6bb0..2068de68 100755
--- a/test/pagila.sh
+++ b/test/pagila.sh
@@ -34,4 +34,9 @@ case $(sha256sum "$pagila_file") in
 *) false ;;
 esac
 
-docker exec -i "$CID" container-entrypoint psql -tA < "$pagila_file" &>/dev/null
+# Deliberately using a separate container, otherwise the docker exec with redirection
+# does not work in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
+# This change can be reverted to the previous variant, once this BZ is fixed.
+server_ip=$(docker inspect --format='{{.NetworkSettings.IPAddress}}' "$CID")
+admin_pass=$(docker exec "$CID" bash -c 'echo $POSTGRESQL_ADMIN_PASSWORD')
+docker run --rm -i "$IMAGE_NAME" bash -c "PGPASSWORD=$admin_pass psql -h $server_ip" <"$pagila_file" &>/dev/null
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 71e8d5c4..70bea018 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -58,11 +58,13 @@ data_pagila_check ()
     local exp_output='28
 16
 2'
-    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+    # Deliberately moving heredoc into the container, otherwise it does not work
+    # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
+    local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
 select count(*) from information_schema.tables where table_schema = 'public';
 select count(*) from information_schema.triggers;
 select count(*) from staff;
-EOF
+EOF"
 )
     test "$exp_output" = "$output" \
         || error "Unexpected output: '$output', expected: '$exp_output'"
@@ -70,10 +72,12 @@ EOF
 
 data_empty_create ()
 {
-    docker exec -i "$CID" container-entrypoint psql &>/dev/null <<EOF
+    # Deliberately moving heredoc into the container, otherwise it does not work
+    # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
+    docker exec -i "$CID" bash -c "psql &>/dev/null <<EOF
 create table blah (id int);
 insert into blah values (1), (2), (3);
-EOF
+EOF"
 }
 
 data_empty_check ()
@@ -82,9 +86,11 @@ data_empty_check ()
     local exp_output='1
 2
 3'
-    local output=$(docker exec -i "$CID" container-entrypoint psql -tA <<EOF
+    # Deliberately moving heredoc into the container, otherwise it does not work
+    # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
+    local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
 select * from blah order by id;
-EOF
+EOF"
 )
     test "$exp_output" = "$output" || error "Unexpected output '$output'"
 }
diff --git a/test/run_test b/test/run_test
index 2c687309..3205c077 100755
--- a/test/run_test
+++ b/test/run_test
@@ -60,6 +60,9 @@ add_cleanup_command ()
 '
 }
 function cleanup() {
+  # Print a big fat separator to find the error easier
+  echo "=================================== Cleanup begins here ============================="
+
   for cidfile in $CIDFILE_DIR/* ; do
     CONTAINER=$(cat $cidfile)
 
@@ -872,19 +875,21 @@ run_pgaudit_test()
   wait_ready "$name"
 
   # enable the pgaudit extension
-  docker exec -i $(get_cid "$name") bash -c psql <<EOSQL
+  # Deliberately moving heredoc into the container, otherwise it does not work
+  # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
+  docker exec -i $(get_cid "$name") bash -c "psql <<EOSQL
 CREATE EXTENSION pgaudit;
 SET pgaudit.log = 'read, ddl';
 CREATE DATABASE pgaudittest;
-EOSQL
+EOSQL"
 
   # simulate some trafic that should be audited
-  docker exec -i $(get_cid "$name") bash -c psql pgaudittest <<EOSQL
+  docker exec -i $(get_cid "$name") bash -c "psql pgaudittest <<EOSQL
 SET pgaudit.log = 'read, ddl';
 CREATE TABLE account (id int, name text, password text, description text);
 INSERT INTO account (id, name, password, description) VALUES (1, 'user1', 'HASH1', 'blah, blah');
 SELECT * FROM account;
-EOSQL
+EOSQL"
 
   # give server some time for write all audit messages
   sleep 1

From 24bfab2d45be8147216ed6a4fb2168b9f5185857 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 22 May 2020 14:27:23 +0200
Subject: [PATCH 186/509] Reorder imagestreams. No other change

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/postgresql-centos7.json       | 20 ++++++++++----------
 imagestreams/postgresql-rhel7-ppc64le.json | 20 ++++++++++----------
 imagestreams/postgresql-rhel7-s390x.json   | 20 ++++++++++----------
 imagestreams/postgresql-rhel7.json         | 20 ++++++++++----------
 4 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index c8b70dae..d5e41c5e 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -27,18 +27,18 @@
         }
       },
       {
-        "name": "9.6",
+        "name": "12",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6",
+          "openshift.io/display-name": "PostgreSQL 12",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "9.6"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-96-centos7:latest"
+          "name": "docker.io/centos/postgresql-12-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -63,18 +63,18 @@
         }
       },
       {
-        "name": "12",
+        "name": "9.6",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12",
+          "openshift.io/display-name": "PostgreSQL 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "9.6"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-12-centos7:latest"
+          "name": "docker.io/centos/postgresql-96-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel7-ppc64le.json
index aba189cf..bd1442c0 100644
--- a/imagestreams/postgresql-rhel7-ppc64le.json
+++ b/imagestreams/postgresql-rhel7-ppc64le.json
@@ -27,36 +27,36 @@
         }
       },
       {
-        "name": "10",
+        "name": "12",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,ppc64le",
-          "version": "10"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12",
+        "name": "10",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,ppc64le",
-          "version": "12"
+          "version": "10"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel7-s390x.json b/imagestreams/postgresql-rhel7-s390x.json
index f0c29e70..059248ac 100644
--- a/imagestreams/postgresql-rhel7-s390x.json
+++ b/imagestreams/postgresql-rhel7-s390x.json
@@ -27,36 +27,36 @@
         }
       },
       {
-        "name": "10",
+        "name": "12",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,s390x",
-          "version": "10"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12",
+        "name": "10",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,s390x",
-          "version": "12"
+          "version": "10"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index 47007597..b7db687b 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -27,18 +27,18 @@
         }
       },
       {
-        "name": "9.6",
+        "name": "12",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "9.6"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -63,18 +63,18 @@
         }
       },
       {
-        "name": "12",
+        "name": "9.6",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "9.6"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"

From f4ed3b82cf3f32b13a82b6e2468fa9a0bbd3c6bf Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 26 May 2020 16:48:09 +0200
Subject: [PATCH 187/509] Add image stream test, fix openshift tests for OCP4
 and adopt changes from common/test-lib-openshfit.sh

---
 common                            |  2 +-
 test/run-openshift-local-cluster  | 20 ++++++++++++++------
 test/run-openshift-remote-cluster |  8 +++++++-
 test/test-lib-postgresql.sh       | 18 ++++++++++++++----
 4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/common b/common
index 7cc9c7d2..13285eb9 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 7cc9c7d22bc8cdd3e7b34fad1f5c96a8d0898664
+Subproject commit 13285eb93bbe1ed6fb18a48b2d526f104b9f490e
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index 79c592f6..c3c09945 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -14,11 +14,11 @@ source "$THISDIR"/pg-test-lib.sh
 source "$THISDIR"/test-lib-openshift.sh
 source "$THISDIR"/test-lib-postgresql.sh
 
-set -exo nounset
+set -eo nounset
 
-test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
-test -n "${VERSION-}" || false 'make sure $VERSION is defined'
-test -n "${OS-}" || false 'make sure $OS is defined'
+trap ct_os_cleanup EXIT SIGINT
+
+ct_os_check_compulsory_vars
 
 # Populate template variables if not set already
 if [ -z "${EPHEMERAL_TEMPLATES:-}" ]; then
@@ -428,6 +428,7 @@ run_persistent_tests "$IMAGE_NAME"
 test_postgresql_configmap_start "$IMAGE_NAME"
 
 # test with the just built image and an integrated template
+echo "Running test_postgresql_integration with ${IMAGE_NAME}"
 test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql
 
 # test with a released image and an integrated template
@@ -440,15 +441,22 @@ else
   fail_not_released=false
 fi
 
-export CT_SKIP_UPLOAD_IMAGE=true
 # Try pulling the image first to see if it is accessible
 if docker pull "${PUBLIC_IMAGE_NAME}"; then
-  test_postgresql_integration postgresql "${VERSION}" "${PUBLIC_IMAGE_NAME}"
+  echo "Running test_postgresql_integration with ${PUBLIC_IMAGE_NAME}"
+  test_postgresql_integration "${PUBLIC_IMAGE_NAME}" "${VERSION}" postgresql
 else
   echo "Warning: ${PUBLIC_IMAGE_NAME} could not be downloaded via 'docker'"
   ! $fail_not_released || false "ERROR: Failed to pull image"
 fi
 
+# Check the imagestream
+echo "Running test_mariadb_imagestream"
+test_postgresql_imagestream
+
 OS_TESTSUITE_RESULT=0
 
 ct_os_cluster_down
+
+# vim: set tabstop=2:shiftwidth=2:expandtab:
+
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 447d4bf9..00e82f7d 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -24,7 +24,13 @@ export CT_SKIP_NEW_PROJECT=true
 export CT_SKIP_UPLOAD_IMAGE=true
 export CT_NAMESPACE=openshift
 
-test_postgresql_integration postgresql ${VERSION} "${IMAGE_NAME}"
+# Check the template
+test_postgresql_integration "${IMAGE_NAME}" ${VERSION} postgresql
+
+# Check the imagestream
+test_postgresql_imagestream
 
 OS_TESTSUITE_RESULT=0
 
+# vim: set tabstop=2:shiftwidth=2:expandtab:
+
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 711a8657..280a6e55 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -14,18 +14,28 @@ source ${THISDIR}/test-lib-openshift.sh
 function test_postgresql_integration() {
   local image_name=$1
   local VERSION=$2
-  local import_image=$3
-  local service_name=${import_image##*/}
+  local service_name=$3
+  local image_tagged="${service_name}:${VERSION}"
   ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent
   ct_os_test_template_app_func "${image_name}" \
                                "${t}" \
                                "${service_name}" \
-                               "ct_os_check_cmd_internal '${import_image}' '${service_name}' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
+                               "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
                                "-p POSTGRESQL_VERSION=${VERSION} \
                                 -p DATABASE_SERVICE_NAME="${service_name}-testing" \
                                 -p POSTGRESQL_USER=testu \
                                 -p POSTGRESQL_PASSWORD=testp \
-                                -p POSTGRESQL_DATABASE=testdb" "" "${import_image}"
+                                -p POSTGRESQL_DATABASE=testdb"
+}
+
+# Check the imagestream
+function test_postgresql_imagestream() {
+  case ${OS} in
+    rhel7|centos7) ;;
+    *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
+  esac
+
+  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From 1a5b31c27a576d5f9f60c898c4b85cc1eb26ae25 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 29 May 2020 07:53:48 +0200
Subject: [PATCH 188/509] Enabling verbose bash mode to debug test in CI

---
 test/run-openshift-local-cluster | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index c3c09945..8df23fcd 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -14,7 +14,7 @@ source "$THISDIR"/pg-test-lib.sh
 source "$THISDIR"/test-lib-openshift.sh
 source "$THISDIR"/test-lib-postgresql.sh
 
-set -eo nounset
+set -exo nounset
 
 trap ct_os_cleanup EXIT SIGINT
 

From e71649c7afd7aa5906b7dd500dfcdd208eb6ad95 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 29 May 2020 19:21:53 +0200
Subject: [PATCH 189/509] Simplify tests

---
 common                            |  2 +-
 test/run-openshift-local-cluster  | 16 +++++-----------
 test/run-openshift-remote-cluster |  2 +-
 test/test-lib-postgresql.sh       |  4 +---
 4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/common b/common
index 13285eb9..0df72221 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 13285eb93bbe1ed6fb18a48b2d526f104b9f490e
+Subproject commit 0df72221ddbfdb9adb27a5ac0cbdef346a883ce7
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index 8df23fcd..c2d1456e 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -429,25 +429,19 @@ test_postgresql_configmap_start "$IMAGE_NAME"
 
 # test with the just built image and an integrated template
 echo "Running test_postgresql_integration with ${IMAGE_NAME}"
-test_postgresql_integration "${IMAGE_NAME}" "${VERSION}" postgresql
+test_postgresql_integration "${IMAGE_NAME}"
 
 # test with a released image and an integrated template
-# ignore possible failure of this test for centos images
-fail_not_released=true
-if [ "${OS}" == "rhel7" ] ; then
-  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.redhat.io/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
-else
-  PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
-  fail_not_released=false
-fi
+PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-$(ct_get_public_image_name "${OS}" "${BASE_IMAGE_NAME}" "${VERSION}")}
 
 # Try pulling the image first to see if it is accessible
 if docker pull "${PUBLIC_IMAGE_NAME}"; then
   echo "Running test_postgresql_integration with ${PUBLIC_IMAGE_NAME}"
-  test_postgresql_integration "${PUBLIC_IMAGE_NAME}" "${VERSION}" postgresql
+  test_postgresql_integration "${PUBLIC_IMAGE_NAME}"
 else
   echo "Warning: ${PUBLIC_IMAGE_NAME} could not be downloaded via 'docker'"
-  ! $fail_not_released || false "ERROR: Failed to pull image"
+  # ignore possible failure of this test for centos images
+  [ "${OS}" == "rhel7" ] && false "ERROR: Failed to pull image"
 fi
 
 # Check the imagestream
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 00e82f7d..55d49808 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -25,7 +25,7 @@ export CT_SKIP_UPLOAD_IMAGE=true
 export CT_NAMESPACE=openshift
 
 # Check the template
-test_postgresql_integration "${IMAGE_NAME}" ${VERSION} postgresql
+test_postgresql_integration "${IMAGE_NAME}"
 
 # Check the imagestream
 test_postgresql_imagestream
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 280a6e55..e05af463 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -13,9 +13,7 @@ source ${THISDIR}/test-lib-openshift.sh
 
 function test_postgresql_integration() {
   local image_name=$1
-  local VERSION=$2
-  local service_name=$3
-  local image_tagged="${service_name}:${VERSION}"
+  local service_name=postgresql
   ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent
   ct_os_test_template_app_func "${image_name}" \
                                "${t}" \

From 8fc0c13b3d9416daf4f7faeefd1bd8d86a1d214e Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 3 Jun 2020 10:25:17 +0200
Subject: [PATCH 190/509] Update common dir

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 0df72221..7da1511b 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0df72221ddbfdb9adb27a5ac0cbdef346a883ce7
+Subproject commit 7da1511b547a794f9ee0ae3214ca30dd027dbe09

From c8373f040435e98dfdefabe0784ec781a7145293 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 8 Jun 2020 10:33:39 +0200
Subject: [PATCH 191/509] Update the common sub-module

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 7da1511b..54a44266 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 7da1511b547a794f9ee0ae3214ca30dd027dbe09
+Subproject commit 54a442667db8c24f101569a9dad9a2338a4978a7

From 40da6ca55824c5539e6db38f5ceb16583b4ee603 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 8 Jun 2020 10:38:54 +0200
Subject: [PATCH 192/509] Update the common sub-module

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 54a44266..a1893e65 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 54a442667db8c24f101569a9dad9a2338a4978a7
+Subproject commit a1893e65e3292601c95956c155af7fc96da2d8cd

From 42217d58196bb748226622b35d03a39724a7a41d Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 18 Jun 2020 14:14:57 +0200
Subject: [PATCH 193/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index a1893e65..c0e57430 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a1893e65e3292601c95956c155af7fc96da2d8cd
+Subproject commit c0e5743072a46465918f2dcc1547b82ea9d4b1a5

From 66fe8900ac255623eea412ad369cd80379ff05c7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 18 Jun 2020 14:29:38 +0200
Subject: [PATCH 194/509] Add check for the latest version in imagestreams

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/check_imagestreams.py |  1 +
 test/run_test              | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 120000 test/check_imagestreams.py

diff --git a/test/check_imagestreams.py b/test/check_imagestreams.py
new file mode 120000
index 00000000..48e6cad0
--- /dev/null
+++ b/test/check_imagestreams.py
@@ -0,0 +1 @@
+../common/check_imagestreams.py
\ No newline at end of file
diff --git a/test/run_test b/test/run_test
index 3205c077..a47875e8 100755
--- a/test/run_test
+++ b/test/run_test
@@ -29,6 +29,7 @@ run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 run_pgaudit_test
+run_latest_imagestreams_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -898,6 +899,17 @@ EOSQL"
   grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
 }
 
+function run_latest_imagestreams_test() {
+  local result=1
+  # Switch to root directory of a container
+  echo "Testing the latest version in imagestreams"
+  pushd "${test_dir}/.." >/dev/null || return 1
+  ct_check_latest_imagestreams
+  result=$?
+  popd >/dev/null || return 1
+  return $result
+}
+
 function run_all_tests() {
   for test_case in $TEST_LIST; do
     : "Running test $test_case"

From 157ee287567a7cd02e33d0e823357be2a26691a8 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 19 Jun 2020 15:26:48 +0200
Subject: [PATCH 195/509] Add fix for checking VERSIONS in Makefile

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index c0e57430..9e8688d1 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit c0e5743072a46465918f2dcc1547b82ea9d4b1a5
+Subproject commit 9e8688d13c8bde35a8daaaf026035b66bced4204

From 8ba25885f834786296ffaa8947849633cfeeac08 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Sun, 12 Jul 2020 23:44:56 -0400
Subject: [PATCH 196/509] Add RHEL8 imagestreams

---
 imagestreams/postgresql-rhel8.json | 85 ++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 imagestreams/postgresql-rhel8.json

diff --git a/imagestreams/postgresql-rhel8.json b/imagestreams/postgresql-rhel8.json
new file mode 100644
index 00000000..cebfc04b
--- /dev/null
+++ b/imagestreams/postgresql-rhel8.json
@@ -0,0 +1,85 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "12"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "9.6",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      }
+    ]
+  }
+}

From ae87eaab1ffa33a8d951512c53b3308361da759e Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Tue, 11 Aug 2020 11:44:55 -0400
Subject: [PATCH 197/509] Consolidate RHEL 7 and 8 imagestreams

---
 imagestreams/postgresql-centos7.json       |  64 ++++++++++-
 imagestreams/postgresql-rhel7-ppc64le.json |  98 ++++++++++++++++-
 imagestreams/postgresql-rhel7-s390x.json   |  98 ++++++++++++++++-
 imagestreams/postgresql-rhel7.json         | 118 ++++++++++++++++++++-
 imagestreams/postgresql-rhel8.json         |  85 ---------------
 5 files changed, 360 insertions(+), 103 deletions(-)
 delete mode 100644 imagestreams/postgresql-rhel8.json

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos7.json
index d5e41c5e..ce124f45 100644
--- a/imagestreams/postgresql-centos7.json
+++ b/imagestreams/postgresql-centos7.json
@@ -14,13 +14,31 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL database on CentOS. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12"
+          "name": "12-el7"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-12-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -33,7 +51,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "12"
         },
         "from": {
@@ -44,6 +62,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-10-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "10",
         "annotations": {
@@ -51,7 +87,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "10"
         },
         "from": {
@@ -62,6 +98,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "9.6-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-96-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "9.6",
         "annotations": {
@@ -69,7 +123,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "9.6"
         },
         "from": {
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel7-ppc64le.json
index bd1442c0..2c791d17 100644
--- a/imagestreams/postgresql-rhel7-ppc64le.json
+++ b/imagestreams/postgresql-rhel7-ppc64le.json
@@ -14,13 +14,49 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,ppc64le"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12"
+          "name": "12-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -33,7 +69,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
+          "tags": "database,postgresql,ppc64le,hidden",
           "version": "12"
         },
         "from": {
@@ -44,6 +80,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "10",
         "annotations": {
@@ -51,7 +123,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
+          "tags": "database,postgresql,ppc64le,hidden",
           "version": "10"
         },
         "from": {
@@ -61,6 +133,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "9.6-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,ppc64le",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel7-s390x.json b/imagestreams/postgresql-rhel7-s390x.json
index 059248ac..f721d16f 100644
--- a/imagestreams/postgresql-rhel7-s390x.json
+++ b/imagestreams/postgresql-rhel7-s390x.json
@@ -14,13 +14,49 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql,s390x"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12"
+          "name": "12-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -33,7 +69,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
+          "tags": "database,postgresql,s390x,hidden",
           "version": "12"
         },
         "from": {
@@ -44,6 +80,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "10",
         "annotations": {
@@ -51,7 +123,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
+          "tags": "database,postgresql,s390x,hidden",
           "version": "10"
         },
         "from": {
@@ -61,6 +133,24 @@
         "referencePolicy": {
           "type": "Local"
         }
+      },
+      {
+        "name": "9.6-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,s390x",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel7.json
index b7db687b..2a9aaf4e 100644
--- a/imagestreams/postgresql-rhel7.json
+++ b/imagestreams/postgresql-rhel7.json
@@ -14,13 +14,49 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12"
+          "name": "12-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -33,7 +69,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "12"
         },
         "from": {
@@ -44,6 +80,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "10",
         "annotations": {
@@ -51,7 +123,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "10"
         },
         "from": {
@@ -62,6 +134,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "9.6-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "9.6-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "9.6",
         "annotations": {
@@ -69,7 +177,7 @@
           "openshift.io/provider-display-name": "Red Hat, Inc.",
           "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
+          "tags": "database,postgresql,hidden",
           "version": "9.6"
         },
         "from": {
diff --git a/imagestreams/postgresql-rhel8.json b/imagestreams/postgresql-rhel8.json
deleted file mode 100644
index cebfc04b..00000000
--- a/imagestreams/postgresql-rhel8.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
-  "kind": "ImageStream",
-  "apiVersion": "v1",
-  "metadata": {
-    "name": "postgresql",
-    "annotations": {
-      "openshift.io/display-name": "PostgreSQL"
-    }
-  },
-  "spec": {
-    "tags": [
-      {
-        "name": "latest",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql"
-        },
-        "from": {
-          "kind": "ImageStreamTag",
-          "name": "12"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.6",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      }
-    ]
-  }
-}

From d014aae66cb46ef48c3a2327e2647865d336e649 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Tue, 11 Aug 2020 11:45:07 -0400
Subject: [PATCH 198/509] Unversion imagestreams filenames

---
 imagestreams/{postgresql-centos7.json => postgresql-centos.json}  | 0
 ...postgresql-rhel7-ppc64le.json => postgresql-rhel-ppc64le.json} | 0
 .../{postgresql-rhel7-s390x.json => postgresql-rhel-s390x.json}   | 0
 imagestreams/{postgresql-rhel7.json => postgresql-rhel.json}      | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 rename imagestreams/{postgresql-centos7.json => postgresql-centos.json} (100%)
 rename imagestreams/{postgresql-rhel7-ppc64le.json => postgresql-rhel-ppc64le.json} (100%)
 rename imagestreams/{postgresql-rhel7-s390x.json => postgresql-rhel-s390x.json} (100%)
 rename imagestreams/{postgresql-rhel7.json => postgresql-rhel.json} (100%)

diff --git a/imagestreams/postgresql-centos7.json b/imagestreams/postgresql-centos.json
similarity index 100%
rename from imagestreams/postgresql-centos7.json
rename to imagestreams/postgresql-centos.json
diff --git a/imagestreams/postgresql-rhel7-ppc64le.json b/imagestreams/postgresql-rhel-ppc64le.json
similarity index 100%
rename from imagestreams/postgresql-rhel7-ppc64le.json
rename to imagestreams/postgresql-rhel-ppc64le.json
diff --git a/imagestreams/postgresql-rhel7-s390x.json b/imagestreams/postgresql-rhel-s390x.json
similarity index 100%
rename from imagestreams/postgresql-rhel7-s390x.json
rename to imagestreams/postgresql-rhel-s390x.json
diff --git a/imagestreams/postgresql-rhel7.json b/imagestreams/postgresql-rhel.json
similarity index 100%
rename from imagestreams/postgresql-rhel7.json
rename to imagestreams/postgresql-rhel.json

From 4f894724c0c9ab8f96dbebdf8263ef587145e11f Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Thu, 13 Aug 2020 17:12:02 -0400
Subject: [PATCH 199/509] Fix tests after renaming imagestream files

---
 test/test-lib-postgresql.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index e05af463..599507ff 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -33,7 +33,7 @@ function test_postgresql_imagestream() {
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
 
-  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
+  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From e5bd5601139c61f9f0211dff04f46d7a185cedf3 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 24 Aug 2020 16:51:03 +0200
Subject: [PATCH 200/509] Add CentOS 8 image to the imagestream

---
 common                              |  2 +-
 imagestreams/postgresql-centos.json | 56 ++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/common b/common
index 9e8688d1..2bcb4fc6 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 9e8688d13c8bde35a8daaaf026035b66bced4204
+Subproject commit 2bcb4fc622cf42cb964808e7ebd5ff502c66a64c
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index ce124f45..3e935108 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -20,7 +20,25 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12-el7"
+          "name": "12-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (CentOS 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-12-centos8:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -62,6 +80,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (CentOS 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-10-centos8:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "10-el7",
         "annotations": {
@@ -98,6 +134,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "9.6-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (CentOS 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "docker.io/centos/postgresql-96-centos8:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "9.6-el7",
         "annotations": {

From cbe725b5aa498492620c130020aaf8d4f9504990 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Thu, 27 Aug 2020 23:43:57 -0400
Subject: [PATCH 201/509] Move templates to RHEL/CentOS 8

---
 examples/postgresql-ephemeral-template.json  | 4 ++--
 examples/postgresql-persistent-template.json | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index 0f55830f..dd8d64f1 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -245,8 +245,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (10 or latest).",
-      "value": "10",
+      "description": "Version of PostgreSQL image to be used (10-el7, 10-el8, or latest).",
+      "value": "10-el8",
       "required": true
     }
   ]
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index b6b0455a..5bcab583 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -269,8 +269,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (10 or latest).",
-      "value": "10",
+      "description": "Version of PostgreSQL image to be used (10-el7, 10-el8, or latest).",
+      "value": "10-el8",
       "required": true
     }
   ]

From 1cf767734507d19e12fa748fdfca57aca0e20d8c Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Wed, 2 Sep 2020 11:55:07 -0400
Subject: [PATCH 202/509] Add aarch64 imagestreams

---
 imagestreams/postgresql-rhel-aarch64.json | 85 +++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 imagestreams/postgresql-rhel-aarch64.json

diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
new file mode 100644
index 00000000..5991f962
--- /dev/null
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -0,0 +1,85 @@
+{
+  "kind": "ImageStream",
+  "apiVersion": "v1",
+  "metadata": {
+    "name": "postgresql",
+    "annotations": {
+      "openshift.io/display-name": "PostgreSQL"
+    }
+  },
+  "spec": {
+    "tags": [
+      {
+        "name": "latest",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql"
+        },
+        "from": {
+          "kind": "ImageStreamTag",
+          "name": "12-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "12-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "12"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "9.6-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "9.6"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      }
+    ]
+  }
+}

From a5c922701a6bfe5507b1c8c7ba4b2237029d34e4 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 15 Sep 2020 17:24:09 +0200
Subject: [PATCH 203/509] Remove streams that will be soon EOL.

With no el7 based 9.6 stream, we do not need a separate imagestream for ppc64le and s390x eiter.
---
 imagestreams/postgresql-centos.json       |  36 -----
 imagestreams/postgresql-rhel-ppc64le.json | 157 ----------------------
 imagestreams/postgresql-rhel-s390x.json   | 157 ----------------------
 imagestreams/postgresql-rhel.json         |  36 -----
 4 files changed, 386 deletions(-)
 delete mode 100644 imagestreams/postgresql-rhel-ppc64le.json
 delete mode 100644 imagestreams/postgresql-rhel-s390x.json

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 3e935108..bb7057f6 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -151,42 +151,6 @@
         "referencePolicy": {
           "type": "Local"
         }
-      },
-      {
-        "name": "9.6-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (CentOS 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-96-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.6",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-96-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel-ppc64le.json b/imagestreams/postgresql-rhel-ppc64le.json
deleted file mode 100644
index 2c791d17..00000000
--- a/imagestreams/postgresql-rhel-ppc64le.json
+++ /dev/null
@@ -1,157 +0,0 @@
-{
-  "kind": "ImageStream",
-  "apiVersion": "v1",
-  "metadata": {
-    "name": "postgresql",
-    "annotations": {
-      "openshift.io/display-name": "PostgreSQL"
-    }
-  },
-  "spec": {
-    "tags": [
-      {
-        "name": "latest",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le"
-        },
-        "from": {
-          "kind": "ImageStreamTag",
-          "name": "12-el8"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le,hidden",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le,hidden",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.6-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,ppc64le",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      }
-    ]
-  }
-}
diff --git a/imagestreams/postgresql-rhel-s390x.json b/imagestreams/postgresql-rhel-s390x.json
deleted file mode 100644
index f721d16f..00000000
--- a/imagestreams/postgresql-rhel-s390x.json
+++ /dev/null
@@ -1,157 +0,0 @@
-{
-  "kind": "ImageStream",
-  "apiVersion": "v1",
-  "metadata": {
-    "name": "postgresql",
-    "annotations": {
-      "openshift.io/display-name": "PostgreSQL"
-    }
-  },
-  "spec": {
-    "tags": [
-      {
-        "name": "latest",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x"
-        },
-        "from": {
-          "kind": "ImageStreamTag",
-          "name": "12-el8"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x,hidden",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x,hidden",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.6-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,s390x",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      }
-    ]
-  }
-}
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 2a9aaf4e..5cddfaa2 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -151,42 +151,6 @@
         "referencePolicy": {
           "type": "Local"
         }
-      },
-      {
-        "name": "9.6-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "9.6",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 9.6",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-96-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
       }
     ]
   }

From 0812291b48aba31e4329cadd3bb5c5c00905b92a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 12 Nov 2020 17:59:10 +0100
Subject: [PATCH 204/509] Deprecate version 9.6 which is EOL

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile  |  2 +-
 README.md | 11 ++++-------
 common    |  2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 14ddf7e5..669484bd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.6 10 11 12
+VERSIONS = 10 11 12
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index 83722c29..f659ac7b 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,6 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently supported are:
-* [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
 
@@ -77,9 +76,6 @@ In this repository [distgen](https://github.com/devexp-db/distgen/) is used for
 Usage
 ---------------------------------
 
-For information about usage of Dockerfile for PostgreSQL 9.6,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
-
 For information about usage of Dockerfile for PostgreSQL 10,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
 
@@ -87,9 +83,10 @@ For information about usage of Dockerfile for PostgreSQL 12,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/12).
 
 For versions which are not supported anymore:
-[PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
-and
-[PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4).
+
+* [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
+* [PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4)
+* [PostgreSQL 9.6](https://github.com/sclorg/postgresql-container/tree/139dafa9/9.6)
 
 Test
 ---------------------------------
diff --git a/common b/common
index 2bcb4fc6..23c6c9d2 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2bcb4fc622cf42cb964808e7ebd5ff502c66a64c
+Subproject commit 23c6c9d2af4ef509000a2740ac3817e256e6e6a8

From 75a7f02eb8931025784b9f63dd0d17ee489aa49f Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 19 Nov 2020 08:50:51 +0100
Subject: [PATCH 205/509] Move test latest_imagestreams into openshift tests
 (#390)

* Move test latest_imagestreams into openshift tests

Update container-common-scripts into the latest

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>

* Fix test suite

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common                           |  2 +-
 test/run-openshift-local-cluster | 36 +++++++++++++++++++++-----------
 test/run_test                    | 12 -----------
 test/test-lib-postgresql.sh      |  2 +-
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/common b/common
index 2bcb4fc6..23c6c9d2 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2bcb4fc622cf42cb964808e7ebd5ff502c66a64c
+Subproject commit 23c6c9d2af4ef509000a2740ac3817e256e6e6a8
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index c2d1456e..b59aeb0c 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -118,14 +118,13 @@ function check_postgresql_os_service_connection() {
 function test_postgresql_pure_image() {
   local image_name=$1
   local image_name_no_namespace=${image_name##*/}
-  local service_name=${image_name_no_namespace}
+  local service_name="${image_name_no_namespace%%:*}-testing"
 
   ct_os_new_project
-  ct_os_upload_image "${image_name}"
   # Create a specific imagestream tag for the image so that oc cannot use anything else
-  ct_os_upload_image "${image_name}" "$image_name_no_namespace:testing"
+  ct_os_upload_image "${image_name}" "$image_name_no_namespace"
 
-  ct_os_deploy_pure_image "$image_name_no_namespace:testing" \
+  ct_os_deploy_pure_image "$image_name_no_namespace" \
                           --name "${service_name}" \
                           --env POSTGRESQL_ADMIN_PASSWORD=test
 
@@ -139,7 +138,7 @@ function test_postgresql_template() {
   local image_name=$1; shift
   local template=$1
   local image_name_no_namespace=${image_name##*/}
-  local service_name=${image_name_no_namespace}
+  local service_name="${image_name_no_namespace%%:*}-testing"
 
   ct_os_new_project
   ct_os_upload_image "${image_name}" "postgresql:$VERSION"
@@ -161,8 +160,8 @@ function test_postgresql_template() {
 function test_postgresql_update() {
   local image_name=$1; shift
   local template=$1
-  local image_name_no_registry=${image_name#*/}
-  local service_name=${image_name_no_registry#*/}
+  local image_name_no_registry=${image_name##*/}
+  local service_name="${image_name_no_registry%%:*}-testing"
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip=""
   local version released=:
@@ -219,8 +218,8 @@ function test_postgresql_update() {
 function test_postgresql_replication() {
   local image_name=$1
   local image_name_no_namespace=${image_name##*/}
-  local master_service_name=${image_name_no_namespace}-master
-  local slave_service_name=${image_name_no_namespace}-slave
+  local master_service_name="${image_name_no_namespace%%:*}-master"
+  local slave_service_name="${image_name_no_namespace%%:*}-slave"
   local istag="postgresql:$VERSION"
   local user="testu" pass="testp" db="testdb"
   local master_name="" master_ip="" slave_name="" slave_ip=""
@@ -289,7 +288,7 @@ function test_postgresql_persistent_redeploy() {
   local image_name=$1; shift
   local template=$1
   local image_name_no_namespace=${image_name##*/}
-  local service_name=$image_name_no_namespace
+  local service_name="${image_name_no_namespace%%:*}-testing"
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip=""
 
@@ -327,7 +326,7 @@ function test_postgresql_ephemeral_redeploy() {
   local image_name=$1; shift
   local template=$1
   local image_name_no_namespace=${image_name##*/}
-  local service_name=$image_name_no_namespace
+  local service_name="${image_name_no_namespace%%:*}-testing"
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip=""
 
@@ -365,7 +364,7 @@ function test_postgresql_configmap_start() {
   local image_name=$1; shift
   local template="$TEMPLATES/postgresql-ephemeral-template.json"
   local image_name_no_namespace=${image_name##*/}
-  local service_name=$image_name_no_namespace
+  local service_name="${image_name_no_namespace%%:*}-testing"
   local user="testu" pass="testp" db="testdb"
   local registry="" old_image="" pod_ip="" tmpdir=""
   local test_string=""
@@ -448,6 +447,19 @@ fi
 echo "Running test_mariadb_imagestream"
 test_postgresql_imagestream
 
+function run_latest_imagestreams_test() {
+  local result=1
+  # Switch to root directory of a container
+  echo "Testing the latest version in imagestreams"
+  pushd "${test_dir}/.." >/dev/null || return 1
+  ct_check_latest_imagestreams
+  result=$?
+  popd >/dev/null || return 1
+  return $result
+}
+
+run_latest_imagestreams_test
+
 OS_TESTSUITE_RESULT=0
 
 ct_os_cluster_down
diff --git a/test/run_test b/test/run_test
index a47875e8..3205c077 100755
--- a/test/run_test
+++ b/test/run_test
@@ -29,7 +29,6 @@ run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 run_pgaudit_test
-run_latest_imagestreams_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -899,17 +898,6 @@ EOSQL"
   grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
 }
 
-function run_latest_imagestreams_test() {
-  local result=1
-  # Switch to root directory of a container
-  echo "Testing the latest version in imagestreams"
-  pushd "${test_dir}/.." >/dev/null || return 1
-  ct_check_latest_imagestreams
-  result=$?
-  popd >/dev/null || return 1
-  return $result
-}
-
 function run_all_tests() {
   for test_case in $TEST_LIST; do
     : "Running test $test_case"
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 599507ff..8885e93e 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -33,7 +33,7 @@ function test_postgresql_imagestream() {
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
 
-  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
+  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From 204f8285c64c22a7e1ed1c7ab32820ac74dc7579 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 11 Dec 2020 10:10:31 +0100
Subject: [PATCH 206/509] Support Quay.io registry

This pull request supports building image on Quay.io instead of
Docker.io.
This is caused by introducing Docker.io rate limits.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 README.md                                                 | 2 ++
 imagestreams/postgresql-centos.json                       | 8 ++++----
 specs/multispec.yml                                       | 6 +++---
 src/root/usr/share/container-scripts/postgresql/README.md | 6 +++---
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index f659ac7b..c3b762ee 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 PostgreSQL container images
 ========================
 
+PostgreSQL 10 status:[![Docker Repository on Quay](https://quay.io/repository/centos7/postgresql-10-centos7/status "Docker Repository on Quay")](https://quay.io/repository/centos7/postgresql-10-centos7), PostgreSQL 12 status:[![Docker Repository on Quay](https://quay.io/repository/centos7/postgresql-12-centos7/status "Docker Repository on Quay")](https://quay.io/repository/centos7/postgresql-12-centos7)
+
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.
 
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index bb7057f6..c0438dbc 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -56,7 +56,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-12-centos7:latest"
+          "name": "quay.io/centos7/postgresql-12-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -74,7 +74,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-12-centos7:latest"
+          "name": "quay.io/centos7/postgresql-12-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -110,7 +110,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-10-centos7:latest"
+          "name": "quay.io/centos7/postgresql-10-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -128,7 +128,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-10-centos7:latest"
+          "name": "quay.io/centos7/postgresql-10-centos7:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 624db016..adfe0cee 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -5,13 +5,13 @@ specs:
     centos:
       distros:
         - centos-7-x86_64
-      s2i_base: centos/s2i-core-centos7
-      org: "centos"
+      s2i_base: quay.io/centos7/s2i-core-centos7
+      org: "centos7"
       prod: "centos7"
       openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
       redhat_component: "rh-postgresql{{ spec.short }}-container"
       enabled_collection: "rh-postgresql{{ spec.short }}"
-      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      img_name: "quay.io/{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
       repo_enable_reason: ""
       environment_setup: yum install -y centos-release-scl-rh && \
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index ea0a6428..bc01aa9f 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -4,7 +4,7 @@ PostgreSQL {{ spec.version }} SQL Database Server container image
 This container image includes PostgreSQL {{ spec.version }} SQL database server for OpenShift and general usage.
 Users can choose between RHEL, CentOS and Fedora based images.
 The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Docker Hub](https://hub.docker.com/r/centos/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
 and the Fedora images are available in [Fedora Registry](https://registry.fedoraproject.org/).
 The resulting image can be run using [podman](https://github.com/containers/libpod).
 
@@ -123,7 +123,7 @@ $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 
 
 Data migration
-----------------------
+--------------
 
 PostgreSQL container supports migration of data from remote PostgreSQL server.
 You can run it like:
@@ -173,7 +173,7 @@ clusters is not encrypted by default, it is up to user to configure SSL on
 remote cluster or ensure security via different means.
 
 PostgreSQL auto-tuning
---------------------
+----------------------
 
 When the PostgreSQL image is run with the `--memory` parameter set and if there
 are no values provided for `POSTGRESQL_SHARED_BUFFERS` and

From 8de34fdc27fda3202525b8e15d5ce8e70613c719 Mon Sep 17 00:00:00 2001
From: Michael Scherer <misc@redhat.com>
Date: Thu, 11 Feb 2021 23:51:42 +0100
Subject: [PATCH 207/509] Update Fedora container to F33

---
 specs/multispec.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index adfe0cee..ccf1125d 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -96,7 +96,7 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos/postgresql-{{ spec.short }}-centos7"
       cccp_job: "postgresql-{{ spec.short }}-centos7"
-      latest_fedora: "f32"
+      latest_fedora: "f33"
 
 matrix:
   exclude:

From e1bb8da6e0111b9b622e27faeb6a640ad4abc331 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 22 Feb 2021 11:23:42 +0100
Subject: [PATCH 208/509] update container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 23c6c9d2..9aba9033 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 23c6c9d2af4ef509000a2740ac3817e256e6e6a8
+Subproject commit 9aba9033d02a4d25aff53a17f7236446e239b3c5

From 3525b011dd8e44e081cdfb7b55aa12719eeae5b7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 22 Feb 2021 11:25:58 +0100
Subject: [PATCH 209/509] Deprecate imagestream 10 for RHEL7 and CentOS7.

The images are going to be EOL soon.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/postgresql-centos.json | 36 -----------------------------
 imagestreams/postgresql-rhel.json   | 36 -----------------------------
 2 files changed, 72 deletions(-)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index c0438dbc..eb7c4368 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -98,42 +98,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "10-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (CentOS 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-10-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-10-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "9.6-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 5cddfaa2..ebb2d2f0 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -98,42 +98,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "10-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "10",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "9.6-el8",
         "annotations": {

From 8ab45b653d09d0f29855f32f7e1e9d9feaa4c0fd Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 12 Apr 2021 10:29:41 +0200
Subject: [PATCH 210/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 9aba9033..44540537 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 9aba9033d02a4d25aff53a17f7236446e239b3c5
+Subproject commit 445405372b8188e1739e00584ec8f50cdc4eab51

From 1629211259210174b3e1cf96223e02886906a317 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 12 Apr 2021 11:46:08 +0200
Subject: [PATCH 211/509] Fix pushing postgresql images into Quay.io

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 specs/multispec.yml | 6 +++---
 test/pg-test-lib.sh | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index ccf1125d..549fdf83 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -11,7 +11,7 @@ specs:
       openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
       redhat_component: "rh-postgresql{{ spec.short }}-container"
       enabled_collection: "rh-postgresql{{ spec.short }}"
-      img_name: "quay.io/{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
       repo_enable_reason: ""
       environment_setup: yum install -y centos-release-scl-rh && \
@@ -74,7 +74,7 @@ specs:
       prev_short: "96"
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
-      centos_image_name: "centos/postgresql-10-centos7"
+      centos_image_name: "centos7/postgresql-10-centos7"
       cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
 
@@ -94,7 +94,7 @@ specs:
       prev_short: "10"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
-      centos_image_name: "centos/postgresql-{{ spec.short }}-centos7"
+      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f33"
 
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 70bea018..76d9ced7 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -29,11 +29,11 @@ get_image_id ()
                 image=registry.redhat.io/$ns/postgresql-${version}-rhel7
                 ;;
             centos7)
-                ns=centos
+                ns=centos7
                 if test "$version" -eq 92; then
                     ns=openshift
                 fi
-                local image=docker.io/$ns/postgresql-${1//\./}-centos7
+                local image=quay.io/$ns/postgresql-${1//\./}-centos7
                 ;;
             rhel8)
                 ns=rhel8

From 423156585d87bdc08a4c383c3132d69def4ff673 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 28 Apr 2021 11:12:46 +0200
Subject: [PATCH 212/509] Revert "Deprecate imagestream 10 for RHEL7 and
 CentOS7."

This reverts commit 3525b011dd8e44e081cdfb7b55aa12719eeae5b7.

SCL rh-postgresql10 lifecycle is about to be extended.
---
 imagestreams/postgresql-centos.json | 36 +++++++++++++++++++++++++++++
 imagestreams/postgresql-rhel.json   | 36 +++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index eb7c4368..c0438dbc 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -98,6 +98,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/centos7/postgresql-10-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,hidden",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/centos7/postgresql-10-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "9.6-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index ebb2d2f0..5cddfaa2 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -98,6 +98,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "10-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql,hidden",
+          "version": "10"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "9.6-el8",
         "annotations": {

From c2325d68d665207c6cf45bda1798cf979b43a41a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 16 Mar 2021 14:08:54 +0100
Subject: [PATCH 213/509] Support testing postgresql-container under OpenShift
 4

To test it just write a comment into PR in format
`[test-openshift-4]`.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-remote-cluster | 7 ++++---
 test/test-lib-postgresql.sh       | 7 ++++---
 test/test-lib-remote-openshift.sh | 1 +
 3 files changed, 9 insertions(+), 6 deletions(-)
 create mode 120000 test/test-lib-remote-openshift.sh

diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 55d49808..00d0f555 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -16,13 +16,14 @@ set -eo nounset
 
 trap ct_os_cleanup EXIT SIGINT
 
+ct_os_set_ocp4
+
 ct_os_check_compulsory_vars
 
 oc status || false "It looks like oc is not properly logged in."
 
-export CT_SKIP_NEW_PROJECT=true
-export CT_SKIP_UPLOAD_IMAGE=true
-export CT_NAMESPACE=openshift
+# For testing on OpenShift 4 we use external registry
+export CT_EXTERNAL_REGISTRY=true
 
 # Check the template
 test_postgresql_integration "${IMAGE_NAME}"
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 8885e93e..e725fc00 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -8,8 +8,9 @@
 
 THISDIR=$(dirname ${BASH_SOURCE[0]})
 
-source ${THISDIR}/test-lib.sh
-source ${THISDIR}/test-lib-openshift.sh
+source "${THISDIR}"/test-lib.sh
+source "${THISDIR}"/test-lib-openshift.sh
+source "${THISDIR}"/test-lib-remote-openshift.sh
 
 function test_postgresql_integration() {
   local image_name=$1
@@ -33,7 +34,7 @@ function test_postgresql_imagestream() {
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
 
-  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
+  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:
diff --git a/test/test-lib-remote-openshift.sh b/test/test-lib-remote-openshift.sh
new file mode 120000
index 00000000..15003d84
--- /dev/null
+++ b/test/test-lib-remote-openshift.sh
@@ -0,0 +1 @@
+../common/test-lib-remote-openshift.sh
\ No newline at end of file

From 103c459b3554720f3b13cd4f07be585e44fe15e7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 23 Apr 2021 12:37:43 +0200
Subject: [PATCH 214/509] Add 10/.exclude-openshift to Makefile. Skip tests for
 ver 10

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index 669484bd..620c8694 100644
--- a/Makefile
+++ b/Makefile
@@ -20,4 +20,6 @@ upgrade-tests: $(VERSIONS)
 	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local
 
 build-serial: generate
+	# Version 10 reached EOL in RHEL do not test in openshift
+	touch 10/.exclude-openshift
 test-openshift-remote-cluster: generate

From 636fa454e128f0fb6998824c6337c61f2e3ff6da Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 26 Apr 2021 10:14:06 +0200
Subject: [PATCH 215/509] Update container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 44540537..f20bf178 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 445405372b8188e1739e00584ec8f50cdc4eab51
+Subproject commit f20bf1787d5c3c63da281118e3822c5ff20b0053

From 944041101fead16f6f84775d3ab2f255893c920b Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 7 May 2021 11:07:54 +0200
Subject: [PATCH 216/509] postgresql-10 was extended

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 620c8694..d260026b 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,5 @@ upgrade-tests: $(VERSIONS)
 	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local
 
 build-serial: generate
-	# Version 10 reached EOL in RHEL do not test in openshift
-	touch 10/.exclude-openshift
+
 test-openshift-remote-cluster: generate

From e7d0e0ecd60b64edaeafbbbad109c7b816a4ebc5 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Wed, 19 May 2021 21:23:51 -0400
Subject: [PATCH 217/509] Update imagestreams for RHEL 8.4

---
 imagestreams/postgresql-rhel-aarch64.json | 20 +++++++++++++++++++-
 imagestreams/postgresql-rhel.json         | 20 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 5991f962..132283bc 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -20,7 +20,25 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12-el8"
+          "name": "13-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "13-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-13:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 5cddfaa2..b59d509a 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -20,7 +20,25 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12-el8"
+          "name": "13-el8"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "13-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-13:latest"
         },
         "referencePolicy": {
           "type": "Local"

From 506abcdcd81a39a0262c534f38315ea2e52cbc15 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 7 Jun 2021 10:59:12 +0200
Subject: [PATCH 218/509] Add PostgreSQL 13 SCL (rhel-7) image

---
 imagestreams/postgresql-rhel.json | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index b59d509a..dc4b8161 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -62,6 +62,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "12-el7",
         "annotations": {

From 8ed0efc293d54ff888e991ac08d36944377b0eef Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 22 Jun 2021 12:56:08 +0200
Subject: [PATCH 219/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index f20bf178..2869270a 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit f20bf1787d5c3c63da281118e3822c5ff20b0053
+Subproject commit 2869270a2c36924d76dd34eef9a91623005a7596

From 7f95106f61c21410ad2a8b9329c7a8b2834199fc Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 22 Jun 2021 12:57:24 +0200
Subject: [PATCH 220/509] Add support postgresql-13

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile            |  2 +-
 README.md           | 20 ++++++++++++--------
 specs/multispec.yml | 20 ++++++++++++++++++++
 src/Dockerfile      |  6 +++++-
 test/run_test       |  6 +++---
 5 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index d260026b..a1904360 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 11 12
+VERSIONS = 10 11 12 13
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index c3b762ee..4a27ab8f 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,7 @@ Versions
 PostgreSQL versions currently supported are:
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
+* [postgresql-13](https://github.com/sclorg/postgresql-container/tree/generated/13)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -34,10 +35,10 @@ Choose either the CentOS7 or RHEL7 based image:
 
 *  **RHEL7 based image**
 
-    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-12-rhel7).
+    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-13-rhel7).
     To download it run:
     ```
-    podman pull registry.redhat.io/rhscl/postgresql-12-rhel7
+    podman pull registry.redhat.io/rhscl/postgresql-13-rhel7
     ```
 
     To build a RHEL7 based image, you need to run Docker build on a properly
@@ -46,7 +47,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONS=12
+    $ make build TARGET=rhel7 VERSIONS=13
     ```
 
 *  **CentOS7 based image**
@@ -54,7 +55,7 @@ Choose either the CentOS7 or RHEL7 based image:
     These images are available on DockerHub. To download it run:
 
     ```
-    $ podman pull centos/postgresql-12-centos7
+    $ podman pull centos/postgresql-13-centos7
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -62,7 +63,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSIONS=12
+    $ make build TARGET=centos7 VERSIONS=13
     ```
 
 Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments.
@@ -84,6 +85,9 @@ see [usage documentation](https://github.com/sclorg/postgresql-container/tree/ge
 For information about usage of Dockerfile for PostgreSQL 12,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/12).
 
+For information about usage of Dockerfile for PostgreSQL 13,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/13).
+
 For versions which are not supported anymore:
 
 * [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
@@ -105,19 +109,19 @@ Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSIONS=12
+    $ make test TARGET=rhel7 VERSIONS=13
     ```
 
 *  **CentOS based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSIONS=12
+    $ make test TARGET=centos7 VERSIONS=13
     ```
 +By using the `TESTS` parameter you can choose a test case subset to be run against the image, eg:
 
     $ cd postgresql
-    $ make test VERSIONS=12 TESTS="run_general_tests run_replication_test"
+    $ make test VERSIONS=13 TESTS="run_general_tests run_replication_test"
 
 
 **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 549fdf83..1864a9fe 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -54,6 +54,7 @@ specs:
     fedora:
       distros:
         - fedora-31-x86_64
+        - fedora-34-x86_64
 
   version:
     "9.6":
@@ -98,19 +99,38 @@ specs:
       cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f33"
 
+    "13":
+      version: "13"
+      prev_version: "12"
+      short: "13"
+      prev_short: "12"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
+      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
+      cccp_job: "postgresql-{{ spec.short }}-centos7"
+      latest_fedora: "f34"
+
+
 matrix:
   exclude:
     - distros:
         - fedora-31-x86_64
+        - fedora-34-x86_64
       version: "9.6"
     - distros:
         - fedora-31-x86_64
+        - fedora-34-x86_64
       version: "10"
     - distros:
         - rhel-7-x86_64
         - rhel-8-x86_64
         - centos-7-x86_64
+        - fedora-34-x86_64
       version: "11"
     - distros:
         - rhel-8-x86_64
+        - fedora-34-x86_64
       version: "12"
+    - distros:
+        - fedora-31-x86_64
+      version: "13"
diff --git a/src/Dockerfile b/src/Dockerfile
index 5fff7a45..95d8dac2 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -70,8 +70,12 @@ RUN {{ spec.environment_setup }}
   {% endif %}
 {% endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
-{% if spec.version in ["12"] %}
+{% if spec.version not in ["9.6", "10", "11"] %}
+    {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
+    {% elif spec.prod == 'rhel8' %}
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    {% endif %}
 {% endif %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/test/run_test b/test/run_test
index 3205c077..14860eae 100755
--- a/test/run_test
+++ b/test/run_test
@@ -654,7 +654,7 @@ run_upgrade_test ()
     # is fixed for non-SCL use cases
     { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -676,9 +676,9 @@ run_migration_test ()
     local from_version
     # Only test a subset of the migration path on non-intel hosts
     if [ "$(uname -i)" == "x86_64" ]; then
-        local upgrade_path="9.2 9.4 9.5 9.6 10 12"
+        local upgrade_path="9.2 9.4 9.5 9.6 10 12 13"
     else
-        local upgrade_path="10 12"
+        local upgrade_path="10 12 13"
     fi
 
     for from_version in $upgrade_path; do

From 7e8c3fcfc81a128feb12a7f3c0db6b04ff4313d8 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 22 Jun 2021 12:57:50 +0200
Subject: [PATCH 221/509] Fixes for postgresql-13 caused by new version

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.sh                                                | 7 ++++---
 .../openshift-custom-postgresql-replication.conf.template  | 4 ++++
 test/test-lib-postgresql.sh                                | 7 +++++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/manifest.sh b/manifest.sh
index f93f4b3b..8270dba2 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -20,6 +20,10 @@ DISTGEN_RULES="
 
     src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
     dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
+
+    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template;
+
 "
 
 # Files containing distgen directives, which are used for each
@@ -59,9 +63,6 @@ COPY_RULES="
     src=src/content_sets.yml
     dest=content_sets.yml;
 
-    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
-    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template;
-
     src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
     dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template;
 
diff --git a/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
index ef04eaae..30842001 100644
--- a/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ b/src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -1,7 +1,11 @@
 # required on master for replication
 wal_level = hot_standby         # minimal, archive, hot_standby, or logical
 max_wal_senders = 6             # max number of walsender processes
+{% if spec.version in ["9.6", "10", "11", "12"] %}
 wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+{% else %}
+wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
+{% endif %}
 
 # required on replicas for replication
 hot_standby = on
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index e725fc00..ac0acba0 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -33,8 +33,11 @@ function test_postgresql_imagestream() {
     rhel7|centos7) ;;
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
-
-  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
+  local tag="-el7"
+  if [ x"${OS}" == "rhel8" ]; then
+    tag="-el8"
+  fi
+  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From 62c8fae637bc862e880955a42e5774fd562c02d2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 14 Jul 2021 12:26:03 +0200
Subject: [PATCH 222/509] Add support for Testing Farm for postgresql_container

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .../workflows/centos7-openshift-tests.yaml    | 188 +++++++++++++++++
 .github/workflows/centos7-tests.yaml          | 188 +++++++++++++++++
 .github/workflows/fedora-tests.yaml           | 189 ++++++++++++++++++
 3 files changed, 565 insertions(+)
 create mode 100644 .github/workflows/centos7-openshift-tests.yaml
 create mode 100644 .github/workflows/centos7-tests.yaml
 create mode 100644 .github/workflows/fedora-tests.yaml

diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/centos7-openshift-tests.yaml
new file mode 100644
index 00000000..25991dfc
--- /dev/null
+++ b/.github/workflows/centos7-openshift-tests.yaml
@@ -0,0 +1,188 @@
+name: CentOS7-openshift-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for CentOS7 - Openshift
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && github.event.comment.body == '[test]'
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - CentOS7 - OpenShift 3",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm forn CentOS7 - OpenShift 3
+        id: sched_test
+        run: |
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://github.com/sclorg/sclorg-testing-farm",
+              "ref": "main"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "CentOS-7"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "centos7",
+                "TEST_NAME": "test-openshift"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+#      - name: Add comment with Testing Farm request/result
+#        # This step adds a new comment to the pull request with a link to the test.
+#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
+#        id: comment
+#        uses: peter-evans/create-or-update-comment@v1
+#        if: always()
+#        with:
+#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
+#          body: |
+#            Testing Farm - CentOS 7 [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.req_id }})
+#            for CentOS 7 test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
+#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log)
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          apt update && apt -y install curl jq
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request
+        id: running
+        run: |
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - CentOS7 - OpenShift 3",
+            "description": "Build started",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
+          }
+          EOF
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - CentOS7 - OpenShift 3",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
+          }
+          EOF
+          cat final.json
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json
diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/centos7-tests.yaml
new file mode 100644
index 00000000..20127997
--- /dev/null
+++ b/.github/workflows/centos7-tests.yaml
@@ -0,0 +1,188 @@
+name: CentOS7-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for CentOS7
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && github.event.comment.body == '[test]'
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - CentOS7",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm
+        id: sched_test
+        run: |
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://github.com/sclorg/sclorg-testing-farm",
+              "ref": "main"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "CentOS-7"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "centos7",
+                "TEST_NAME": "test"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+#      - name: Add comment with Testing Farm request/result
+#        # This step adds a new comment to the pull request with a link to the test.
+#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
+#        id: comment
+#        uses: peter-evans/create-or-update-comment@v1
+#        if: always()
+#        with:
+#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
+#          body: |
+#            Testing Farm - CentOS 7 [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.req_id }})
+#            for CentOS 7 test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
+#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log)
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          apt update && apt -y install curl jq
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request
+        id: running
+        run: |
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - CentOS7",
+            "description": "Build started",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
+          }
+          EOF
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - CentOS7",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
+          }
+          EOF
+          cat final.json
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json
diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml
new file mode 100644
index 00000000..72ece893
--- /dev/null
+++ b/.github/workflows/fedora-tests.yaml
@@ -0,0 +1,189 @@
+name: Fedora-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for Fedora
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && github.event.comment.body == '[test]'
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - Fedora"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm
+        id: sched_test
+        run: |
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://github.com/sclorg/sclorg-testing-farm",
+              "ref": "main"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "CentOS-7"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "fedora",
+                "TEST_NAME": "test"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+#      - name: Add comment with Testing Farm request/result
+#        # This step adds a new comment to the pull request with a link to the test.
+#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
+#        id: comment
+#        uses: peter-evans/create-or-update-comment@v1
+#        if: always()
+#        with:
+#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
+#          body: |
+#            Testing Farm - Fedora [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.REQ_ID }})
+#            for Fedora test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
+#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.REQ_ID }}/pipeline.log)
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          apt update && apt -y install curl jq
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request
+        id: running
+        run: |
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - Fedora",
+            "description": "Build started",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
+          }
+          EOF
+          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            sleep 30
+            curl $CMD > job.json
+            cat job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - Fedora",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
+          }
+          EOF
+          cat final.json
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json

From fb0779cc6bc266b011d0d2f2fd5dd414554ae024 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 22 Jul 2021 09:32:36 +0200
Subject: [PATCH 223/509] Add more comments and react on test in case contains
 [test]

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .../workflows/centos7-openshift-tests.yaml    | 34 ++++++++-------
 .github/workflows/centos7-tests.yaml          | 34 ++++++++-------
 .github/workflows/fedora-tests.yaml           | 41 ++++++++++---------
 3 files changed, 60 insertions(+), 49 deletions(-)

diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/centos7-openshift-tests.yaml
index 25991dfc..5e10a5c5 100644
--- a/.github/workflows/centos7-openshift-tests.yaml
+++ b/.github/workflows/centos7-openshift-tests.yaml
@@ -7,11 +7,11 @@ on:
 jobs:
   build:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for CentOS7 - Openshift
+    name: Schedule test on Testing Farm service for CentOS7 - OpenShift 3
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && github.event.comment.body == '[test]'
+      && contains(github.event.comment.body, '[test-openshift]')
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
@@ -31,6 +31,7 @@ jobs:
       - name: Get sha
         id: sha
         run: |
+          # Store SHA into outputs
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
       - name: Create status check to pending
@@ -38,6 +39,7 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
           cat << EOF > pending.json
           {
             "sha": "${{steps.sha.outputs.SHA}}",
@@ -47,6 +49,8 @@ jobs:
           }
           EOF
           echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
           curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
             --data @pending.json
@@ -55,6 +59,7 @@ jobs:
       - name: Schedule a test on Testing Farm forn CentOS7 - OpenShift 3
         id: sched_test
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
           apt update && apt -y install curl jq
           cat << EOF > request.json
           {
@@ -77,21 +82,9 @@ jobs:
           }
           EOF
           curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
           echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
 
-#      - name: Add comment with Testing Farm request/result
-#        # This step adds a new comment to the pull request with a link to the test.
-#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
-#        id: comment
-#        uses: peter-evans/create-or-update-comment@v1
-#        if: always()
-#        with:
-#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
-#          body: |
-#            Testing Farm - CentOS 7 [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.req_id }})
-#            for CentOS 7 test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
-#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log)
-
   running:
     needs: build
     name: Check running tests on Testing Farm service
@@ -104,13 +97,17 @@ jobs:
       - name: Check if REQ_ID and SHA exists
         id: req_sha
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
           echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
           echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
 
       - name: Switch to running state of Testing Farm request
         id: running
         run: |
+          # Create running.json file for query, whether job is finished or not.
           cat << EOF > running.json
           {
             "sha": "${{needs.build.outputs.SHA}}",
@@ -120,6 +117,7 @@ jobs:
             "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
           }
           EOF
+          # Update GitHub status description to 'Build started'
           curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
             --data @running.json
@@ -130,7 +128,9 @@ jobs:
           CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
           curl $CMD > job.json
           state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
           while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
             sleep 30
             curl $CMD > job.json
             state=$(jq -r .state job.json)
@@ -150,6 +150,8 @@ jobs:
       - name: Get final state of Testing Farm request
         id: final_state
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
           curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
           cat job.json
@@ -163,6 +165,7 @@ jobs:
               new_state="failure"
             fi
           else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
             infra_error=" - Infra problems"
             new_state="failure"
           fi
@@ -183,6 +186,7 @@ jobs:
           }
           EOF
           cat final.json
+          # Switch Github status to proper state
           curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
             --data @final.json
diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/centos7-tests.yaml
index 20127997..982956de 100644
--- a/.github/workflows/centos7-tests.yaml
+++ b/.github/workflows/centos7-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && github.event.comment.body == '[test]'
+      && contains(github.event.comment.body, '[test]')
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
@@ -31,6 +31,7 @@ jobs:
       - name: Get sha
         id: sha
         run: |
+          # Store SHA into outputs
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
       - name: Create status check to pending
@@ -38,6 +39,7 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
           cat << EOF > pending.json
           {
             "sha": "${{steps.sha.outputs.SHA}}",
@@ -47,14 +49,17 @@ jobs:
           }
           EOF
           echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
           curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
             --data @pending.json
           echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
 
-      - name: Schedule a test on Testing Farm
+      - name: Schedule a test on Testing Farm forn CentOS7
         id: sched_test
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
           apt update && apt -y install curl jq
           cat << EOF > request.json
           {
@@ -77,21 +82,9 @@ jobs:
           }
           EOF
           curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
           echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
 
-#      - name: Add comment with Testing Farm request/result
-#        # This step adds a new comment to the pull request with a link to the test.
-#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
-#        id: comment
-#        uses: peter-evans/create-or-update-comment@v1
-#        if: always()
-#        with:
-#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
-#          body: |
-#            Testing Farm - CentOS 7 [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.req_id }})
-#            for CentOS 7 test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
-#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log)
-
   running:
     needs: build
     name: Check running tests on Testing Farm service
@@ -104,13 +97,17 @@ jobs:
       - name: Check if REQ_ID and SHA exists
         id: req_sha
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
           echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
           echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
 
       - name: Switch to running state of Testing Farm request
         id: running
         run: |
+          # Create running.json file for query, whether job is finished or not.
           cat << EOF > running.json
           {
             "sha": "${{needs.build.outputs.SHA}}",
@@ -120,6 +117,7 @@ jobs:
             "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
           }
           EOF
+          # Update GitHub status description to 'Build started'
           curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
             --data @running.json
@@ -130,7 +128,9 @@ jobs:
           CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
           curl $CMD > job.json
           state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
           while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
             sleep 30
             curl $CMD > job.json
             state=$(jq -r .state job.json)
@@ -150,6 +150,8 @@ jobs:
       - name: Get final state of Testing Farm request
         id: final_state
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
           curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
           cat job.json
@@ -163,6 +165,7 @@ jobs:
               new_state="failure"
             fi
           else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
             infra_error=" - Infra problems"
             new_state="failure"
           fi
@@ -183,6 +186,7 @@ jobs:
           }
           EOF
           cat final.json
+          # Switch Github status to proper state
           curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
             --data @final.json
diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml
index 72ece893..baa75c0b 100644
--- a/.github/workflows/fedora-tests.yaml
+++ b/.github/workflows/fedora-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && github.event.comment.body == '[test]'
+      && contains(github.event.comment.body, '[test]')
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
@@ -31,6 +31,7 @@ jobs:
       - name: Get sha
         id: sha
         run: |
+          # Store SHA into outputs
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
       - name: Create status check to pending
@@ -38,22 +39,27 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
           cat << EOF > pending.json
           {
             "sha": "${{steps.sha.outputs.SHA}}",
             "state": "pending",
-            "context": "Testing Farm - Fedora"
+            "context": "Testing Farm - Fedora",
+            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
           }
           EOF
           echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
           curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
             --data @pending.json
           echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
 
-      - name: Schedule a test on Testing Farm
+      - name: Schedule a test on Testing Farm forn Fedora
         id: sched_test
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
           apt update && apt -y install curl jq
           cat << EOF > request.json
           {
@@ -76,21 +82,9 @@ jobs:
           }
           EOF
           curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
           echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
 
-#      - name: Add comment with Testing Farm request/result
-#        # This step adds a new comment to the pull request with a link to the test.
-#        # TODO: This is a temporary workaround until a proper way to set a commit status is implemented.
-#        id: comment
-#        uses: peter-evans/create-or-update-comment@v1
-#        if: always()
-#        with:
-#          issue-number: ${{ steps.pr_nr.outputs.PR_NR }}
-#          body: |
-#            Testing Farm - Fedora [request](${{ secrets.TF_ENDPOINT }}/requests/${{ steps.sched_test.outputs.REQ_ID }})
-#            for Fedora test was created. Once finished, results should be available [here](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/)
-#            [Full pipeline log](http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.REQ_ID }}/pipeline.log)
-
   running:
     needs: build
     name: Check running tests on Testing Farm service
@@ -103,13 +97,17 @@ jobs:
       - name: Check if REQ_ID and SHA exists
         id: req_sha
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
           echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
           echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
 
       - name: Switch to running state of Testing Farm request
         id: running
         run: |
+          # Create running.json file for query, whether job is finished or not.
           cat << EOF > running.json
           {
             "sha": "${{needs.build.outputs.SHA}}",
@@ -119,7 +117,8 @@ jobs:
             "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
           }
           EOF
-          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+          # Update GitHub status description to 'Build started'
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
             --data @running.json
 
@@ -128,12 +127,12 @@ jobs:
         run: |
           CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
           curl $CMD > job.json
-          cat job.json
           state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
           while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
             sleep 30
             curl $CMD > job.json
-            cat job.json
             state=$(jq -r .state job.json)
           done
 
@@ -151,6 +150,8 @@ jobs:
       - name: Get final state of Testing Farm request
         id: final_state
         run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
           apt update && apt -y install curl jq
           curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
           cat job.json
@@ -164,6 +165,7 @@ jobs:
               new_state="failure"
             fi
           else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
             infra_error=" - Infra problems"
             new_state="failure"
           fi
@@ -184,6 +186,7 @@ jobs:
           }
           EOF
           cat final.json
+          # Switch Github status to proper state
           curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
             https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
             --data @final.json

From 3a5e0ff961d869f1db6184f07ed74b89ec999648 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 22 Jul 2021 10:09:20 +0200
Subject: [PATCH 224/509] Create rhel7-tests.yml

---
 .github/workflows/rhel7-tests.yml | 193 ++++++++++++++++++++++++++++++
 1 file changed, 193 insertions(+)
 create mode 100644 .github/workflows/rhel7-tests.yml

diff --git a/.github/workflows/rhel7-tests.yml b/.github/workflows/rhel7-tests.yml
new file mode 100644
index 00000000..569a2bcf
--- /dev/null
+++ b/.github/workflows/rhel7-tests.yml
@@ -0,0 +1,193 @@
+name: RHEL7-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for RHEL7
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && contains(github.event.comment.body, '[test]')
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          # Store SHA into outputs
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending for RHEL7
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}/"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm for RHEL7
+        id: sched_test
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
+              "ref": "master",
+              "name": "rhel7"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "RHEL-7.9-Released"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "rhel7",
+                "TEST_NAME": "test"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service for RHEL7
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request for RHEL7
+        id: running
+        run: |
+          # Create running.json file for query, whether job is finished or not.
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7",
+            "description": "Build started",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
+          }
+          EOF
+          # Update GitHub status description to 'Build started'
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state for RHEL7
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request for RHEL7
+        id: final_state
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request for RHEL7
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - RHEL7",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
+          }
+          EOF
+          cat final.json
+          # Switch Github status to proper state
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json

From af89b6ba7f266a6129b2918ba8f18e1dfcae9be6 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 22 Jul 2021 10:09:40 +0200
Subject: [PATCH 225/509] Create rhel8-tests.yml

---
 .github/workflows/rhel8-tests.yml | 193 ++++++++++++++++++++++++++++++
 1 file changed, 193 insertions(+)
 create mode 100644 .github/workflows/rhel8-tests.yml

diff --git a/.github/workflows/rhel8-tests.yml b/.github/workflows/rhel8-tests.yml
new file mode 100644
index 00000000..3852f0a9
--- /dev/null
+++ b/.github/workflows/rhel8-tests.yml
@@ -0,0 +1,193 @@
+name: RHEL8-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for RHEL8
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && contains(github.event.comment.body, '[test]')
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          # Store SHA into outputs
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL8",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm for RHEL 8
+        id: sched_test
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
+              "ref": "master",
+              "name": "rhel8"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "RHEL-8.3.1-Released"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "rhel8",
+                "TEST_NAME": "test"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service on RHEL8
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request for RHEL8
+        id: running
+        run: |
+          # Create running.json file for query, whether job is finished or not.
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL8",
+            "description": "Build started",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
+          }
+          EOF
+          # Update GitHub status description to 'Build started'
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running for RHEL8
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state for RHEL8
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request for RHEL8
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - RHEL8",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
+          }
+          EOF
+          cat final.json
+          # Switch Github status to proper state
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json

From 89056ea19c8516cca7697a27acc528a89d24cffb Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 22 Jul 2021 12:52:54 +0200
Subject: [PATCH 226/509] Use unique names

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/{rhel7-tests.yml => rhel7-tests.yaml} | 2 +-
 .github/workflows/{rhel8-tests.yml => rhel8-tests.yaml} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename .github/workflows/{rhel7-tests.yml => rhel7-tests.yaml} (99%)
 rename .github/workflows/{rhel8-tests.yml => rhel8-tests.yaml} (99%)

diff --git a/.github/workflows/rhel7-tests.yml b/.github/workflows/rhel7-tests.yaml
similarity index 99%
rename from .github/workflows/rhel7-tests.yml
rename to .github/workflows/rhel7-tests.yaml
index 569a2bcf..a0295418 100644
--- a/.github/workflows/rhel7-tests.yml
+++ b/.github/workflows/rhel7-tests.yaml
@@ -67,7 +67,7 @@ jobs:
             "test": {"fmf": {
               "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
               "ref": "master",
-              "name": "rhel7"
+              "name": "rhel7-docker"
             }},
             "environments": [{
               "arch": "x86_64",
diff --git a/.github/workflows/rhel8-tests.yml b/.github/workflows/rhel8-tests.yaml
similarity index 99%
rename from .github/workflows/rhel8-tests.yml
rename to .github/workflows/rhel8-tests.yaml
index 3852f0a9..69df8145 100644
--- a/.github/workflows/rhel8-tests.yml
+++ b/.github/workflows/rhel8-tests.yaml
@@ -67,7 +67,7 @@ jobs:
             "test": {"fmf": {
               "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
               "ref": "master",
-              "name": "rhel8"
+              "name": "rhel8-docker"
             }},
             "environments": [{
               "arch": "x86_64",

From 0ebb7162d63193c0220375463c7fe0e561f1d6a7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 22 Jul 2021 13:19:59 +0200
Subject: [PATCH 227/509] Fix typo in OpenShift 3 tests

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-local-cluster | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index b59aeb0c..c3550c0f 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -451,7 +451,7 @@ function run_latest_imagestreams_test() {
   local result=1
   # Switch to root directory of a container
   echo "Testing the latest version in imagestreams"
-  pushd "${test_dir}/.." >/dev/null || return 1
+  pushd "${THISDIR}/.." >/dev/null || return 1
   ct_check_latest_imagestreams
   result=$?
   popd >/dev/null || return 1

From 594f9bf28d2daee1d1cb09540fb140c38aeb6294 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 22 Jul 2021 13:21:07 +0200
Subject: [PATCH 228/509] Create rhel7-openshift-tests.yaml

---
 .github/workflows/rhel7-openshift-tests.yaml | 193 +++++++++++++++++++
 1 file changed, 193 insertions(+)
 create mode 100644 .github/workflows/rhel7-openshift-tests.yaml

diff --git a/.github/workflows/rhel7-openshift-tests.yaml b/.github/workflows/rhel7-openshift-tests.yaml
new file mode 100644
index 00000000..9b3f5f38
--- /dev/null
+++ b/.github/workflows/rhel7-openshift-tests.yaml
@@ -0,0 +1,193 @@
+name: RHEL7-openshift-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for RHEL7 - OpenShift 3
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && contains(github.event.comment.body, '[test-openshift]')
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          # Store SHA into outputs
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7 - OpenShift 3",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 3
+        id: sched_test
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
+              "ref": "master",
+              "name": "rhel7-openshift-3"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "RHEL-7.9-Released"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "rhel7",
+                "TEST_NAME": "test-openshift"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request
+        id: running
+        run: |
+          # Create running.json file for query, whether job is finished or not.
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7 - OpenShift 3",
+            "description": "Build started",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
+          }
+          EOF
+          # Update GitHub status description to 'Build started'
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - RHEL7 - OpenShift 3",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
+          }
+          EOF
+          cat final.json
+          # Switch Github status to proper state
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json

From 70dc4d355cef2650e0a5536cb16270489259d906 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 22 Jul 2021 13:21:20 +0200
Subject: [PATCH 229/509] Create rhel7-openshift4-tests.yaml

---
 .github/workflows/rhel7-openshift4-tests.yaml | 193 ++++++++++++++++++
 1 file changed, 193 insertions(+)
 create mode 100644 .github/workflows/rhel7-openshift4-tests.yaml

diff --git a/.github/workflows/rhel7-openshift4-tests.yaml b/.github/workflows/rhel7-openshift4-tests.yaml
new file mode 100644
index 00000000..8ea1238b
--- /dev/null
+++ b/.github/workflows/rhel7-openshift4-tests.yaml
@@ -0,0 +1,193 @@
+name: RHEL7-openshift4-tests@TF
+
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  build:
+    # This job only runs for '[test]' pull request comments by owner, member
+    name: Schedule test on Testing Farm service for RHEL7 - OpenShift 4
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && contains(github.event.comment.body, '[test-openshift-4]')
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    outputs:
+      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
+      SHA: ${{steps.sha.outputs.SHA}}
+    steps:
+      - name: Get pull request number
+        id: pr_nr
+        run: |
+          PR_URL="${{ github.event.comment.issue_url }}"
+          echo "::set-output name=PR_NR::${PR_URL##*/}"
+
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+
+      - name: Get sha
+        id: sha
+        run: |
+          # Store SHA into outputs
+          echo "::set-output name=SHA::$(git rev-parse HEAD)"
+
+      - name: Create status check to pending
+        id: pending
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Create a JSON file for Testing Farm in order to schedule a CI testing job
+          cat << EOF > pending.json
+          {
+            "sha": "${{steps.sha.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7 - OpenShift 4",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
+          }
+          EOF
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          # GITHUB_TOKEN is used for updating pull request status.
+          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
+          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            --data @pending.json
+          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
+
+      - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 4
+        id: sched_test
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          apt update && apt -y install curl jq
+          cat << EOF > request.json
+          {
+            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
+            "test": {"fmf": {
+              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
+              "ref": "master",
+              "name": "rhel7-openshift-4"
+            }},
+            "environments": [{
+              "arch": "x86_64",
+              "os": {"compose": "RHEL-7.9-Released"},
+              "variables": {
+                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
+                "REPO_NAME": "$GITHUB_REPOSITORY",
+                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
+                "OS": "rhel7",
+                "TEST_NAME": "test-openshift-4"
+              }
+            }]
+          }
+          EOF
+          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          # Store REQ_ID into outputs for later on usage
+          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+
+  running:
+    needs: build
+    name: Check running tests on Testing Farm service
+    runs-on: ubuntu-20.04
+    outputs:
+      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
+      SHA: ${{steps.req_sha.outputs.SHA}}
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Check if REQ_ID and SHA exists
+        id: req_sha
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          # Propagate REQ_ID and SHA into the finish section
+          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
+          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+
+      - name: Switch to running state of Testing Farm request
+        id: running
+        run: |
+          # Create running.json file for query, whether job is finished or not.
+          cat << EOF > running.json
+          {
+            "sha": "${{needs.build.outputs.SHA}}",
+            "state": "pending",
+            "context": "Testing Farm - RHEL7 - OpenShift 4",
+            "description": "Build started",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
+          }
+          EOF
+          # Update GitHub status description to 'Build started'
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+            --data @running.json
+
+      - name: Check test is still running
+        id: still_running
+        run: |
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          curl $CMD > job.json
+          state=$(jq -r .state job.json)
+          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
+          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
+            # Wait 30s. We do not need to query Testing Farm each second
+            sleep 30
+            curl $CMD > job.json
+            state=$(jq -r .state job.json)
+          done
+
+  finish:
+    needs: running
+    name: Tests are finished - switching to proper state
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Check if REQ_ID exists
+        run: echo "${{ needs.running.outputs.REQ_ID }}"
+
+      - name: Check if SHA exists
+        run: echo "${{ needs.running.outputs.SHA }}"
+
+      - name: Get final state of Testing Farm request
+        id: final_state
+        run: |
+          # Update ubuntu-20.04 in order to install curl and jq
+          # each job is separate machine
+          apt update && apt -y install curl jq
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          cat job.json
+          state=$(jq -r .state job.json)
+          result=$(jq -r .result.overall job.json)
+          new_state="success"
+          infra_error=" "
+          echo "State is $state and result is: $result"
+          if [ "$state" == "complete" ]; then
+            if [ "$result" != "passed" ]; then
+              new_state="failure"
+            fi
+          else
+            # Mark job in case of infrastructure issues. Report to Testing Farm team
+            infra_error=" - Infra problems"
+            new_state="failure"
+          fi
+          echo "New State is: $new_state"
+          echo "Infra state is: $infra_error"
+          echo "::set-output name=FINAL_STATE::$new_state"
+          echo "::set-output name=INFRA_STATE::$infra_error"
+
+      - name: Switch to final state of Testing Farm request
+        run: |
+          cat << EOF > final.json
+          {
+            "sha": "${{needs.running.outputs.SHA}}",
+            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
+            "context": "Testing Farm - RHEL7 - OpenShift 4",
+            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
+            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
+          }
+          EOF
+          cat final.json
+          # Switch Github status to proper state
+          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+            --data @final.json

From 34d1a36913b86621167ac98f575841f994b97d48 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 22 Jul 2021 15:04:54 +0200
Subject: [PATCH 230/509] Add imagestream 13-el7 so tests are passing

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/postgresql-centos.json | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index c0438dbc..9281f283 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -44,6 +44,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/centos7/postgresql-13-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "12-el7",
         "annotations": {

From f52438b7a7c867ee1d671125c958a7293f4c5565 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 11 Aug 2021 12:46:38 +0200
Subject: [PATCH 231/509] Select only valid plan

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/centos7-openshift-tests.yaml | 3 ++-
 .github/workflows/centos7-tests.yaml           | 3 ++-
 .github/workflows/fedora-tests.yaml            | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/centos7-openshift-tests.yaml
index 5e10a5c5..b03c9186 100644
--- a/.github/workflows/centos7-openshift-tests.yaml
+++ b/.github/workflows/centos7-openshift-tests.yaml
@@ -66,7 +66,8 @@ jobs:
             "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
             "test": {"fmf": {
               "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main"
+              "ref": "main",
+              "name": "fedora"
             }},
             "environments": [{
               "arch": "x86_64",
diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/centos7-tests.yaml
index 982956de..718a03a9 100644
--- a/.github/workflows/centos7-tests.yaml
+++ b/.github/workflows/centos7-tests.yaml
@@ -66,7 +66,8 @@ jobs:
             "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
             "test": {"fmf": {
               "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main"
+              "ref": "main",
+              "name": "fedora"
             }},
             "environments": [{
               "arch": "x86_64",
diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml
index baa75c0b..fe2d7020 100644
--- a/.github/workflows/fedora-tests.yaml
+++ b/.github/workflows/fedora-tests.yaml
@@ -66,7 +66,8 @@ jobs:
             "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
             "test": {"fmf": {
               "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main"
+              "ref": "main",
+              "name": "fedora"
             }},
             "environments": [{
               "arch": "x86_64",

From 83c71ac76c23b2021f12a1b9e035e518cc4d7f9d Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 27 Aug 2021 12:45:09 +0200
Subject: [PATCH 232/509] Use a working link in README.md

While this is not the same content, it's likely the closest one. I didn't find anything more close or the same content as before any more.
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 4a27ab8f..ab2e84a4 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.
 
 For more information about using these images with OpenShift, please see the
-official [OpenShift Documentation](https://docs.okd.io/latest/using_images/db_images/postgresql.html).
+official [OpenShift Documentation](https://docs.okd.io/latest/openshift_images/using-templates.html).
 
 For more information about contributing, see
 [the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).

From 9922da3858b34e87a156284c2c1af763a95ad8f9 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 29 Apr 2021 11:28:55 +0200
Subject: [PATCH 233/509] Revert 0812291b48aba31e4329cadd3bb5c5c00905b92a

---
 Makefile  | 2 +-
 README.md | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a1904360..2b5470ee 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 11 12 13
+VERSIONS = 9.6 10 11 12 13
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index ab2e84a4..ee28655e 100644
--- a/README.md
+++ b/README.md
@@ -18,12 +18,14 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently supported are:
+* [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
 * [postgresql-13](https://github.com/sclorg/postgresql-container/tree/generated/13)
 
 RHEL versions currently supported are:
 * RHEL7
+* RHEL8
 
 CentOS versions currently supported are:
 * CentOS7
@@ -79,6 +81,9 @@ In this repository [distgen](https://github.com/devexp-db/distgen/) is used for
 Usage
 ---------------------------------
 
+For information about usage of Dockerfile for PostgreSQL 9.6,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
+
 For information about usage of Dockerfile for PostgreSQL 10,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
 
@@ -92,7 +97,6 @@ For versions which are not supported anymore:
 
 * [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
 * [PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4)
-* [PostgreSQL 9.6](https://github.com/sclorg/postgresql-container/tree/139dafa9/9.6)
 
 Test
 ---------------------------------

From 9c1fc7e9bf39881652f5b8c9c01cb44e96cd9ed9 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 29 Apr 2021 11:29:55 +0200
Subject: [PATCH 234/509] disable source generation for rhel7-based 9.6 version

---
 specs/multispec.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 1864a9fe..0c6b5e4e 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -116,6 +116,8 @@ matrix:
     - distros:
         - fedora-31-x86_64
         - fedora-34-x86_64
+        - rhel-7-x86_64
+        - centos-7-x86_64
       version: "9.6"
     - distros:
         - fedora-31-x86_64

From 951d5a1d83fc7353c37870e015155b3859d87f72 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 24 Sep 2021 15:14:09 +0200
Subject: [PATCH 235/509] Support build and push image into Quay.IO

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 74 ++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 .github/workflows/build-and-push.yml

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
new file mode 100644
index 00000000..fd44d503
--- /dev/null
+++ b/.github/workflows/build-and-push.yml
@@ -0,0 +1,74 @@
+name: Build and push CentOS7 images to Quay.io registry
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  build-and-push:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        version: [6]
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+
+      - name: Get base image name
+        id: base-image-name
+        run: |
+          # This command returns row with BASE_IMAGE_NAME
+          row=$(grep "BASE_IMAGE_NAME" Makefile)
+          # Return only base image name
+          BASE_IMAGE_ROW=${row/BASE_IMAGE_NAME = /}
+          echo ::set-output name=image_name::$BASE_IMAGE_ROW
+
+      - name: Checkout into generated section
+        run: |
+          git checkout --progress --force -B generated refs/remotes/origin/generated
+
+      - name: Get short version
+        id: short_version
+        run: |
+          ver="${{ matrix.version }}"
+          echo "::set-output name=SHORT_VER::${ver//./}"
+
+      - name: Check if dockerfile is present in version directory
+        id: check_dockerfile_file
+        # https://github.com/marketplace/actions/file-existence
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/Dockerfile"
+
+      - name: Check if .exclude-centos7 is present in version directory
+        id: check_exclude_centos7_file
+        # https://github.com/marketplace/actions/file-existence
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/.exclude-centos7"
+
+      - name: Build CentOS7 image
+        if: steps.check_exclude_centos7_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
+        id: build-image
+        # https://github.com/marketplace/actions/buildah-build
+        uses: redhat-actions/buildah-build@v2
+        with:
+          dockerfiles: ${{ matrix.version }}/Dockerfile
+          image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.short_version.outputs.SHORT_VER }}-centos7
+          context: ${{ matrix.version }}
+          tags: latest 1 ${{ github.sha }}
+
+      - name: Push CentOS7 image to Quay.io
+        if: steps.check_exclude_centos7_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
+        id: push-to-quay
+        uses: redhat-actions/push-to-registry@v2.2
+        with:
+          image: ${{ steps.build-image.outputs.image }}
+          tags: ${{ steps.build-image.outputs.tags }}
+          registry: quay.io/centos7
+          username: ${{ secrets.QUAY_IMAGE_BUILDER_USERNAME }}
+          password: ${{ secrets.QUAY_IMAGE_BUILDER_TOKEN }}
+
+      - name: Print image url
+        run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

From a71eeba9396bbc0615e0117f69e3df0333251847 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Mon, 27 Sep 2021 09:57:53 +0200
Subject: [PATCH 236/509] Fix versions in build-and-push.yml

---
 .github/workflows/build-and-push.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index fd44d503..2f8f0023 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -9,7 +9,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        version: [6]
+        version: ["9.6", 10, 11, 12, 13]
     steps:
       - uses: actions/checkout@v2
         with:

From aa6dbd67a53288f5d41a7f2c2e431792b56dcf94 Mon Sep 17 00:00:00 2001
From: Michael Scherer <misc@redhat.com>
Date: Wed, 20 Oct 2021 11:06:31 +0200
Subject: [PATCH 237/509] Fix run_doc_test to work with newer go-md2man

Should fix https://github.com/sclorg/postgresql-container/issues/421
---
 test/run_test | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index 14860eae..84a40c73 100755
--- a/test/run_test
+++ b/test/run_test
@@ -699,8 +699,8 @@ run_doc_test() {
   for f in help.1 ; do
     docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
     # Check whether the files include some important information
-    for term in "POSTGRESQL\_ADMIN\_PASSWORD" volume 5432 ; do
-      if ! cat ${tmpdir}/$(basename ${f}) | grep -F -q -e "${term}" ; then
+    for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' volume 5432 ; do
+      if ! cat ${tmpdir}/$(basename ${f}) | grep -E -q -e "${term}" ; then
         echo "ERROR: File /${f} does not include '${term}'."
         return 1
       fi

From 2364565b28ffb56e330ce70ad172c98274371a91 Mon Sep 17 00:00:00 2001
From: Felix Hassert <felix@ferndrang.de>
Date: Thu, 21 Oct 2021 20:35:44 +0200
Subject: [PATCH 238/509] fix typo in docs

---
 src/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index 95d8dac2..6bf69a5d 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -2,7 +2,7 @@ FROM {{ spec.s2i_base }}
 
 # PostgreSQL image for OpenShift.
 # Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
 # Environment:
 #  * $POSTGRESQL_USER     - Database user name
 #  * $POSTGRESQL_PASSWORD - User's password

From f5671fc76ebba6972cb65d4c4fb384e8fa2857b2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 25 Oct 2021 09:51:13 +0200
Subject: [PATCH 239/509] Add possibility to test all

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/centos7-openshift-tests.yaml | 2 +-
 .github/workflows/centos7-tests.yaml           | 2 +-
 .github/workflows/fedora-tests.yaml            | 2 +-
 .github/workflows/rhel7-openshift-tests.yaml   | 2 +-
 .github/workflows/rhel7-openshift4-tests.yaml  | 2 +-
 .github/workflows/rhel7-tests.yaml             | 2 +-
 .github/workflows/rhel8-tests.yaml             | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/centos7-openshift-tests.yaml
index b03c9186..02df7183 100644
--- a/.github/workflows/centos7-openshift-tests.yaml
+++ b/.github/workflows/centos7-openshift-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test-openshift]')
+      && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/centos7-tests.yaml
index 718a03a9..5d045646 100644
--- a/.github/workflows/centos7-tests.yaml
+++ b/.github/workflows/centos7-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test]')
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml
index fe2d7020..07e4f6c6 100644
--- a/.github/workflows/fedora-tests.yaml
+++ b/.github/workflows/fedora-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test]')
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/rhel7-openshift-tests.yaml b/.github/workflows/rhel7-openshift-tests.yaml
index 9b3f5f38..31b9c933 100644
--- a/.github/workflows/rhel7-openshift-tests.yaml
+++ b/.github/workflows/rhel7-openshift-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test-openshift]')
+      && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/rhel7-openshift4-tests.yaml b/.github/workflows/rhel7-openshift4-tests.yaml
index 8ea1238b..c4c0170a 100644
--- a/.github/workflows/rhel7-openshift4-tests.yaml
+++ b/.github/workflows/rhel7-openshift4-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test-openshift-4]')
+      && (contains(github.event.comment.body, '[test-openshift-4]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/rhel7-tests.yaml b/.github/workflows/rhel7-tests.yaml
index a0295418..6210fc0c 100644
--- a/.github/workflows/rhel7-tests.yaml
+++ b/.github/workflows/rhel7-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test]')
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
diff --git a/.github/workflows/rhel8-tests.yaml b/.github/workflows/rhel8-tests.yaml
index 69df8145..3e7b1723 100644
--- a/.github/workflows/rhel8-tests.yaml
+++ b/.github/workflows/rhel8-tests.yaml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && contains(github.event.comment.body, '[test]')
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     outputs:
       REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}

From 9f83d4247469d2782fb7b2a576bf6451ae598034 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Nov 2021 10:03:31 +0100
Subject: [PATCH 240/509] User GitHub Action matrix for docker tests

The matrix contains all docker tests
like Fedora, CentOS7, RHEL7 and RHEL8

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .../{centos7-tests.yaml => docker-tests.yml}  | 140 ++++++-------
 .github/workflows/fedora-tests.yaml           | 193 ------------------
 .github/workflows/rhel7-tests.yaml            | 193 ------------------
 .github/workflows/rhel8-tests.yaml            | 193 ------------------
 4 files changed, 71 insertions(+), 648 deletions(-)
 rename .github/workflows/{centos7-tests.yaml => docker-tests.yml} (58%)
 delete mode 100644 .github/workflows/fedora-tests.yaml
 delete mode 100644 .github/workflows/rhel7-tests.yaml
 delete mode 100644 .github/workflows/rhel8-tests.yaml

diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/docker-tests.yml
similarity index 58%
rename from .github/workflows/centos7-tests.yaml
rename to .github/workflows/docker-tests.yml
index 5d045646..9c625e0a 100644
--- a/.github/workflows/centos7-tests.yaml
+++ b/.github/workflows/docker-tests.yml
@@ -1,4 +1,4 @@
-name: CentOS7-tests@TF
+name: docker-tests at Testing Farm
 
 on:
   issue_comment:
@@ -7,15 +7,40 @@ on:
 jobs:
   build:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for CentOS7
+    name: Docker tests on Testing Farm service
     runs-on: ubuntu-20.04
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - tmt_plan: "fedora"
+            os_test: "fedora"
+            context: "Fedora"
+            compose: "CentOS-7"
+            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+          - tmt_plan: "centos7"
+            os_test: "centos7"
+            context: "CentOS7"
+            compose: "CentOS-7"
+            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+          - tmt_plan: "rhel7-docker"
+            os_test: "rhel7"
+            context: "RHEL7"
+            compose: "RHEL-7.9-Released"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+          - tmt_plan: "rhel8-docker"
+            os_test: "rhel8"
+            context: "RHEL8"
+            compose: "RHEL-8.3.1-Released"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
     steps:
       - name: Get pull request number
         id: pr_nr
@@ -28,10 +53,9 @@ jobs:
         with:
           ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
 
-      - name: Get sha
-        id: sha
+      - name: SHA value
+        id: sha_value
         run: |
-          # Store SHA into outputs
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
       - name: Create status check to pending
@@ -42,68 +66,59 @@ jobs:
           # Create a JSON file for Testing Farm in order to schedule a CI testing job
           cat << EOF > pending.json
           {
-            "sha": "${{steps.sha.outputs.SHA}}",
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
             "state": "pending",
-            "context": "Testing Farm - CentOS7",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
+            "context": "Testing Farm - ${{ matrix.context }}",
+            "target_url": "${{ matrix.tmt_url }}"
           }
           EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}"
           # GITHUB_TOKEN is used for updating pull request status.
           # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
           curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @pending.json
           echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
 
-      - name: Schedule a test on Testing Farm forn CentOS7
+      - name: Schedule a test on Testing Farm
         id: sched_test
         run: |
           # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
+          sudo apt update && sudo apt -y install curl jq
+          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then
+            api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
+            branch_name="main"
+          else
+            api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
+            branch_name="master"
+          fi
           cat << EOF > request.json
           {
-            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
+            "api_key": "$api_key",
             "test": {"fmf": {
-              "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main",
-              "name": "fedora"
+              "url": "${{ matrix.tmt_repo }}",
+              "ref": "$branch_name",
+              "name": "${{ matrix.tmt_plan }}"
             }},
             "environments": [{
               "arch": "x86_64",
-              "os": {"compose": "CentOS-7"},
+              "os": {"compose": "${{ matrix.compose }}"},
               "variables": {
                 "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
                 "REPO_NAME": "$GITHUB_REPOSITORY",
                 "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "centos7",
+                "OS": "${{ matrix.os_test }}",
                 "TEST_NAME": "test"
               }
             }]
           }
           EOF
           curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
+          cat response.json
+          
           # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+          req_id=$(jq -r .id response.json)
+          echo "REQ_ID=$req_id" >> $GITHUB_ENV
 
       - name: Switch to running state of Testing Farm request
         id: running
@@ -111,23 +126,24 @@ jobs:
           # Create running.json file for query, whether job is finished or not.
           cat << EOF > running.json
           {
-            "sha": "${{needs.build.outputs.SHA}}",
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
             "state": "pending",
-            "context": "Testing Farm - CentOS7",
+            "context": "Testing Farm - ${{ matrix.context }}",
             "description": "Build started",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
+            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
           }
           EOF
           # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @running.json
 
       - name: Check test is still running
         id: still_running
         run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }}
           curl $CMD > job.json
+          cat job.json
           state=$(jq -r .state job.json)
           # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
           while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
@@ -137,24 +153,10 @@ jobs:
             state=$(jq -r .state job.json)
           done
 
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
       - name: Get final state of Testing Farm request
         id: final_state
         run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json
           cat job.json
           state=$(jq -r .state job.json)
           result=$(jq -r .result.overall job.json)
@@ -179,15 +181,15 @@ jobs:
         run: |
           cat << EOF > final.json
           {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - CentOS7",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
+            "state": "${{ steps.final_state.outputs.FINAL_STATE }}",
+            "context": "Testing Farm - ${{ matrix.context }}",
+            "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}",
+            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
           }
           EOF
           cat final.json
           # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @final.json
diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml
deleted file mode 100644
index 07e4f6c6..00000000
--- a/.github/workflows/fedora-tests.yaml
+++ /dev/null
@@ -1,193 +0,0 @@
-name: Fedora-tests@TF
-
-on:
-  issue_comment:
-    types:
-      - created
-jobs:
-  build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for Fedora
-    runs-on: ubuntu-20.04
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
-    steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: Get sha
-        id: sha
-        run: |
-          # Store SHA into outputs
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{steps.sha.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - Fedora",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm forn Fedora
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
-          cat << EOF > request.json
-          {
-            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
-            "test": {"fmf": {
-              "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main",
-              "name": "fedora"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "CentOS-7"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "fedora",
-                "TEST_NAME": "test"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
-
-      - name: Switch to running state of Testing Farm request
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{needs.build.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - Fedora",
-            "description": "Build started",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
-            --data @running.json
-
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
-          curl $CMD > job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - Fedora",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
-            --data @final.json
diff --git a/.github/workflows/rhel7-tests.yaml b/.github/workflows/rhel7-tests.yaml
deleted file mode 100644
index 6210fc0c..00000000
--- a/.github/workflows/rhel7-tests.yaml
+++ /dev/null
@@ -1,193 +0,0 @@
-name: RHEL7-tests@TF
-
-on:
-  issue_comment:
-    types:
-      - created
-jobs:
-  build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for RHEL7
-    runs-on: ubuntu-20.04
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
-    steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: Get sha
-        id: sha
-        run: |
-          # Store SHA into outputs
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending for RHEL7
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{steps.sha.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}/"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm for RHEL7
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
-          cat << EOF > request.json
-          {
-            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
-            "test": {"fmf": {
-              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
-              "ref": "master",
-              "name": "rhel7-docker"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "RHEL-7.9-Released"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "rhel7",
-                "TEST_NAME": "test"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service for RHEL7
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
-
-      - name: Switch to running state of Testing Farm request for RHEL7
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{needs.build.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7",
-            "description": "Build started",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
-            --data @running.json
-
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
-          curl $CMD > job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state for RHEL7
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
-      - name: Get final state of Testing Farm request for RHEL7
-        id: final_state
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request for RHEL7
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - RHEL7",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
-            --data @final.json
diff --git a/.github/workflows/rhel8-tests.yaml b/.github/workflows/rhel8-tests.yaml
deleted file mode 100644
index 3e7b1723..00000000
--- a/.github/workflows/rhel8-tests.yaml
+++ /dev/null
@@ -1,193 +0,0 @@
-name: RHEL8-tests@TF
-
-on:
-  issue_comment:
-    types:
-      - created
-jobs:
-  build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for RHEL8
-    runs-on: ubuntu-20.04
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
-    steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: Get sha
-        id: sha
-        run: |
-          # Store SHA into outputs
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{steps.sha.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL8",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm for RHEL 8
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
-          cat << EOF > request.json
-          {
-            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
-            "test": {"fmf": {
-              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
-              "ref": "master",
-              "name": "rhel8-docker"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "RHEL-8.3.1-Released"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "rhel8",
-                "TEST_NAME": "test"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service on RHEL8
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
-
-      - name: Switch to running state of Testing Farm request for RHEL8
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{needs.build.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL8",
-            "description": "Build started",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
-            --data @running.json
-
-      - name: Check test is still running for RHEL8
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
-          curl $CMD > job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state for RHEL8
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request for RHEL8
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - RHEL8",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
-            --data @final.json

From 108d9dfe2f039091e23d810d403879c0f392fe9b Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Nov 2021 10:04:17 +0100
Subject: [PATCH 241/509] Use GitHub action matrix for OpenShift tests.

It contains all openshift tests like
CentOS7-OpenSHift 3, RHEL7-OpenShift 3 and RHEL7-OpenShift 4

and newly RHEL8-OpenShift 4

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 ...enshift-tests.yaml => openshift-tests.yml} | 146 ++++++-------
 .github/workflows/rhel7-openshift-tests.yaml  | 193 ------------------
 .github/workflows/rhel7-openshift4-tests.yaml | 193 ------------------
 3 files changed, 76 insertions(+), 456 deletions(-)
 rename .github/workflows/{centos7-openshift-tests.yaml => openshift-tests.yml} (55%)
 delete mode 100644 .github/workflows/rhel7-openshift-tests.yaml
 delete mode 100644 .github/workflows/rhel7-openshift4-tests.yaml

diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/openshift-tests.yml
similarity index 55%
rename from .github/workflows/centos7-openshift-tests.yaml
rename to .github/workflows/openshift-tests.yml
index 02df7183..0bf64261 100644
--- a/.github/workflows/centos7-openshift-tests.yaml
+++ b/.github/workflows/openshift-tests.yml
@@ -1,4 +1,4 @@
-name: CentOS7-openshift-tests@TF
+name: openshift-tests at Testing Farm
 
 on:
   issue_comment:
@@ -7,15 +7,44 @@ on:
 jobs:
   build:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for CentOS7 - OpenShift 3
+    name: OpenShift tests on Testing Farm service
     runs-on: ubuntu-20.04
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - tmt_plan: "centos7"
+            os_test: "centos7"
+            context: "CentOS7 - OpenShift3"
+            compose: "CentOS-7"
+            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+            test_name: "test-openshift"
+          - tmt_plan: "rhel7-openshift-3"
+            os_test: "rhel7"
+            context: "RHEL7 - OpenShift 3"
+            compose: "RHEL-7.9-Released"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            test_name: "test-openshift"
+          - tmt_plan: "rhel7-openshift-4"
+            os_test: "rhel7"
+            context: "RHEL7 - OpenShift 4"
+            compose: "RHEL-7.9-Released"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            test_name: "test-openshift-4"
+          - tmt_plan: "rhel8-openshift-4"
+            os_test: "rhel8"
+            context: "RHEL8 - OpenShift 4"
+            compose: "RHEL-8.3.1-Released"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            test_name: "test-openshift-4"
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
     steps:
       - name: Get pull request number
         id: pr_nr
@@ -28,10 +57,9 @@ jobs:
         with:
           ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
 
-      - name: Get sha
-        id: sha
+      - name: SHA value
+        id: sha_value
         run: |
-          # Store SHA into outputs
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
       - name: Create status check to pending
@@ -42,68 +70,59 @@ jobs:
           # Create a JSON file for Testing Farm in order to schedule a CI testing job
           cat << EOF > pending.json
           {
-            "sha": "${{steps.sha.outputs.SHA}}",
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
             "state": "pending",
-            "context": "Testing Farm - CentOS7 - OpenShift 3",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log"
+            "context": "Testing Farm - ${{ matrix.context }}",
+            "target_url": "${{ matrix.tmt_url }}"
           }
           EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
+          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}"
           # GITHUB_TOKEN is used for updating pull request status.
           # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
           curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @pending.json
           echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
 
-      - name: Schedule a test on Testing Farm forn CentOS7 - OpenShift 3
+      - name: Schedule a test on Testing Farm
         id: sched_test
         run: |
           # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
+          sudo apt update && sudo apt -y install curl jq
+          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then
+            api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
+            branch_name="main"
+          else
+            api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
+            branch_name="master"
+          fi
           cat << EOF > request.json
           {
-            "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}",
+            "api_key": "$api_key",
             "test": {"fmf": {
-              "url": "https://github.com/sclorg/sclorg-testing-farm",
-              "ref": "main",
-              "name": "fedora"
+              "url": "${{ matrix.tmt_repo }}",
+              "ref": "$branch_name",
+              "name": "${{ matrix.tmt_plan }}"
             }},
             "environments": [{
               "arch": "x86_64",
-              "os": {"compose": "CentOS-7"},
+              "os": {"compose": "${{ matrix.compose }}"},
               "variables": {
                 "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
                 "REPO_NAME": "$GITHUB_REPOSITORY",
                 "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "centos7",
-                "TEST_NAME": "test-openshift"
+                "OS": "${{ matrix.os_test }}",
+                "TEST_NAME": "${{ matrix.test_name }}"
               }
             }]
           }
           EOF
           curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
+          cat response.json
 
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
+          # Store REQ_ID into outputs for later on usage
+          req_id=$(jq -r .id response.json)
+          echo "REQ_ID=$req_id" >> $GITHUB_ENV
 
       - name: Switch to running state of Testing Farm request
         id: running
@@ -111,23 +130,24 @@ jobs:
           # Create running.json file for query, whether job is finished or not.
           cat << EOF > running.json
           {
-            "sha": "${{needs.build.outputs.SHA}}",
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
             "state": "pending",
-            "context": "Testing Farm - CentOS7 - OpenShift 3",
+            "context": "Testing Farm - ${{ matrix.context }}",
             "description": "Build started",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/"
+            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
           }
           EOF
           # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
+          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @running.json
 
       - name: Check test is still running
         id: still_running
         run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
+          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }}
           curl $CMD > job.json
+          cat job.json
           state=$(jq -r .state job.json)
           # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
           while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
@@ -137,24 +157,10 @@ jobs:
             state=$(jq -r .state job.json)
           done
 
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
       - name: Get final state of Testing Farm request
         id: final_state
         run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
+          curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json
           cat job.json
           state=$(jq -r .state job.json)
           result=$(jq -r .result.overall job.json)
@@ -179,15 +185,15 @@ jobs:
         run: |
           cat << EOF > final.json
           {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - CentOS7 - OpenShift 3",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/"
+            "sha": "${{ steps.sha_value.outputs.SHA }}",
+            "state": "${{ steps.final_state.outputs.FINAL_STATE }}",
+            "context": "Testing Farm - ${{ matrix.context }}",
+            "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}",
+            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
           }
           EOF
           cat final.json
           # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
+          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
+            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
             --data @final.json
diff --git a/.github/workflows/rhel7-openshift-tests.yaml b/.github/workflows/rhel7-openshift-tests.yaml
deleted file mode 100644
index 31b9c933..00000000
--- a/.github/workflows/rhel7-openshift-tests.yaml
+++ /dev/null
@@ -1,193 +0,0 @@
-name: RHEL7-openshift-tests@TF
-
-on:
-  issue_comment:
-    types:
-      - created
-jobs:
-  build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for RHEL7 - OpenShift 3
-    runs-on: ubuntu-20.04
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
-    steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: Get sha
-        id: sha
-        run: |
-          # Store SHA into outputs
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{steps.sha.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7 - OpenShift 3",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 3
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
-          cat << EOF > request.json
-          {
-            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
-            "test": {"fmf": {
-              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
-              "ref": "master",
-              "name": "rhel7-openshift-3"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "RHEL-7.9-Released"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "rhel7",
-                "TEST_NAME": "test-openshift"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
-
-      - name: Switch to running state of Testing Farm request
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{needs.build.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7 - OpenShift 3",
-            "description": "Build started",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
-            --data @running.json
-
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
-          curl $CMD > job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - RHEL7 - OpenShift 3",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
-            --data @final.json
diff --git a/.github/workflows/rhel7-openshift4-tests.yaml b/.github/workflows/rhel7-openshift4-tests.yaml
deleted file mode 100644
index c4c0170a..00000000
--- a/.github/workflows/rhel7-openshift4-tests.yaml
+++ /dev/null
@@ -1,193 +0,0 @@
-name: RHEL7-openshift4-tests@TF
-
-on:
-  issue_comment:
-    types:
-      - created
-jobs:
-  build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: Schedule test on Testing Farm service for RHEL7 - OpenShift 4
-    runs-on: ubuntu-20.04
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test-openshift-4]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
-    outputs:
-      REQ_ID: ${{steps.sched_test.outputs.REQ_ID}}
-      SHA: ${{steps.sha.outputs.SHA}}
-    steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: Get sha
-        id: sha
-        run: |
-          # Store SHA into outputs
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{steps.sha.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7 - OpenShift 4",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 4
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          apt update && apt -y install curl jq
-          cat << EOF > request.json
-          {
-            "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}",
-            "test": {"fmf": {
-              "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans",
-              "ref": "master",
-              "name": "rhel7-openshift-4"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "RHEL-7.9-Released"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "rhel7",
-                "TEST_NAME": "test-openshift-4"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          # Store REQ_ID into outputs for later on usage
-          echo "::set-output name=REQ_ID::$(jq -r .id response.json)"
-
-  running:
-    needs: build
-    name: Check running tests on Testing Farm service
-    runs-on: ubuntu-20.04
-    outputs:
-      REQ_ID: ${{steps.req_sha.outputs.REQ_ID}}
-      SHA: ${{steps.req_sha.outputs.SHA}}
-      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Check if REQ_ID and SHA exists
-        id: req_sha
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          # Propagate REQ_ID and SHA into the finish section
-          echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}"
-          echo "::set-output name=SHA::${{needs.build.outputs.SHA}}"
-
-      - name: Switch to running state of Testing Farm request
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{needs.build.outputs.SHA}}",
-            "state": "pending",
-            "context": "Testing Farm - RHEL7 - OpenShift 4",
-            "description": "Build started",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \
-            --data @running.json
-
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}}
-          curl $CMD > job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-  finish:
-    needs: running
-    name: Tests are finished - switching to proper state
-    runs-on: ubuntu-20.04
-    steps:
-      - name: Check if REQ_ID exists
-        run: echo "${{ needs.running.outputs.REQ_ID }}"
-
-      - name: Check if SHA exists
-        run: echo "${{ needs.running.outputs.SHA }}"
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          # each job is separate machine
-          apt update && apt -y install curl jq
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{needs.running.outputs.SHA}}",
-            "state": "${{steps.final_state.outputs.FINAL_STATE}}",
-            "context": "Testing Farm - RHEL7 - OpenShift 4",
-            "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}",
-            "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \
-            --data @final.json

From 3ba9c001bdf70ae871c8bb3a79efc02bb628901e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Nov 2021 10:15:02 +0100
Subject: [PATCH 242/509] Fix bash condition

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index ac0acba0..19ca08bd 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -34,7 +34,7 @@ function test_postgresql_imagestream() {
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
   local tag="-el7"
-  if [ x"${OS}" == "rhel8" ]; then
+  if [ "${OS}" == "rhel8" ]; then
     tag="-el8"
   fi
   ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"

From 41869429955834625afc8ff93a6f9dfe1033de6a Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 9 Nov 2021 10:28:53 +0100
Subject: [PATCH 243/509] Update .github/workflows/openshift-tests.yml

---
 .github/workflows/openshift-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 0bf64261..6cbe4c75 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -15,7 +15,7 @@ jobs:
         include:
           - tmt_plan: "centos7"
             os_test: "centos7"
-            context: "CentOS7 - OpenShift3"
+            context: "CentOS7 - OpenShift 3"
             compose: "CentOS-7"
             tmt_url: "http://artifacts.dev.testing-farm.io/"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"

From 275213cfde8e3d85301c3da62a82da19b4e6e1cf Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 23 Nov 2021 12:21:43 +0100
Subject: [PATCH 244/509] Update .github/workflows/docker-tests.yml

---
 .github/workflows/docker-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 9c625e0a..2ee95318 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -63,7 +63,7 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
+          # Create a JSON data structure for GitHub API to display the test status in the PR
           cat << EOF > pending.json
           {
             "sha": "${{ steps.sha_value.outputs.SHA }}",

From 00fe5dc506df9cc8abf45effadb98503def69b8a Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 23 Nov 2021 12:22:08 +0100
Subject: [PATCH 245/509] Update .github/workflows/docker-tests.yml

---
 .github/workflows/docker-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 2ee95318..832c8edd 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -7,7 +7,7 @@ on:
 jobs:
   build:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Docker tests on Testing Farm service
+    name: Container tests on Testing Farm service
     runs-on: ubuntu-20.04
     strategy:
       fail-fast: false

From cc4d1f544a64835df11b6ed0cd02cb38c5faf68c Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 23 Nov 2021 12:22:29 +0100
Subject: [PATCH 246/509] Update .github/workflows/docker-tests.yml

---
 .github/workflows/docker-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 832c8edd..78d9615e 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -1,4 +1,4 @@
-name: docker-tests at Testing Farm
+name: container-tests at Testing Farm
 
 on:
   issue_comment:

From caf25587d168de12bbde59e122c4e94c542e6409 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Mon, 22 Nov 2021 09:04:39 -0500
Subject: [PATCH 247/509] Update imagestreams

---
 imagestreams/postgresql-centos.json       | 36 +++++++++++------------
 imagestreams/postgresql-rhel-aarch64.json | 18 ------------
 imagestreams/postgresql-rhel.json         | 36 +++++++++++------------
 3 files changed, 36 insertions(+), 54 deletions(-)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 9281f283..ffa53619 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -26,6 +26,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/centos7/postgresql-13-centos7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "12-el8",
         "annotations": {
@@ -151,24 +169,6 @@
         "referencePolicy": {
           "type": "Local"
         }
-      },
-      {
-        "name": "9.6-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (CentOS 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-96-centos8:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 132283bc..45f3da07 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -79,24 +79,6 @@
         "referencePolicy": {
           "type": "Local"
         }
-      },
-      {
-        "name": "9.6-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
       }
     ]
   }
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index dc4b8161..a7868ff8 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -44,6 +44,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el7",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "12-el8",
         "annotations": {
@@ -169,24 +187,6 @@
         "referencePolicy": {
           "type": "Local"
         }
-      },
-      {
-        "name": "9.6-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 9.6 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 9.6 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "9.6"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-96:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
       }
     ]
   }

From 2ac7718fea556054d017e0c8af873160d3e0e503 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Mon, 22 Nov 2021 11:26:00 -0500
Subject: [PATCH 248/509] Use groupified apiVersion

Non-groupified objects were deprecated in OCP 4.7.
---
 examples/postgresql-ephemeral-template.json  | 4 ++--
 examples/postgresql-persistent-template.json | 4 ++--
 imagestreams/postgresql-centos.json          | 2 +-
 imagestreams/postgresql-rhel-aarch64.json    | 2 +-
 imagestreams/postgresql-rhel.json            | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index dd8d64f1..bf5bf57a 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -1,6 +1,6 @@
 {
   "kind": "Template",
-  "apiVersion": "v1",
+  "apiVersion": "template.openshift.io/v1",
   "metadata": {
     "name": "postgresql-ephemeral",
     "annotations": {
@@ -67,7 +67,7 @@
     },
     {
       "kind": "DeploymentConfig",
-      "apiVersion": "v1",
+      "apiVersion": "apps.openshift.io/v1",
       "metadata": {
         "name": "${DATABASE_SERVICE_NAME}",
         "annotations": {
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index 5bcab583..312ecd91 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -1,6 +1,6 @@
 {
   "kind": "Template",
-  "apiVersion": "v1",
+  "apiVersion": "template.openshift.io/v1",
   "metadata": {
     "name": "postgresql-persistent",
     "annotations": {
@@ -84,7 +84,7 @@
     },
     {
       "kind": "DeploymentConfig",
-      "apiVersion": "v1",
+      "apiVersion": "apps.openshift.io/v1",
       "metadata": {
         "name": "${DATABASE_SERVICE_NAME}",
         "annotations": {
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index ffa53619..2cde84b9 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -1,6 +1,6 @@
 {
   "kind": "ImageStream",
-  "apiVersion": "v1",
+  "apiVersion": "image.openshift.io/v1",
   "metadata": {
     "name": "postgresql",
     "annotations": {
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 45f3da07..d8a16c00 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -1,6 +1,6 @@
 {
   "kind": "ImageStream",
-  "apiVersion": "v1",
+  "apiVersion": "image.openshift.io/v1",
   "metadata": {
     "name": "postgresql",
     "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index a7868ff8..adc8def3 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -1,6 +1,6 @@
 {
   "kind": "ImageStream",
-  "apiVersion": "v1",
+  "apiVersion": "image.openshift.io/v1",
   "metadata": {
     "name": "postgresql",
     "annotations": {

From e99f160c729a7cd363e2a0b584f58770b379b562 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Tue, 14 Dec 2021 11:00:48 -0500
Subject: [PATCH 249/509] Rebase common submodule

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 2869270a..ce7b9d1a 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2869270a2c36924d76dd34eef9a91623005a7596
+Subproject commit ce7b9d1aa48cf65bb8071254e4e5396de410904b

From e7b687c3c3a16a7302823ad64548b2cb2bff3aa5 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 24 Jan 2022 12:23:38 +0100
Subject: [PATCH 250/509] Add support for testing postgresql-container in C9S

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/docker-tests.yml | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 78d9615e..2565e585 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -17,26 +17,33 @@ jobs:
             os_test: "fedora"
             context: "Fedora"
             compose: "CentOS-7"
-            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            tmt_url: "http://artifacts.dev.testing-farm.io"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "centos7"
             os_test: "centos7"
             context: "CentOS7"
             compose: "CentOS-7"
-            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            tmt_url: "http://artifacts.dev.testing-farm.io"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "rhel7-docker"
             os_test: "rhel7"
             context: "RHEL7"
             compose: "RHEL-7.9-Released"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
           - tmt_plan: "rhel8-docker"
             os_test: "rhel8"
             context: "RHEL8"
             compose: "RHEL-8.3.1-Released"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            tmt_url: "http://artifacts.osci.redhat.com/testing-farm"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+          - tmt_plan: "c9s"
+            os_test: "c9s"
+            context: "CentOS Stream 9"
+            compose: "CentOS-Stream-9"
+            tmt_url: "http://artifacts.dev.testing-farm.io"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
@@ -80,17 +87,16 @@ jobs:
             --data @pending.json
           echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
 
-      - name: Schedule a test on Testing Farm
+      - name: Schedule tests on Testing Farm
         id: sched_test
         run: |
           # Update ubuntu-20.04 in order to install curl and jq
           sudo apt update && sudo apt -y install curl jq
-          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then
+          api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
+          branch_name="master"
+          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ] || [ "${{ matrix.tmt_plan }}" == "c9s" ]; then
             api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
             branch_name="main"
-          else
-            api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
-            branch_name="master"
           fi
           cat << EOF > request.json
           {
@@ -109,6 +115,10 @@ jobs:
                 "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
                 "OS": "${{ matrix.os_test }}",
                 "TEST_NAME": "test"
+              },
+              "secrets": {
+                "QUAY_USERNAME": "${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}",
+                "QUAY_TOKEN": "${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}"
               }
             }]
           }

From ebede34ca400ae87a4aa60aae6f599097f22d8bf Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 2 Feb 2022 12:31:27 +0100
Subject: [PATCH 251/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index ce7b9d1a..57f24bc8 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit ce7b9d1aa48cf65bb8071254e4e5396de410904b
+Subproject commit 57f24bc833281e8dcaec97abd595ea96cac221a0

From 404880a6932be77bdfa18b27dea28ca98df6f1e9 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 2 Feb 2022 12:32:00 +0100
Subject: [PATCH 252/509] Remove 9.6 from Makefile

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2b5470ee..a1904360 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 9.6 10 11 12 13
+VERSIONS = 10 11 12 13
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 

From 46856749efc356894ba6733a5dcac404336ca973 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 2 Feb 2022 12:32:18 +0100
Subject: [PATCH 253/509] Remove 9.6 from README.md

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 README.md | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/README.md b/README.md
index ee28655e..351ba4ec 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,6 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently supported are:
-* [postgresql-9.6](https://github.com/sclorg/postgresql-container/tree/generated/9.6)
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
 * [postgresql-13](https://github.com/sclorg/postgresql-container/tree/generated/13)
@@ -81,9 +80,6 @@ In this repository [distgen](https://github.com/devexp-db/distgen/) is used for
 Usage
 ---------------------------------
 
-For information about usage of Dockerfile for PostgreSQL 9.6,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/9.6).
-
 For information about usage of Dockerfile for PostgreSQL 10,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
 

From 088bd54651304ad5ce6859cfd9d2ce2589cc978e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 2 Feb 2022 12:32:43 +0100
Subject: [PATCH 254/509] Remove 9.6 from RHEL 8

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 specs/multispec.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 0c6b5e4e..c67dc295 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -118,6 +118,7 @@ matrix:
         - fedora-34-x86_64
         - rhel-7-x86_64
         - centos-7-x86_64
+        - rhel-8-x86_64
       version: "9.6"
     - distros:
         - fedora-31-x86_64

From 105b64d85659ed65d2ef56a48f581e6041bf4d18 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 9 Feb 2022 11:49:54 +0100
Subject: [PATCH 255/509] Support building, testing and pushing C9S

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.sh         |  3 +++
 specs/multispec.yml | 18 ++++++++++++++++++
 src/Dockerfile      |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/manifest.sh b/manifest.sh
index 8270dba2..d501b0e5 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -38,6 +38,9 @@ DISTGEN_MULTI_RULES="
     src=src/Dockerfile
     dest=Dockerfile.rhel8;
 
+    src=src/Dockerfile
+    dest=Dockerfile.c9s;
+
     src=src/Dockerfile.fedora
     dest=Dockerfile.fedora;
 "
diff --git a/specs/multispec.yml b/specs/multispec.yml
index c67dc295..1e5c46c5 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -51,6 +51,19 @@ specs:
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
            yum -y reinstall tzdata && \
+    c9s:
+      distros:
+        - centos-stream-9-x86_64
+      s2i_base: quay.io/sclorg/s2i-core-c9s:c9s
+      org: "sclorg"
+      prod: "c9s"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+      redhat_component: "postgresql-{{ spec.short }}-container"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "postgresql-server postgresql-contrib"
+      environment_setup: >-4
+          yum -y install postgresql && \
+
     fedora:
       distros:
         - fedora-31-x86_64
@@ -107,6 +120,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
+      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f34"
 
@@ -119,20 +133,24 @@ matrix:
         - rhel-7-x86_64
         - centos-7-x86_64
         - rhel-8-x86_64
+        - centos-stream-9-x86_64
       version: "9.6"
     - distros:
         - fedora-31-x86_64
         - fedora-34-x86_64
+        - centos-stream-9-x86_64
       version: "10"
     - distros:
         - rhel-7-x86_64
         - rhel-8-x86_64
         - centos-7-x86_64
         - fedora-34-x86_64
+        - centos-stream-9-x86_64
       version: "11"
     - distros:
         - rhel-8-x86_64
         - fedora-34-x86_64
+        - centos-stream-9-x86_64
       version: "12"
     - distros:
         - fedora-31-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 6bf69a5d..8a1cf9e5 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -73,7 +73,7 @@ RUN {{ spec.environment_setup }}
 {% if spec.version not in ["9.6", "10", "11"] %}
     {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
-    {% elif spec.prod == 'rhel8' %}
+    {% elif spec.prod == 'rhel8' or spec.prod == 'c9s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     {% endif %}
 {% endif %}

From 9931278e5ea4887f520ba26fc870d52d0fd97ae9 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 9 Feb 2022 14:20:35 +0100
Subject: [PATCH 256/509] Add support for building and pushing into quay.io

CentOS 7 images are pushed to quay.io/centos7 organization
CentOS Stream 9 images are pushed to quay.io/sclorg organization

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 97 ++++++++++++++++++++++------
 1 file changed, 79 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 2f8f0023..a7962598 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -8,12 +8,39 @@ jobs:
   build-and-push:
     runs-on: ubuntu-latest
     strategy:
+      fail-fast: false
       matrix:
-        version: ["9.6", 10, 11, 12, 13]
+        include:
+          - version: "9.6"
+            dockerfile: "Dockerfile"
+            registry_namespace: "centos7"
+            tag: "centos7"
+          - version: "10"
+            dockerfile: "Dockerfile"
+            registry_namespace: "centos7"
+            tag: "centos7"
+          - version: "11"
+            dockerfile: "Dockerfile"
+            registry_namespace: "centos7"
+            tag: "centos7"
+          - version: "12"
+            dockerfile: "Dockerfile"
+            registry_namespace: "centos7"
+            tag: "centos7"
+          - version: "13"
+            dockerfile: "Dockerfile"
+            registry_namespace: "centos7"
+            tag: "centos7"
+          - version: "13"
+            dockerfile: "Dockerfile.c9s"
+            registry_namespace: "sclorg"
+            tag: "c9s"
+
     steps:
       - uses: actions/checkout@v2
         with:
           fetch-depth: 0
+          submodules: true
 
       - name: Get base image name
         id: base-image-name
@@ -24,9 +51,14 @@ jobs:
           BASE_IMAGE_ROW=${row/BASE_IMAGE_NAME = /}
           echo ::set-output name=image_name::$BASE_IMAGE_ROW
 
-      - name: Checkout into generated section
+      - name: Install python3 packages needed by distgen
+        run: |
+          sudo apt-get update -y && sudo apt-get install -y python3 python3-pip
+
+      - name: Install dist-gen package from PyPi
+        id: dist-gen-install
         run: |
-          git checkout --progress --force -B generated refs/remotes/origin/generated
+          pip3 -v install distgen
 
       - name: Get short version
         id: short_version
@@ -34,41 +66,70 @@ jobs:
           ver="${{ matrix.version }}"
           echo "::set-output name=SHORT_VER::${ver//./}"
 
-      - name: Check if dockerfile is present in version directory
+      - name: Generate source by dist-gen
+        id: generate
+        run: |
+          DG=$HOME/.local/bin/dg make generate-all
+
+      - name: Login to Quay.io private registry
+        if: ${{ matrix.tag == 'c9s' }}
+        uses: redhat-actions/podman-login@v1
+        with:
+          registry: quay.io
+          username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
+          password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
+
+      - name: Check if ${{ matrix.dockerfile }} is present in version directory
         id: check_dockerfile_file
         # https://github.com/marketplace/actions/file-existence
         uses: andstor/file-existence-action@v1
         with:
-          files: "${{ matrix.version }}/Dockerfile"
+          files: "${{ matrix.version }}/${{ matrix.dockerfile }}"
 
-      - name: Check if .exclude-centos7 is present in version directory
-        id: check_exclude_centos7_file
+      - name: Check if .exclude-${{ matrix.tag }} is present in version directory
+        id: check_exclude_file
         # https://github.com/marketplace/actions/file-existence
         uses: andstor/file-existence-action@v1
         with:
-          files: "${{ matrix.version }}/.exclude-centos7"
+          files: "${{ matrix.version }}/.exclude-${{ matrix.tag }}"
 
-      - name: Build CentOS7 image
-        if: steps.check_exclude_centos7_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
+      - name: Build image
+        if: steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
         id: build-image
         # https://github.com/marketplace/actions/buildah-build
         uses: redhat-actions/buildah-build@v2
         with:
-          dockerfiles: ${{ matrix.version }}/Dockerfile
-          image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.short_version.outputs.SHORT_VER }}-centos7
+          dockerfiles: ${{ matrix.version }}/${{ matrix.dockerfile }}
+          image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.short_version.outputs.SHORT_VER }}-${{ matrix.tag }}
           context: ${{ matrix.version }}
-          tags: latest 1 ${{ github.sha }}
+          tags: latest ${{ matrix.tag }} ${{ github.sha }}
 
-      - name: Push CentOS7 image to Quay.io
-        if: steps.check_exclude_centos7_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
-        id: push-to-quay
+      - name: Push CentOS 7 image to Quay.io
+        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'centos7' }}
+        id: push-to-quay-centos7
         uses: redhat-actions/push-to-registry@v2.2
         with:
           image: ${{ steps.build-image.outputs.image }}
           tags: ${{ steps.build-image.outputs.tags }}
-          registry: quay.io/centos7
+          registry: quay.io/${{ matrix.registry_namespace }}
           username: ${{ secrets.QUAY_IMAGE_BUILDER_USERNAME }}
           password: ${{ secrets.QUAY_IMAGE_BUILDER_TOKEN }}
 
+      - name: Push CentOS Stream 9 image to Quay.io
+        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'c9s' }}
+        id: push-to-quay-sclorg
+        uses: redhat-actions/push-to-registry@v2.2
+        with:
+          image: ${{ steps.build-image.outputs.image }}
+          tags: ${{ steps.build-image.outputs.tags }}
+          registry: quay.io/${{ matrix.registry_namespace }}
+          username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
+          password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
+
+      - name: Print image url
+        if: ${{ matrix.tag == 'centos7' }}
+        run: echo "Image pushed to ${{ steps.push-to-quay-centos7.outputs.registry-paths }}"
+
       - name: Print image url
-        run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
+        if: ${{ matrix.tag == 'c9s' }}
+        run: echo "Image pushed to ${{ steps.push-to-quay-sclorg.outputs.registry-paths }}"

From 2efa022837ec9c34114c4563dd43ab4a5cd10bfa Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 15 Feb 2022 15:35:15 +0100
Subject: [PATCH 257/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 57f24bc8..789ca3e7 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 57f24bc833281e8dcaec97abd595ea96cac221a0
+Subproject commit 789ca3e7e4b5625b87d1c71672b26407f040950d

From 1717890f7737f9a0cac095baa49f92a554838fda Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 24 Feb 2022 09:32:41 +0100
Subject: [PATCH 258/509] Use Testing Farm as Github Action

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/docker-tests.yml | 169 +++++------------------------
 1 file changed, 26 insertions(+), 143 deletions(-)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 2565e585..a07e2f83 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -1,4 +1,4 @@
-name: container-tests at Testing Farm
+name: Container-tests by GitHub Action at Testing Farm
 
 on:
   issue_comment:
@@ -7,7 +7,7 @@ on:
 jobs:
   build:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Container tests on Testing Farm service
+    name: Container-tests by GitHub Action on Testing Farm service
     runs-on: ubuntu-20.04
     strategy:
       fail-fast: false
@@ -17,32 +17,22 @@ jobs:
             os_test: "fedora"
             context: "Fedora"
             compose: "CentOS-7"
-            tmt_url: "http://artifacts.dev.testing-farm.io"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "centos7"
             os_test: "centos7"
             context: "CentOS7"
             compose: "CentOS-7"
-            tmt_url: "http://artifacts.dev.testing-farm.io"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "rhel7-docker"
             os_test: "rhel7"
             context: "RHEL7"
             compose: "RHEL-7.9-Released"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
           - tmt_plan: "rhel8-docker"
             os_test: "rhel8"
             context: "RHEL8"
             compose: "RHEL-8.3.1-Released"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
           - tmt_plan: "c9s"
             os_test: "c9s"
             context: "CentOS Stream 9"
             compose: "CentOS-Stream-9"
-            tmt_url: "http://artifacts.dev.testing-farm.io"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
 
     if: |
       github.event.issue.pull_request
@@ -65,141 +55,34 @@ jobs:
         run: |
           echo "::set-output name=SHA::$(git rev-parse HEAD)"
 
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: Setup Testing Farm values
+        id: tf_values
         run: |
-          # Create a JSON data structure for GitHub API to display the test status in the PR
-          cat << EOF > pending.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "pending",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "target_url": "${{ matrix.tmt_url }}"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule tests on Testing Farm
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          sudo apt update && sudo apt -y install curl jq
-          api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
           branch_name="master"
+          api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
+          tmt_repo="https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
           if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ] || [ "${{ matrix.tmt_plan }}" == "c9s" ]; then
             api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
             branch_name="main"
+            tmt_repo="https://github.com/sclorg/sclorg-testing-farm"
           fi
-          cat << EOF > request.json
-          {
-            "api_key": "$api_key",
-            "test": {"fmf": {
-              "url": "${{ matrix.tmt_repo }}",
-              "ref": "$branch_name",
-              "name": "${{ matrix.tmt_plan }}"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "${{ matrix.compose }}"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "${{ matrix.os_test }}",
-                "TEST_NAME": "test"
-              },
-              "secrets": {
-                "QUAY_USERNAME": "${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}",
-                "QUAY_TOKEN": "${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          cat response.json
-          
-          # Store REQ_ID into outputs for later on usage
-          req_id=$(jq -r .id response.json)
-          echo "REQ_ID=$req_id" >> $GITHUB_ENV
-
-      - name: Switch to running state of Testing Farm request
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "pending",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "description": "Build started",
-            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @running.json
+          echo "::set-output name=API_KEY::$api_key"
+          echo "::set-output name=BRANCH_NAME::$branch_name"
+          echo "::set-output name=TMT_REPO::$tmt_repo"
+        shell: bash
 
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }}
-          curl $CMD > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "${{ steps.final_state.outputs.FINAL_STATE }}",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}",
-            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @final.json
+      # https://github.com/sclorg/testing-farm-as-github-action
+      - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
+        id: github_action
+        uses: sclorg/testing-farm-as-github-action@v1
+        with:
+          api_key: ${{ steps.tf_values.outputs.API_KEY }}
+          git_url: ${{ steps.tf_values.outputs.TMT_REPO }}
+          git_ref: ${{ steps.tf_values.outputs.BRANCH_NAME }}
+          tmt_plan_regex: ${{ matrix.tmt_plan }}
+          pull_request_status_name: ${{ matrix.context }}
+          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ steps.pr_nr.outputs.PR_NR }};OS=${{ matrix.os_test }};TEST_NAME=test"
+          secrets: "QUAY_USERNAME=${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }};QUAY_TOKEN=${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}"
+          compose: ${{ matrix.compose }}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

From a8c1e1beb9cbb2cfa7ebabda597189fcd748da24 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 24 Feb 2022 09:33:13 +0100
Subject: [PATCH 259/509] Rename docker-tests.yml -> container-tests.yml

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/{docker-tests.yml => container-tests.yml} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename .github/workflows/{docker-tests.yml => container-tests.yml} (100%)

diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/container-tests.yml
similarity index 100%
rename from .github/workflows/docker-tests.yml
rename to .github/workflows/container-tests.yml

From 119033f2678cb265ca2ae5299043e741113e2bda Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 24 Feb 2022 09:35:23 +0100
Subject: [PATCH 260/509] Do not run build-and-push on forks

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index a7962598..597ace46 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -6,6 +6,8 @@ on:
 
 jobs:
   build-and-push:
+    # To not run in forks
+    if: github.repository_owner == 'sclorg'
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false

From 5c46044486ef1fbd46653fb81bf34adf8109eaf4 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Fri, 11 Mar 2022 15:48:38 +0100
Subject: [PATCH 261/509] Update README.md

update the docs to mirror the move of centos7 images to quay.io

Fixes: #433
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 351ba4ec..0276ee06 100644
--- a/README.md
+++ b/README.md
@@ -53,10 +53,10 @@ Choose either the CentOS7 or RHEL7 based image:
 
 *  **CentOS7 based image**
 
-    These images are available on DockerHub. To download it run:
+    These images are available on Quay.io. To download it run:
 
     ```
-    $ podman pull centos/postgresql-13-centos7
+    $ podman pull quay.io/centos7/postgresql-13-centos7
     ```
 
     To build a PostgreSQL image from scratch run:

From e0c5c7924407a06dbf7e370d9877989860a8d088 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 21 Mar 2022 08:47:48 +0100
Subject: [PATCH 262/509] use composite build-and-push-action

- and rebuild container image every wednesday
---
 .github/workflows/build-and-push.yml | 133 +++++++--------------------
 1 file changed, 32 insertions(+), 101 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index a7962598..9f6f5fb4 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -3,133 +3,64 @@ on:
   push:
     branches:
       - master
+  schedule:
+      - cron: '0 1 * * 3'
 
 jobs:
   build-and-push:
+    if: github.repository_owner == 'sclorg'
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
       matrix:
         include:
-          - version: "9.6"
+          - dockerfile_path: "9.6"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-          - version: "10"
+            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
+          - dockerfile_path: "10"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-          - version: "11"
+            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
+          - dockerfile_path: "11"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-          - version: "12"
+            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
+          - dockerfile_path: "12"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-          - version: "13"
+            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
+          - dockerfile_path: "13"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-          - version: "13"
+            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
+          - dockerfile_path: "13"
             dockerfile: "Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
 
     steps:
-      - uses: actions/checkout@v2
+      - name: Build and push to quay.io registry
+        uses: sclorg/build-and-push-action@v1
         with:
-          fetch-depth: 0
-          submodules: true
-
-      - name: Get base image name
-        id: base-image-name
-        run: |
-          # This command returns row with BASE_IMAGE_NAME
-          row=$(grep "BASE_IMAGE_NAME" Makefile)
-          # Return only base image name
-          BASE_IMAGE_ROW=${row/BASE_IMAGE_NAME = /}
-          echo ::set-output name=image_name::$BASE_IMAGE_ROW
-
-      - name: Install python3 packages needed by distgen
-        run: |
-          sudo apt-get update -y && sudo apt-get install -y python3 python3-pip
-
-      - name: Install dist-gen package from PyPi
-        id: dist-gen-install
-        run: |
-          pip3 -v install distgen
-
-      - name: Get short version
-        id: short_version
-        run: |
-          ver="${{ matrix.version }}"
-          echo "::set-output name=SHORT_VER::${ver//./}"
-
-      - name: Generate source by dist-gen
-        id: generate
-        run: |
-          DG=$HOME/.local/bin/dg make generate-all
-
-      - name: Login to Quay.io private registry
-        if: ${{ matrix.tag == 'c9s' }}
-        uses: redhat-actions/podman-login@v1
-        with:
-          registry: quay.io
-          username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
-          password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
-
-      - name: Check if ${{ matrix.dockerfile }} is present in version directory
-        id: check_dockerfile_file
-        # https://github.com/marketplace/actions/file-existence
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/${{ matrix.dockerfile }}"
-
-      - name: Check if .exclude-${{ matrix.tag }} is present in version directory
-        id: check_exclude_file
-        # https://github.com/marketplace/actions/file-existence
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/.exclude-${{ matrix.tag }}"
-
-      - name: Build image
-        if: steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true'
-        id: build-image
-        # https://github.com/marketplace/actions/buildah-build
-        uses: redhat-actions/buildah-build@v2
-        with:
-          dockerfiles: ${{ matrix.version }}/${{ matrix.dockerfile }}
-          image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.short_version.outputs.SHORT_VER }}-${{ matrix.tag }}
-          context: ${{ matrix.version }}
-          tags: latest ${{ matrix.tag }} ${{ github.sha }}
-
-      - name: Push CentOS 7 image to Quay.io
-        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'centos7' }}
-        id: push-to-quay-centos7
-        uses: redhat-actions/push-to-registry@v2.2
-        with:
-          image: ${{ steps.build-image.outputs.image }}
-          tags: ${{ steps.build-image.outputs.tags }}
-          registry: quay.io/${{ matrix.registry_namespace }}
-          username: ${{ secrets.QUAY_IMAGE_BUILDER_USERNAME }}
-          password: ${{ secrets.QUAY_IMAGE_BUILDER_TOKEN }}
-
-      - name: Push CentOS Stream 9 image to Quay.io
-        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile_file.outputs.files_exists == 'true' && matrix.tag == 'c9s' }}
-        id: push-to-quay-sclorg
-        uses: redhat-actions/push-to-registry@v2.2
-        with:
-          image: ${{ steps.build-image.outputs.image }}
-          tags: ${{ steps.build-image.outputs.tags }}
-          registry: quay.io/${{ matrix.registry_namespace }}
-          username: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }}
-          password: ${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}
-
-      - name: Print image url
-        if: ${{ matrix.tag == 'centos7' }}
-        run: echo "Image pushed to ${{ steps.push-to-quay-centos7.outputs.registry-paths }}"
-
-      - name: Print image url
-        if: ${{ matrix.tag == 'c9s' }}
-        run: echo "Image pushed to ${{ steps.push-to-quay-sclorg.outputs.registry-paths }}"
+          registry: "quay.io"
+          registry_namespace: ${{ matrix.registry_namespace }}
+          registry_username: ${{ secrets[matrix.quayio_username] }}
+          registry_token: ${{ secrets[matrix.quayio_token] }}
+          dockerfile: ${{ matrix.dockerfile }}
+          docker_context: ${{ matrix.dockerfile_path }}
+          dockerfile_path: ${{ matrix.dockerfile_path }}
+          tag: ${{ matrix.tag }}
+          use_distgen: "true"

From 9faa54d3e3e235d40026b232aee605f956231e74 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 23 Mar 2022 12:45:21 +0100
Subject: [PATCH 263/509] do not build v9.6, as it reached EOL

---
 .github/workflows/build-and-push.yml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 9f6f5fb4..a89a119a 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -14,12 +14,6 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - dockerfile_path: "9.6"
-            dockerfile: "Dockerfile"
-            registry_namespace: "centos7"
-            tag: "centos7"
-            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
           - dockerfile_path: "10"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"

From ae24561607341690d76168feb98828490370a830 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 23 Mar 2022 13:14:47 +0100
Subject: [PATCH 264/509] Update container-tests.yml

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml  |  2 -
 .github/workflows/container-tests.yml | 59 +++++++++++----------------
 2 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 597ace46..a7962598 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -6,8 +6,6 @@ on:
 
 jobs:
   build-and-push:
-    # To not run in forks
-    if: github.repository_owner == 'sclorg'
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index a07e2f83..b87a418a 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -17,72 +17,59 @@ jobs:
             os_test: "fedora"
             context: "Fedora"
             compose: "CentOS-7"
+            api_key: "TF_PUBLIC_API_KEY"
+            branch: "main"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "centos7"
             os_test: "centos7"
             context: "CentOS7"
             compose: "CentOS-7"
+            api_key: "TF_PUBLIC_API_KEY"
+            branch: "main"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
           - tmt_plan: "rhel7-docker"
             os_test: "rhel7"
             context: "RHEL7"
             compose: "RHEL-7.9-Released"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tf_scope: "private"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
           - tmt_plan: "rhel8-docker"
             os_test: "rhel8"
             context: "RHEL8"
             compose: "RHEL-8.3.1-Released"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
           - tmt_plan: "c9s"
             os_test: "c9s"
             context: "CentOS Stream 9"
             compose: "CentOS-Stream-9"
-
+            api_key: "TF_PUBLIC_API_KEY"
+            branch: "main"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
       - name: Checkout repo
         uses: actions/checkout@v2
         with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
-
-      - name: SHA value
-        id: sha_value
-        run: |
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Setup Testing Farm values
-        id: tf_values
-        run: |
-          branch_name="master"
-          api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
-          tmt_repo="https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ] || [ "${{ matrix.tmt_plan }}" == "c9s" ]; then
-            api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
-            branch_name="main"
-            tmt_repo="https://github.com/sclorg/sclorg-testing-farm"
-          fi
-          echo "::set-output name=API_KEY::$api_key"
-          echo "::set-output name=BRANCH_NAME::$branch_name"
-          echo "::set-output name=TMT_REPO::$tmt_repo"
-        shell: bash
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
 
       # https://github.com/sclorg/testing-farm-as-github-action
       - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
         id: github_action
         uses: sclorg/testing-farm-as-github-action@v1
         with:
-          api_key: ${{ steps.tf_values.outputs.API_KEY }}
-          git_url: ${{ steps.tf_values.outputs.TMT_REPO }}
-          git_ref: ${{ steps.tf_values.outputs.BRANCH_NAME }}
+          api_key: ${{ secrets[matrix.api_key] }}
+          git_url: ${{ matrix.tmt_repo }}
+          git_ref: ${{ matrix.branch }}
+          tf_scope: ${{ matrix.tf_scope }}
           tmt_plan_regex: ${{ matrix.tmt_plan }}
           pull_request_status_name: ${{ matrix.context }}
-          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ steps.pr_nr.outputs.PR_NR }};OS=${{ matrix.os_test }};TEST_NAME=test"
-          secrets: "QUAY_USERNAME=${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_USERNAME }};QUAY_TOKEN=${{ secrets.QUAY_IMAGE_SCLORG_BUILDER_TOKEN }}"
+          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};OS=${{ matrix.os_test }};TEST_NAME=test"
           compose: ${{ matrix.compose }}
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

From f7ba29b0441bb07776579bcabf7c4a83f2ef24ff Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Wed, 23 Mar 2022 14:40:44 +0100
Subject: [PATCH 265/509] Update .github/workflows/container-tests.yml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Zuzana Miklánková <zmiklank@redhat.com>
---
 .github/workflows/container-tests.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index b87a418a..20f9a503 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -62,7 +62,6 @@ jobs:
 
       # https://github.com/sclorg/testing-farm-as-github-action
       - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
-        id: github_action
         uses: sclorg/testing-farm-as-github-action@v1
         with:
           api_key: ${{ secrets[matrix.api_key] }}

From 045e1036eeab94f2c74369901c0fc826bd028d64 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 13 Apr 2022 09:58:02 +0200
Subject: [PATCH 266/509] do not build v11 for centos7

---
 .github/workflows/build-and-push.yml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index a89a119a..8bfa57cc 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -20,12 +20,6 @@ jobs:
             tag: "centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-          - dockerfile_path: "11"
-            dockerfile: "Dockerfile"
-            registry_namespace: "centos7"
-            tag: "centos7"
-            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
           - dockerfile_path: "12"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"

From 9c6dd607cd0c316ce3daeb50294116df3882d5c5 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 19 Apr 2022 13:01:40 +0200
Subject: [PATCH 267/509] Allow testing container in CentOS Stream 8

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 20f9a503..1e017c9c 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -50,6 +50,13 @@ jobs:
             api_key: "TF_PUBLIC_API_KEY"
             branch: "main"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+          - tmt_plan: "c8s"
+            os_test: "c8s"
+            context: "CentOS Stream 8"
+            compose: "CentOS-Stream-8"
+            api_key: "TF_PUBLIC_API_KEY"
+            branch: "main"
+            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))

From fb16205adf02e056334f7991875cd3a38b52e19f Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 22 Apr 2022 12:57:55 +0200
Subject: [PATCH 268/509] Use Fedora-latest compose for Fedora tests

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 1e017c9c..d7982812 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -16,7 +16,7 @@ jobs:
           - tmt_plan: "fedora"
             os_test: "fedora"
             context: "Fedora"
-            compose: "CentOS-7"
+            compose: "Fedora-latest"
             api_key: "TF_PUBLIC_API_KEY"
             branch: "main"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"

From 95d32c15bac86333c0152ed458b2a28392e36e51 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 22 Apr 2022 13:31:18 +0200
Subject: [PATCH 269/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 789ca3e7..fcc0742b 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 789ca3e7e4b5625b87d1c71672b26407f040950d
+Subproject commit fcc0742b13ba0496f484e50a47f8945d86e37a5a

From 5600fa000c7098c85f470501531a0e06411023da Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 22 Apr 2022 13:31:36 +0200
Subject: [PATCH 270/509] Use s2i-core from quay.io

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile.fedora | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index a53ae6aa..577e775a 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM registry.fedoraproject.org/{{ spec.latest_fedora }}/s2i-core:latest
+FROM quay.io/fedora/s2i-core:35
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -33,9 +33,9 @@ LABEL summary="$SUMMARY" \
       io.openshift.tags="database,postgresql,postgresql{{ spec.short }}" \
       com.redhat.component="$NAME" \
       maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="$FGC/$NAME" \
+      name="fedora/$NAME-{{ spec.short }}" \
       version="0" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 $FGC/$NAME"
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-{{ spec.short }}"
 
 EXPOSE 5432
 

From 3a3c34460f022e8b4b192f1c036e417b08d78456 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 22 Apr 2022 13:45:55 +0200
Subject: [PATCH 271/509] Build and push update for versions - 11, 12, 13

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 8bfa57cc..2cd0d040 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -18,30 +18,52 @@ jobs:
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
+            suffix: "centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
           - dockerfile_path: "12"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
+            suffix: "centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
           - dockerfile_path: "13"
             dockerfile: "Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
+            suffix: "centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
           - dockerfile_path: "13"
             dockerfile: "Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
+            suffix: "c8s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+          - dockerfile_path: "11"
+            dockerfile: "Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "11"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+          - dockerfile_path: "12"
+            dockerfile: "Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "12"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+          - dockerfile_path: "13"
+            dockerfile: "Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "13"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
 
     steps:
       - name: Build and push to quay.io registry
-        uses: sclorg/build-and-push-action@v1
+        uses: sclorg/build-and-push-action@v2
         with:
           registry: "quay.io"
           registry_namespace: ${{ matrix.registry_namespace }}
@@ -52,3 +74,4 @@ jobs:
           dockerfile_path: ${{ matrix.dockerfile_path }}
           tag: ${{ matrix.tag }}
           use_distgen: "true"
+          suffix: ${{ matrix.suffix }}

From fc8fd2a6033fb53d0830afbfad777e95d1209f11 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 26 Apr 2022 10:15:20 +0200
Subject: [PATCH 272/509] Update .github/workflows/build-and-push.yml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Zuzana Miklánková <zmiklank@redhat.com>
---
 .github/workflows/build-and-push.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 2cd0d040..9a49f5f5 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -39,7 +39,7 @@ jobs:
             dockerfile: "Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
-            suffix: "c8s"
+            suffix: "c9s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
           - dockerfile_path: "11"

From abf8488816840149dbd58c240ce07118c3718446 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 28 Apr 2022 14:12:27 +0200
Subject: [PATCH 273/509] Use Testing Farm as GitHub Action also for OpenShift
 tests

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/openshift-tests.yml | 186 +++++---------------------
 1 file changed, 32 insertions(+), 154 deletions(-)

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 6cbe4c75..29aed6c6 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -1,4 +1,4 @@
-name: openshift-tests at Testing Farm
+name: OpenShift tests by GitHub Action at Testing Farm
 
 on:
   issue_comment:
@@ -6,8 +6,8 @@ on:
       - created
 jobs:
   build:
-    # This job only runs for '[test]' pull request comments by owner, member
-    name: OpenShift tests on Testing Farm service
+    # This job only runs for '[test-all]' or '[test-openshift] pull request comments by owner, member
+    name: OpenShift tests by GitHub Action on Testing Farm service
     runs-on: ubuntu-20.04
     strategy:
       fail-fast: false
@@ -16,184 +16,62 @@ jobs:
           - tmt_plan: "centos7"
             os_test: "centos7"
             context: "CentOS7 - OpenShift 3"
-            compose: "CentOS-7"
-            tmt_url: "http://artifacts.dev.testing-farm.io/"
+            api_key: "TF_PUBLIC_API_KEY"
+            branch: "main"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+            compose: "CentOS-7"
             test_name: "test-openshift"
           - tmt_plan: "rhel7-openshift-3"
             os_test: "rhel7"
             context: "RHEL7 - OpenShift 3"
             compose: "RHEL-7.9-Released"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
             tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             test_name: "test-openshift"
+            tf_scope: "private"
           - tmt_plan: "rhel7-openshift-4"
             os_test: "rhel7"
             context: "RHEL7 - OpenShift 4"
             compose: "RHEL-7.9-Released"
             tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             test_name: "test-openshift-4"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
           - tmt_plan: "rhel8-openshift-4"
             os_test: "rhel8"
             context: "RHEL8 - OpenShift 4"
             compose: "RHEL-8.3.1-Released"
             tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             test_name: "test-openshift-4"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
+
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
-      - name: Get pull request number
-        id: pr_nr
-        run: |
-          PR_URL="${{ github.event.comment.issue_url }}"
-          echo "::set-output name=PR_NR::${PR_URL##*/}"
-
       - name: Checkout repo
         uses: actions/checkout@v2
         with:
-          ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head"
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
 
-      - name: SHA value
-        id: sha_value
-        run: |
-          echo "::set-output name=SHA::$(git rev-parse HEAD)"
-
-      - name: Create status check to pending
-        id: pending
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Create a JSON file for Testing Farm in order to schedule a CI testing job
-          cat << EOF > pending.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "pending",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "target_url": "${{ matrix.tmt_url }}"
-          }
-          EOF
-          echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}"
-          # GITHUB_TOKEN is used for updating pull request status.
-          # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
-          curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @pending.json
-          echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY"
-
-      - name: Schedule a test on Testing Farm
-        id: sched_test
-        run: |
-          # Update ubuntu-20.04 in order to install curl and jq
-          sudo apt update && sudo apt -y install curl jq
-          if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then
-            api_key="${{ secrets.TF_PUBLIC_API_KEY }}"
-            branch_name="main"
-          else
-            api_key="${{ secrets.TF_INTERNAL_API_KEY }}"
-            branch_name="master"
-          fi
-          cat << EOF > request.json
-          {
-            "api_key": "$api_key",
-            "test": {"fmf": {
-              "url": "${{ matrix.tmt_repo }}",
-              "ref": "$branch_name",
-              "name": "${{ matrix.tmt_plan }}"
-            }},
-            "environments": [{
-              "arch": "x86_64",
-              "os": {"compose": "${{ matrix.compose }}"},
-              "variables": {
-                "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY",
-                "REPO_NAME": "$GITHUB_REPOSITORY",
-                "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}",
-                "OS": "${{ matrix.os_test }}",
-                "TEST_NAME": "${{ matrix.test_name }}"
-              }
-            }]
-          }
-          EOF
-          curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json
-          cat response.json
-
-          # Store REQ_ID into outputs for later on usage
-          req_id=$(jq -r .id response.json)
-          echo "REQ_ID=$req_id" >> $GITHUB_ENV
-
-      - name: Switch to running state of Testing Farm request
-        id: running
-        run: |
-          # Create running.json file for query, whether job is finished or not.
-          cat << EOF > running.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "pending",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "description": "Build started",
-            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
-          }
-          EOF
-          # Update GitHub status description to 'Build started'
-          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @running.json
-
-      - name: Check test is still running
-        id: still_running
-        run: |
-          CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }}
-          curl $CMD > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          # Wait till job is not finished. As soon as state is complete or failure then go to the finish action
-          while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do
-            # Wait 30s. We do not need to query Testing Farm each second
-            sleep 30
-            curl $CMD > job.json
-            state=$(jq -r .state job.json)
-          done
-
-      - name: Get final state of Testing Farm request
-        id: final_state
-        run: |
-          curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json
-          cat job.json
-          state=$(jq -r .state job.json)
-          result=$(jq -r .result.overall job.json)
-          new_state="success"
-          infra_error=" "
-          echo "State is $state and result is: $result"
-          if [ "$state" == "complete" ]; then
-            if [ "$result" != "passed" ]; then
-              new_state="failure"
-            fi
-          else
-            # Mark job in case of infrastructure issues. Report to Testing Farm team
-            infra_error=" - Infra problems"
-            new_state="failure"
-          fi
-          echo "New State is: $new_state"
-          echo "Infra state is: $infra_error"
-          echo "::set-output name=FINAL_STATE::$new_state"
-          echo "::set-output name=INFRA_STATE::$infra_error"
-
-      - name: Switch to final state of Testing Farm request
-        run: |
-          cat << EOF > final.json
-          {
-            "sha": "${{ steps.sha_value.outputs.SHA }}",
-            "state": "${{ steps.final_state.outputs.FINAL_STATE }}",
-            "context": "Testing Farm - ${{ matrix.context }}",
-            "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}",
-            "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}"
-          }
-          EOF
-          cat final.json
-          # Switch Github status to proper state
-          curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-            https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \
-            --data @final.json
+      # https://github.com/sclorg/testing-farm-as-github-action
+      - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
+        id: github_action
+        uses: sclorg/testing-farm-as-github-action@v1
+        with:
+          api_key: ${{ secrets[matrix.api_key] }}
+          git_url: ${{ matrix.tmt_repo }}
+          git_ref: ${{ matrix.branch }}
+          tf_scope: ${{ matrix.tf_scope }}
+          tmt_plan_regex: ${{ matrix.tmt_plan }}
+          pull_request_status_name: ${{ matrix.context }}
+          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};OS=${{ matrix.os_test }};TEST_NAME=${{ matrix.test_name }}"
+          compose: ${{ matrix.compose }}

From 66aede5390f7b32d3c71039e52f2552c3b373597 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 2 May 2022 13:28:20 +0200
Subject: [PATCH 274/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index fcc0742b..f655710e 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit fcc0742b13ba0496f484e50a47f8945d86e37a5a
+Subproject commit f655710e567a22fc653679e9496ef7de639f6ad3

From 8c8eb68b557a2c828ca632e1d3bef1e3ad0fc4bb Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 2 May 2022 13:29:06 +0200
Subject: [PATCH 275/509] Add CentOS Stream 8 to distgen source files

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.sh         |  3 +++
 specs/multispec.yml | 17 +++++++++++++++++
 src/Dockerfile      |  4 ++--
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/manifest.sh b/manifest.sh
index d501b0e5..ee8c1c79 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -41,6 +41,9 @@ DISTGEN_MULTI_RULES="
     src=src/Dockerfile
     dest=Dockerfile.c9s;
 
+    src=src/Dockerfile
+    dest=Dockerfile.c8s;
+
     src=src/Dockerfile.fedora
     dest=Dockerfile.fedora;
 "
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 1e5c46c5..ccbd6706 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -63,6 +63,20 @@ specs:
       pkgs: "postgresql-server postgresql-contrib"
       environment_setup: >-4
           yum -y install postgresql && \
+    c8s:
+      distros:
+        - centos-stream-8-x86_64
+      s2i_base: quay.io/sclorg/s2i-core-c8s:c8s
+      org: "sclorg"
+      prod: "c8s"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+      redhat_component: "postgresql-{{ spec.short }}-container"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "postgresql-server postgresql-contrib"
+      environment_setup: >-4
+          yum -y module enable postgresql:{{ spec.version }} && \
+      post_install: >-4
+          yum -y reinstall tzdata && \
 
     fedora:
       distros:
@@ -133,6 +147,7 @@ matrix:
         - rhel-7-x86_64
         - centos-7-x86_64
         - rhel-8-x86_64
+        - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "9.6"
     - distros:
@@ -145,11 +160,13 @@ matrix:
         - rhel-8-x86_64
         - centos-7-x86_64
         - fedora-34-x86_64
+        - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "11"
     - distros:
         - rhel-8-x86_64
         - fedora-34-x86_64
+        - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "12"
     - distros:
diff --git a/src/Dockerfile b/src/Dockerfile
index 8a1cf9e5..198ed393 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -73,7 +73,7 @@ RUN {{ spec.environment_setup }}
 {% if spec.version not in ["9.6", "10", "11"] %}
     {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
-    {% elif spec.prod == 'rhel8' or spec.prod == 'c9s' %}
+    {% elif spec.prod == 'rhel8' or spec.prod == 'c9s' or spec.prod == 'c8s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     {% endif %}
 {% endif %}
@@ -95,7 +95,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
-{% if spec.prod != "rhel8" and config.os.id != "fedora" %}
+{% if spec.prod != "rhel8" and config.os.id != "fedora" and spec.prod != "c8s" and spec.prod != "c9s" %}
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.

From 2c2f8c7c23954b3a7bb379cf2293b314a417dd4f Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 2 May 2022 13:29:31 +0200
Subject: [PATCH 276/509] Update README.md with building status

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 0276ee06..56f3808c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 PostgreSQL container images
 ========================
 
-PostgreSQL 10 status:[![Docker Repository on Quay](https://quay.io/repository/centos7/postgresql-10-centos7/status "Docker Repository on Quay")](https://quay.io/repository/centos7/postgresql-10-centos7), PostgreSQL 12 status:[![Docker Repository on Quay](https://quay.io/repository/centos7/postgresql-12-centos7/status "Docker Repository on Quay")](https://quay.io/repository/centos7/postgresql-12-centos7)
+[![Build and push images to Quay.io registry](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml/badge.svg)](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml)
 
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.

From 9faa69802b68d013e8fa3b007922f2c955849ecf Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 3 May 2022 12:02:55 +0200
Subject: [PATCH 277/509] Support C8S images for postgresql-10 and postgresql13
 on quay.io/sclorg

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 9a49f5f5..8e785f46 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -42,6 +42,20 @@ jobs:
             suffix: "c9s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+          - dockerfile_path: "10"
+            dockerfile: "Dockerfile.c8s"
+            registry_namespace: "sclorg"
+            tag: "c8s"
+            suffix: "c8s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+          - dockerfile_path: "13"
+            dockerfile: "Dockerfile.c8s"
+            registry_namespace: "sclorg"
+            tag: "c8s"
+            suffix: "c8s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
           - dockerfile_path: "11"
             dockerfile: "Dockerfile.fedora"
             registry_namespace: "fedora"

From e90bd50d76faf34e35a644b5d470dd22a9e0b700 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Wed, 25 May 2022 17:08:50 -0400
Subject: [PATCH 278/509] Add rhel9 imagestreams

---
 imagestreams/postgresql-rhel-aarch64.json | 18 ++++++++++++++++++
 imagestreams/postgresql-rhel.json         | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index d8a16c00..db5121c2 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -26,6 +26,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index adc8def3..cf87748f 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -26,6 +26,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "13-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "13"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el8",
         "annotations": {

From 052f1ff3afb62c85fb3284f1a275c0c2dbafa192 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 27 May 2022 09:05:36 +0200
Subject: [PATCH 279/509] Update common sub-module

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index f655710e..ef528b36 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit f655710e567a22fc653679e9496ef7de639f6ad3
+Subproject commit ef528b3689dc75bbfdd5b57251699c4101ef17c6

From 1a5ba65f4d5091e97c756bce70e741ecbe54eac5 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 31 May 2022 15:09:06 +0200
Subject: [PATCH 280/509] Use RHEL-8.6 compose and update
 container-common-scritps

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 common                                | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index d7982812..0241b8f8 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -38,7 +38,7 @@ jobs:
           - tmt_plan: "rhel8-docker"
             os_test: "rhel8"
             context: "RHEL8"
-            compose: "RHEL-8.3.1-Released"
+            compose: "RHEL-8.6.0-Nightly"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 29aed6c6..ce59abc3 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -44,7 +44,7 @@ jobs:
           - tmt_plan: "rhel8-openshift-4"
             os_test: "rhel8"
             context: "RHEL8 - OpenShift 4"
-            compose: "RHEL-8.3.1-Released"
+            compose: "RHEL-8.6.0-Nightly"
             tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
diff --git a/common b/common
index ef528b36..58b21d3e 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit ef528b3689dc75bbfdd5b57251699c4101ef17c6
+Subproject commit 58b21d3ea5b6ffcbd976cfb7519c061b8df3c761

From 07064a1311188d8fc950bc1d81844971af5a6421 Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka@redhat.com>
Date: Thu, 9 Jun 2022 10:53:55 +0200
Subject: [PATCH 281/509] Update description of POSTGRESQL_SHARED_BUFFERS &
 POSTGRESQL_EFFECTIVE_CACHE_SIZE default values

The previous description was not completely correct, because when the container
is run in Kubernetes/Openshift, the default values are calculated:
https://github.com/sclorg/postgresql-container/blob/master/src/root/usr/share/container-scripts/postgresql/common.sh#L12
based on memory limit:
https://github.com/sclorg/container-common-scripts/blob/master/shared-scripts/core/usr/bin/cgroup-limits
---
 src/root/usr/share/container-scripts/postgresql/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index bc01aa9f..5c24050f 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -95,10 +95,10 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
        Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
-**`POSTGRESQL_SHARED_BUFFERS (default: 32M)`**  
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
        Sets how much memory is dedicated to PostgreSQL to use for caching data
 
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 128M)`**  
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 

From b8fa8e1f2a2ff43c09664e01df3cb84927b3af65 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 13 Jun 2022 10:22:35 +0200
Subject: [PATCH 282/509] Use OpenShift internal registry instead of external

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common                            | 2 +-
 test/run-openshift-remote-cluster | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common b/common
index 58b21d3e..2269a3ec 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 58b21d3ea5b6ffcbd976cfb7519c061b8df3c761
+Subproject commit 2269a3ec3d32410d34807b847728520b601bdfcd
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 00d0f555..32614ee0 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -22,8 +22,8 @@ ct_os_check_compulsory_vars
 
 oc status || false "It looks like oc is not properly logged in."
 
-# For testing on OpenShift 4 we use external registry
-export CT_EXTERNAL_REGISTRY=true
+# For testing on OpenShift 4 we use internal registry
+export CT_OCP4_TEST=true
 
 # Check the template
 test_postgresql_integration "${IMAGE_NAME}"

From fc00aabd7378e0669429b41d7ea9efe9c18e0a24 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 14 Jun 2022 14:04:59 +0200
Subject: [PATCH 283/509] Enable testing postgresql-container on RHEL9 host

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml |  8 ++++++++
 .github/workflows/openshift-tests.yml | 12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 0241b8f8..6a7fc5c4 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -43,6 +43,14 @@ jobs:
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             tf_scope: "private"
+          - tmt_plan: "rhel9-docker"
+            os_test: "rhel9"
+            context: "RHEL9"
+            compose: "RHEL-9.1.0-Nightly"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
           - tmt_plan: "c9s"
             os_test: "c9s"
             context: "CentOS Stream 9"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index ce59abc3..7f44c432 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -27,7 +27,6 @@ jobs:
             compose: "RHEL-7.9-Released"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             test_name: "test-openshift"
             tf_scope: "private"
@@ -35,7 +34,6 @@ jobs:
             os_test: "rhel7"
             context: "RHEL7 - OpenShift 4"
             compose: "RHEL-7.9-Released"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
@@ -45,7 +43,15 @@ jobs:
             os_test: "rhel8"
             context: "RHEL8 - OpenShift 4"
             compose: "RHEL-8.6.0-Nightly"
-            tmt_url: "http://artifacts.osci.redhat.com/testing-farm/"
+            test_name: "test-openshift-4"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
+          - tmt_plan: "rhel9-openshift-4"
+            os_test: "rhel9"
+            context: "RHEL9 - OpenShift 4"
+            compose: "RHEL-9.1.0-Nightly"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"

From c6b749b6d1cef67e8bf0b0973c5ccac0d28d8522 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 23 Jun 2022 14:38:04 +0200
Subject: [PATCH 284/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 2269a3ec..93fb9c19 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2269a3ec3d32410d34807b847728520b601bdfcd
+Subproject commit 93fb9c196b26e18a8de6f0b16702bc0afa7cc744

From a02affdd32b9ddbdbf273678100f29814ba14791 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 23 Jun 2022 14:38:26 +0200
Subject: [PATCH 285/509] Add support for building and testing postgresql-13 on
 RHEL9 host

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.sh         |  3 +++
 specs/multispec.yml | 18 ++++++++++++++++++
 src/Dockerfile      |  6 +++---
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/manifest.sh b/manifest.sh
index ee8c1c79..05a1adc1 100644
--- a/manifest.sh
+++ b/manifest.sh
@@ -38,6 +38,9 @@ DISTGEN_MULTI_RULES="
     src=src/Dockerfile
     dest=Dockerfile.rhel8;
 
+    src=src/Dockerfile
+    dest=Dockerfile.rhel9;
+
     src=src/Dockerfile
     dest=Dockerfile.c9s;
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index ccbd6706..c61a5814 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -51,6 +51,20 @@ specs:
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
            yum -y reinstall tzdata && \
+    rhel9:
+       distros:
+         - rhel-9-x86_64
+       s2i_base: ubi9/s2i-core
+       org: "rhel9"
+       prod: "rhel9"
+       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+       redhat_component: "postgresql-{{ spec.short }}-container"
+       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
+       pkgs: "postgresql-server postgresql-contrib"
+       environment_setup: >-4
+           yum -y install postgresql && \
+       post_install: >-4
+           yum -y reinstall tzdata && \
     c9s:
       distros:
         - centos-stream-9-x86_64
@@ -147,17 +161,20 @@ matrix:
         - rhel-7-x86_64
         - centos-7-x86_64
         - rhel-8-x86_64
+        - rhel-9-x86_64
         - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "9.6"
     - distros:
         - fedora-31-x86_64
         - fedora-34-x86_64
+        - rhel-9-x86_64
         - centos-stream-9-x86_64
       version: "10"
     - distros:
         - rhel-7-x86_64
         - rhel-8-x86_64
+        - rhel-9-x86_64
         - centos-7-x86_64
         - fedora-34-x86_64
         - centos-stream-8-x86_64
@@ -165,6 +182,7 @@ matrix:
       version: "11"
     - distros:
         - rhel-8-x86_64
+        - rhel-9-x86_64
         - fedora-34-x86_64
         - centos-stream-8-x86_64
         - centos-stream-9-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 198ed393..13cc091f 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -11,7 +11,7 @@ FROM {{ spec.s2i_base }}
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION={{ spec.version }} \
-    {% if spec.prod != "rhel8" or spec.version == "10" %}
+    {% if spec.prod != "rhel8" or spec.prod != "rhel9" or spec.version == "10" %}
     POSTGRESQL_PREV_VERSION={{ spec.prev_version }} \
     {% endif %}
     HOME=/var/lib/pgsql \
@@ -73,7 +73,7 @@ RUN {{ spec.environment_setup }}
 {% if spec.version not in ["9.6", "10", "11"] %}
     {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
-    {% elif spec.prod == 'rhel8' or spec.prod == 'c9s' or spec.prod == 'c8s' %}
+    {% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' or spec.prod == 'c8s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     {% endif %}
 {% endif %}
@@ -95,7 +95,7 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
-{% if spec.prod != "rhel8" and config.os.id != "fedora" and spec.prod != "c8s" and spec.prod != "c9s" %}
+{% if spec.prod != "rhel8" and spec.prod != "rhel9" and config.os.id != "fedora" and spec.prod != "c8s" and spec.prod != "c9s" %}
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.

From 76c8e48aef0c2650d8c8567b9981dfe6f5c14c68 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 23 Jun 2022 14:39:02 +0200
Subject: [PATCH 286/509] Update documentation

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 README.md                                          | 14 ++++++++++++++
 .../share/container-scripts/postgresql/README.md   |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 56f3808c..d1d4f996 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,17 @@ PostgreSQL container images
 
 [![Build and push images to Quay.io registry](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml/badge.svg)](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml)
 
+Images available on Quay are:
+* CentOS 7 [postgresql-10](https://quay.io/repository/centos7/postgresql-10-centos7)
+* CentOS 7 [postgresql-12](https://quay.io/repository/centos7/postgresql-12-centos7)
+* CentOS 7 [postgresql-13](https://quay.io/repository/centos7/postgresql-13-centos7)
+* CentOS Stream 8 [postgresql-10](https://quay.io/repository/sclorg/postgresql-10-c8s)
+* CentOS Stream 8 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c8s)
+* CentOS Stream 9 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c9s)
+* Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
+* Fedora [postgresql-12](https://quay.io/repository/fedora/postgresql-12)
+* Fedora [postgresql-13](https://quay.io/repository/fedora/postgresql-13)
+
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.
 
@@ -25,9 +36,12 @@ PostgreSQL versions currently supported are:
 RHEL versions currently supported are:
 * RHEL7
 * RHEL8
+* RHEL9
 
 CentOS versions currently supported are:
 * CentOS7
+* CentOS Stream 8
+* CentOS Stream 9
 
 
 Installation
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index bc01aa9f..0897414e 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -5,7 +5,7 @@ This container image includes PostgreSQL {{ spec.version }} SQL database server
 Users can choose between RHEL, CentOS and Fedora based images.
 The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
 the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Fedora Registry](https://registry.fedoraproject.org/).
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
 The resulting image can be run using [podman](https://github.com/containers/libpod).
 
 Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
@@ -327,4 +327,5 @@ Dockerfile and other sources for this container image are available on
 https://github.com/sclorg/postgresql-container.
 In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
 for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
 and the Dockerfile for Fedora is called Dockerfile.fedora.

From b1ffed0572488e661ded3a2d46e83dce5b7c2660 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 6 Jun 2022 14:25:06 +0200
Subject: [PATCH 287/509] run all openshift4 tests even when one fails

---
 test/run-openshift-remote-cluster | 15 +++++++--------
 test/test-lib-postgresql.sh       |  3 +--
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 32614ee0..303bba85 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -11,8 +11,12 @@
 THISDIR=$(dirname ${BASH_SOURCE[0]})
 
 source ${THISDIR}/test-lib-postgresql.sh
+TEST_LIST="\
+test_postgresql_integration
+test_postgresql_imagestream
+"
 
-set -eo nounset
+set -u
 
 trap ct_os_cleanup EXIT SIGINT
 
@@ -25,13 +29,8 @@ oc status || false "It looks like oc is not properly logged in."
 # For testing on OpenShift 4 we use internal registry
 export CT_OCP4_TEST=true
 
-# Check the template
-test_postgresql_integration "${IMAGE_NAME}"
-
-# Check the imagestream
-test_postgresql_imagestream
-
-OS_TESTSUITE_RESULT=0
+TEST_SUMMARY=''
+TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "openshift-remote-cluster"
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:
 
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 19ca08bd..0b12c0f4 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -13,10 +13,9 @@ source "${THISDIR}"/test-lib-openshift.sh
 source "${THISDIR}"/test-lib-remote-openshift.sh
 
 function test_postgresql_integration() {
-  local image_name=$1
   local service_name=postgresql
   ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent
-  ct_os_test_template_app_func "${image_name}" \
+  ct_os_test_template_app_func "${IMAGE_NAME}" \
                                "${t}" \
                                "${service_name}" \
                                "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \

From 4ab07f2f4add6040df2838d115588d697564f34b Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Tue, 7 Jun 2022 16:42:31 +0200
Subject: [PATCH 288/509] exit testsuite gracefully, when oc setup fails

The nounset shell option needs to be set after the OC login attempt,
because (from man shopt):

-u
  If expansion is attempted on an unset  variable  or
  parameter,  the  shell prints  an  error  message, and, if not
  interactive exits with a non-zero status.

That is in this matter inconvenient, as we do not really know from log
what has happened if the oc login fails and moreover the test suite ends
with success, as only the first failed test sets TESTSUITE_RESULT to 1.

If we check login with the ct_os_check_login function, it handles the
situation conveniently.
---
 test/run-openshift-remote-cluster | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 303bba85..9bb67139 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -16,15 +16,15 @@ test_postgresql_integration
 test_postgresql_imagestream
 "
 
-set -u
-
 trap ct_os_cleanup EXIT SIGINT
 
 ct_os_set_ocp4
 
 ct_os_check_compulsory_vars
 
-oc status || false "It looks like oc is not properly logged in."
+ct_os_check_login || exit 1
+
+set -u
 
 # For testing on OpenShift 4 we use internal registry
 export CT_OCP4_TEST=true

From a53bc35704f19052224365ba0ce9ffd3c3441045 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 30 Jun 2022 13:16:44 +0200
Subject: [PATCH 289/509] Let's use released RHEL-9

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 6a7fc5c4..a94cad11 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -46,7 +46,7 @@ jobs:
           - tmt_plan: "rhel9-docker"
             os_test: "rhel9"
             context: "RHEL9"
-            compose: "RHEL-9.1.0-Nightly"
+            compose: "RHEL-9.0.0-Nightly"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 7f44c432..52f8fa0c 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -51,7 +51,7 @@ jobs:
           - tmt_plan: "rhel9-openshift-4"
             os_test: "rhel9"
             context: "RHEL9 - OpenShift 4"
-            compose: "RHEL-9.1.0-Nightly"
+            compose: "RHEL-9.0.0-Nightly"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"

From 7d96d6f28f11862034b4c6270b6dde1b41ce82f5 Mon Sep 17 00:00:00 2001
From: Filip Janus <fjanus@redhat.com>
Date: Mon, 11 Jul 2022 13:46:14 +0200
Subject: [PATCH 290/509] Postgresql-12 is RHEL 8 Full Life Application Stream
 Removing it from exclude

---
 specs/multispec.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index c61a5814..9be27492 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -181,10 +181,8 @@ matrix:
         - centos-stream-9-x86_64
       version: "11"
     - distros:
-        - rhel-8-x86_64
         - rhel-9-x86_64
         - fedora-34-x86_64
-        - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "12"
     - distros:

From 00bc921e82da45dbeb30892fafa978ea41047370 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 27 May 2022 09:22:09 +0200
Subject: [PATCH 291/509] Remove duplicit 13-el7 tag

The tag was in the image stream twice
---
 imagestreams/postgresql-centos.json | 18 ------------------
 imagestreams/postgresql-rhel.json   | 18 ------------------
 2 files changed, 36 deletions(-)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 2cde84b9..9c71e598 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -62,24 +62,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "13-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (CentOS 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "13"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-13-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "12-el7",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index cf87748f..19dd45b9 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -98,24 +98,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "13-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "13"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "12-el7",
         "annotations": {

From 8dc75d77808157c04d3d0f15a39c19e89d278352 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Thu, 21 Jul 2022 11:17:41 +0200
Subject: [PATCH 292/509] rhel9: fix environment setup and futureproof for
 modules

---
 specs/multispec.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 9be27492..9b206420 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -62,7 +62,7 @@ specs:
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
        environment_setup: >-4
-           yum -y install postgresql && \
+           { yum -y module enable postgresql:{{ spec.version }} || :; } && \
        post_install: >-4
            yum -y reinstall tzdata && \
     c9s:
@@ -76,7 +76,7 @@ specs:
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       pkgs: "postgresql-server postgresql-contrib"
       environment_setup: >-4
-          yum -y install postgresql && \
+           { yum -y module enable postgresql:{{ spec.version }} || :; } && \
     c8s:
       distros:
         - centos-stream-8-x86_64

From 1177b29b475d3eb2026b7142d84dcdf167b7e52c Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 8 Aug 2022 13:26:28 +0200
Subject: [PATCH 293/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 93fb9c19..95018da4 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 93fb9c196b26e18a8de6f0b16702bc0afa7cc744
+Subproject commit 95018da4490445cfc5d54b956ccebb0019b5c315

From 0815688e5ee4e27487ffbe0f477f4c09651717f0 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 8 Aug 2022 13:27:10 +0200
Subject: [PATCH 294/509] Add distgen generated files

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 11/README.md                                  |   1 +
 11/cccp.yml                                   |   1 +
 11/content_sets.yml                           |  10 +
 11/root/usr/bin/container-entrypoint          |   3 +
 11/root/usr/bin/run-postgresql                |  58 +++
 11/root/usr/bin/run-postgresql-master         |   5 +
 11/root/usr/bin/run-postgresql-slave          |  37 ++
 11/root/usr/bin/usage                         |   4 +
 11/root/usr/libexec/check-container           |  27 +
 11/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 331 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 479 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   9 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 11/s2i/bin/assemble                           |  14 +
 11/s2i/bin/run                                |   1 +
 11/s2i/bin/usage                              |   1 +
 11/test                                       |   1 +
 12/Dockerfile.c8s                             |  84 +++
 12/Dockerfile.rhel7                           |  94 ++++
 12/Dockerfile.rhel8                           |  85 ++++
 12/README.md                                  |   1 +
 12/cccp.yml                                   |   1 +
 12/content_sets.yml                           |  10 +
 12/root/usr/bin/container-entrypoint          |   3 +
 12/root/usr/bin/run-postgresql                |  58 +++
 12/root/usr/bin/run-postgresql-master         |   5 +
 12/root/usr/bin/run-postgresql-slave          |  39 ++
 12/root/usr/bin/usage                         |   4 +
 12/root/usr/libexec/check-container           |  27 +
 12/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 331 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 479 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   8 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 12/s2i/bin/assemble                           |  14 +
 12/s2i/bin/run                                |   1 +
 12/s2i/bin/usage                              |   1 +
 12/test                                       |   1 +
 13/Dockerfile.c8s                             |  84 +++
 13/Dockerfile.c9s                             |  83 +++
 13/Dockerfile.rhel7                           |  94 ++++
 13/Dockerfile.rhel8                           |  85 ++++
 13/Dockerfile.rhel9                           |  85 ++++
 13/README.md                                  |   1 +
 13/cccp.yml                                   |   1 +
 13/content_sets.yml                           |  10 +
 13/root/usr/bin/container-entrypoint          |   3 +
 13/root/usr/bin/run-postgresql                |  58 +++
 13/root/usr/bin/run-postgresql-master         |   5 +
 13/root/usr/bin/run-postgresql-slave          |  39 ++
 13/root/usr/bin/usage                         |   4 +
 13/root/usr/libexec/check-container           |  27 +
 13/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 331 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 479 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   8 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 13/s2i/bin/assemble                           |  14 +
 13/s2i/bin/run                                |   1 +
 13/s2i/bin/usage                              |   1 +
 13/test                                       |   1 +
 71 files changed, 3921 insertions(+)
 create mode 120000 11/README.md
 create mode 100644 11/cccp.yml
 create mode 100644 11/content_sets.yml
 create mode 100755 11/root/usr/bin/container-entrypoint
 create mode 100755 11/root/usr/bin/run-postgresql
 create mode 100755 11/root/usr/bin/run-postgresql-master
 create mode 100755 11/root/usr/bin/run-postgresql-slave
 create mode 100755 11/root/usr/bin/usage
 create mode 100755 11/root/usr/libexec/check-container
 create mode 100755 11/root/usr/libexec/fix-permissions
 create mode 100644 11/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 11/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 11/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 11/s2i/bin/assemble
 create mode 120000 11/s2i/bin/run
 create mode 100755 11/s2i/bin/usage
 create mode 120000 11/test
 create mode 100644 12/Dockerfile.c8s
 create mode 100644 12/Dockerfile.rhel7
 create mode 100644 12/Dockerfile.rhel8
 create mode 120000 12/README.md
 create mode 100644 12/cccp.yml
 create mode 100644 12/content_sets.yml
 create mode 100755 12/root/usr/bin/container-entrypoint
 create mode 100755 12/root/usr/bin/run-postgresql
 create mode 100755 12/root/usr/bin/run-postgresql-master
 create mode 100755 12/root/usr/bin/run-postgresql-slave
 create mode 100755 12/root/usr/bin/usage
 create mode 100755 12/root/usr/libexec/check-container
 create mode 100755 12/root/usr/libexec/fix-permissions
 create mode 100644 12/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 12/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 12/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 12/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 12/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 12/s2i/bin/assemble
 create mode 120000 12/s2i/bin/run
 create mode 100755 12/s2i/bin/usage
 create mode 120000 12/test
 create mode 100644 13/Dockerfile.c8s
 create mode 100644 13/Dockerfile.c9s
 create mode 100644 13/Dockerfile.rhel7
 create mode 100644 13/Dockerfile.rhel8
 create mode 100644 13/Dockerfile.rhel9
 create mode 120000 13/README.md
 create mode 100644 13/cccp.yml
 create mode 100644 13/content_sets.yml
 create mode 100755 13/root/usr/bin/container-entrypoint
 create mode 100755 13/root/usr/bin/run-postgresql
 create mode 100755 13/root/usr/bin/run-postgresql-master
 create mode 100755 13/root/usr/bin/run-postgresql-slave
 create mode 100755 13/root/usr/bin/usage
 create mode 100755 13/root/usr/libexec/check-container
 create mode 100755 13/root/usr/libexec/fix-permissions
 create mode 100644 13/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 13/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 13/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 13/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 13/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 13/s2i/bin/assemble
 create mode 120000 13/s2i/bin/run
 create mode 100755 13/s2i/bin/usage
 create mode 120000 13/test

diff --git a/11/README.md b/11/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/11/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/11/cccp.yml b/11/cccp.yml
new file mode 100644
index 00000000..d89c1915
--- /dev/null
+++ b/11/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-11-centos7
diff --git a/11/content_sets.yml b/11/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/11/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms
diff --git a/11/root/usr/bin/container-entrypoint b/11/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/11/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/11/root/usr/bin/run-postgresql b/11/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/11/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/11/root/usr/bin/run-postgresql-master b/11/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/11/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/11/root/usr/bin/run-postgresql-slave b/11/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..82113b76
--- /dev/null
+++ b/11/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/recovery.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/11/root/usr/bin/usage b/11/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/11/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/11/root/usr/libexec/check-container b/11/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/11/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/11/root/usr/libexec/fix-permissions b/11/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/11/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/11/root/usr/share/container-scripts/postgresql/README.md b/11/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..e0980204
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,331 @@
+PostgreSQL 11 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 11 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `` image, available via `postgresql:11` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=11 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/11/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/11/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 10 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `` image,
+available via `postgresql:11` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:11~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/11/root/usr/share/container-scripts/postgresql/common.sh b/11/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..4e1bc94a
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,479 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/11/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..26d56693
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,9 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+standby_mode = on
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/11/root/usr/share/container-scripts/postgresql/scl_enable b/11/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/11/s2i/bin/assemble b/11/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/11/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/11/s2i/bin/run b/11/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/11/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/11/s2i/bin/usage b/11/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/11/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/11/test b/11/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/11/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/12/Dockerfile.c8s b/12/Dockerfile.c8s
new file mode 100644
index 00000000..7251587e
--- /dev/null
+++ b/12/Dockerfile.c8s
@@ -0,0 +1,84 @@
+FROM quay.io/sclorg/s2i-core-c8s:c8s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=12 \
+    POSTGRESQL_PREV_VERSION=10 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 12" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql12,postgresql-12" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-12-c8s" \
+      com.redhat.component="postgresql-12-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-12-c8s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:12 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
new file mode 100644
index 00000000..0bdbb6be
--- /dev/null
+++ b/12/Dockerfile.rhel7
@@ -0,0 +1,94 @@
+FROM rhscl/s2i-core-rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=12 \
+    POSTGRESQL_PREV_VERSION=10 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 12" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql12,rh-postgresql12" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhscl/postgresql-12-rhel7" \
+      com.redhat.component="rh-postgresql12-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-12-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
+    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql12
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
new file mode 100644
index 00000000..e387a241
--- /dev/null
+++ b/12/Dockerfile.rhel8
@@ -0,0 +1,85 @@
+FROM ubi8/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=12 \
+    POSTGRESQL_PREV_VERSION=10 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 12" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql12,postgresql-12" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel8/postgresql-12" \
+      com.redhat.component="postgresql-12-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-12" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:12 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/12/README.md b/12/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/12/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/12/cccp.yml b/12/cccp.yml
new file mode 100644
index 00000000..23374d63
--- /dev/null
+++ b/12/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-12-centos7
diff --git a/12/content_sets.yml b/12/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/12/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms
diff --git a/12/root/usr/bin/container-entrypoint b/12/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/12/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/12/root/usr/bin/run-postgresql b/12/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/12/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/12/root/usr/bin/run-postgresql-master b/12/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/12/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/12/root/usr/bin/run-postgresql-slave b/12/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..586bf5d7
--- /dev/null
+++ b/12/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/12/root/usr/bin/usage b/12/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/12/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/12/root/usr/libexec/check-container b/12/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/12/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/12/root/usr/libexec/fix-permissions b/12/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/12/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..f92d9665
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,331 @@
+PostgreSQL 12 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 12 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-12-rhel7` image, available via `postgresql:12` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-12-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=12 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/12/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/12/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 10 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `rhscl/postgresql-12-rhel7` image,
+available via `postgresql:12` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:12~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-12-rhel7 new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..4b968f5a
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,479 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/12/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/12/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/12/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..58d8e336
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,8 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/12/root/usr/share/container-scripts/postgresql/scl_enable b/12/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/12/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/12/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/12/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/12/s2i/bin/assemble b/12/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/12/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/12/s2i/bin/run b/12/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/12/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/12/s2i/bin/usage b/12/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/12/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/12/test b/12/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/12/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/13/Dockerfile.c8s b/13/Dockerfile.c8s
new file mode 100644
index 00000000..e4e526a4
--- /dev/null
+++ b/13/Dockerfile.c8s
@@ -0,0 +1,84 @@
+FROM quay.io/sclorg/s2i-core-c8s:c8s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,postgresql-13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-13-c8s" \
+      com.redhat.component="postgresql-13-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-13-c8s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:13 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
new file mode 100644
index 00000000..69aa8ed2
--- /dev/null
+++ b/13/Dockerfile.c9s
@@ -0,0 +1,83 @@
+FROM quay.io/sclorg/s2i-core-c9s:c9s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,postgresql-13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-13-c9s" \
+      com.redhat.component="postgresql-13-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-13-c9s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN  { yum -y module enable postgresql:13 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
new file mode 100644
index 00000000..9bbe5ff9
--- /dev/null
+++ b/13/Dockerfile.rhel7
@@ -0,0 +1,94 @@
+FROM rhscl/s2i-core-rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,rh-postgresql13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhscl/postgresql-13-rhel7" \
+      com.redhat.component="rh-postgresql13-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-13-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
+    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql13
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
new file mode 100644
index 00000000..0be804fb
--- /dev/null
+++ b/13/Dockerfile.rhel8
@@ -0,0 +1,85 @@
+FROM ubi8/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,postgresql-13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel8/postgresql-13" \
+      com.redhat.component="postgresql-13-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-13" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:13 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
new file mode 100644
index 00000000..23d2a439
--- /dev/null
+++ b/13/Dockerfile.rhel9
@@ -0,0 +1,85 @@
+FROM ubi9/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,postgresql-13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel9/postgresql-13" \
+      com.redhat.component="postgresql-13-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel9/postgresql-13" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN { yum -y module enable postgresql:13 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/README.md b/13/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/13/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/13/cccp.yml b/13/cccp.yml
new file mode 100644
index 00000000..2a88a7b7
--- /dev/null
+++ b/13/cccp.yml
@@ -0,0 +1 @@
+job-id: postgresql-13-centos7
diff --git a/13/content_sets.yml b/13/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/13/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms
diff --git a/13/root/usr/bin/container-entrypoint b/13/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/13/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/13/root/usr/bin/run-postgresql b/13/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/13/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/13/root/usr/bin/run-postgresql-master b/13/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/13/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/13/root/usr/bin/run-postgresql-slave b/13/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..586bf5d7
--- /dev/null
+++ b/13/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/13/root/usr/bin/usage b/13/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/13/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/13/root/usr/libexec/check-container b/13/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/13/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/13/root/usr/libexec/fix-permissions b/13/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/13/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..fb1dbfa2
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,331 @@
+PostgreSQL 13 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 13 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-13-rhel7` image, available via `postgresql:13` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-13-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=13 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/13/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/13/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 12 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `rhscl/postgresql-13-rhel7` image,
+available via `postgresql:13` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:13~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-13-rhel7 new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..8c8b2dd6
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,479 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/13/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..d133e511
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/13/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/13/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..58d8e336
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,8 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/13/root/usr/share/container-scripts/postgresql/scl_enable b/13/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/13/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/13/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/13/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/13/s2i/bin/assemble b/13/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/13/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/13/s2i/bin/run b/13/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/13/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/13/s2i/bin/usage b/13/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/13/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/13/test b/13/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/13/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file

From 10fc5e46eb47e12e32b37166cce2d7e6fbe17e16 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 12 Sep 2022 10:25:33 +0200
Subject: [PATCH 295/509] Testing single versions for container and openshift
 tests

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 49 ++++++++++++++++++++++-----
 .github/workflows/openshift-tests.yml | 37 ++++++++++++++++----
 2 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index a94cad11..560e03cc 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -1,17 +1,17 @@
-name: Container-tests by GitHub Action at Testing Farm
-
 on:
   issue_comment:
     types:
       - created
 jobs:
-  build:
+  container-tests:
     # This job only runs for '[test]' pull request comments by owner, member
-    name: Container-tests by GitHub Action on Testing Farm service
     runs-on: ubuntu-20.04
+    name: "Container tests: ${{ matrix.version }} - ${{ matrix.context }}"
     strategy:
       fail-fast: false
       matrix:
+        version: [ "10", "11", "12", "13" ]
+        os_test: [ "fedora", "centos7", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
         include:
           - tmt_plan: "fedora"
             os_test: "fedora"
@@ -33,8 +33,8 @@ jobs:
             compose: "RHEL-7.9-Released"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
-            tf_scope: "private"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
           - tmt_plan: "rhel8-docker"
             os_test: "rhel8"
             context: "RHEL8"
@@ -51,6 +51,14 @@ jobs:
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             tf_scope: "private"
+          - tmt_plan: "rhel9-unsubscribed-docker"
+            os_test: "rhel9"
+            context: "RHEL9 - Unsubscribed host"
+            compose: "RHEL-9.0.0-Nightly"
+            api_key: "TF_INTERNAL_API_KEY"
+            branch: "master"
+            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
+            tf_scope: "private"
           - tmt_plan: "c9s"
             os_test: "c9s"
             context: "CentOS Stream 9"
@@ -65,6 +73,7 @@ jobs:
             api_key: "TF_PUBLIC_API_KEY"
             branch: "main"
             tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
@@ -75,8 +84,32 @@ jobs:
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
 
+      - name: Prepare needed variables
+        shell: bash
+        id: vars
+        run: |
+          dockerfile="Dockerfile.${{ matrix.os_test }}"
+          if [[ ${{ matrix.os_test }} == "centos7" ]]; then
+            dockerfile="Dockerfile"
+          fi
+          echo "::set-output name=DOCKERFILE_NAME::${dockerfile}"
+
+      - name: Check that ${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }} is present
+        id: check_dockerfile
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
+
+      - name: Check that .exclude-${{ matrix.os_test }} file is not present
+        id: check_exclude_file
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/.exclude-${{ matrix.os_test }}"
+
       # https://github.com/sclorg/testing-farm-as-github-action
-      - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
+      - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
+        id: github_action
+        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile.outputs.files_exists == 'true' }}
         uses: sclorg/testing-farm-as-github-action@v1
         with:
           api_key: ${{ secrets[matrix.api_key] }}
@@ -84,6 +117,6 @@ jobs:
           git_ref: ${{ matrix.branch }}
           tf_scope: ${{ matrix.tf_scope }}
           tmt_plan_regex: ${{ matrix.tmt_plan }}
-          pull_request_status_name: ${{ matrix.context }}
-          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};OS=${{ matrix.os_test }};TEST_NAME=test"
+          pull_request_status_name: "${{ matrix.context }} - ${{ matrix.version }}"
+          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};SINGLE_VERSION=${{ matrix.version }};OS=${{ matrix.os_test }};TEST_NAME=test"
           compose: ${{ matrix.compose }}
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 52f8fa0c..3950456c 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -1,17 +1,17 @@
-name: OpenShift tests by GitHub Action at Testing Farm
-
 on:
   issue_comment:
     types:
       - created
 jobs:
-  build:
+  openshift-tests:
     # This job only runs for '[test-all]' or '[test-openshift] pull request comments by owner, member
-    name: OpenShift tests by GitHub Action on Testing Farm service
+    name: "OpenShift tests: ${{ matrix.version }} - ${{ matrix.context }}"
     runs-on: ubuntu-20.04
     strategy:
       fail-fast: false
       matrix:
+        version: [ "10", "11", "12", "13" ]
+        os_test: [ "centos7", "rhel7", "rhel8", "rhel9"]
         include:
           - tmt_plan: "centos7"
             os_test: "centos7"
@@ -68,9 +68,32 @@ jobs:
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
 
+      - name: Prepare needed variables
+        shell: bash
+        id: vars
+        run: |
+          dockerfile="Dockerfile.${{ matrix.os_test }}"
+          if [[ ${{ matrix.os_test }} == "centos7" ]]; then
+            dockerfile="Dockerfile"
+          fi
+          echo "::set-output name=DOCKERFILE_NAME::${dockerfile}"
+
+      - name: Check that ${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }} is present
+        id: check_dockerfile
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
+
+      - name: Check that .exclude-${{ matrix.os_test }} file is not present
+        id: check_exclude_file
+        uses: andstor/file-existence-action@v1
+        with:
+          files: "${{ matrix.version }}/.exclude-${{ matrix.os_test }}"
+
       # https://github.com/sclorg/testing-farm-as-github-action
-      - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
+      - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
         id: github_action
+        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile.outputs.files_exists == 'true' }}
         uses: sclorg/testing-farm-as-github-action@v1
         with:
           api_key: ${{ secrets[matrix.api_key] }}
@@ -78,6 +101,6 @@ jobs:
           git_ref: ${{ matrix.branch }}
           tf_scope: ${{ matrix.tf_scope }}
           tmt_plan_regex: ${{ matrix.tmt_plan }}
-          pull_request_status_name: ${{ matrix.context }}
-          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};OS=${{ matrix.os_test }};TEST_NAME=${{ matrix.test_name }}"
+          pull_request_status_name: "${{ matrix.context }} - ${{ matrix.version }}"
+          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};SINGLE_VERSION=${{ matrix.version }};OS=${{ matrix.os_test }};TEST_NAME=${{ matrix.test_name }}"
           compose: ${{ matrix.compose }}

From 4b2b9b22f55973ad2afa9f1a275def9ba744c339 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 14 Sep 2022 14:00:16 +0200
Subject: [PATCH 296/509] Get rid off check for .exclude files. It does not
 make sense

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 8 +-------
 .github/workflows/openshift-tests.yml | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 560e03cc..9912e050 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -100,16 +100,10 @@ jobs:
         with:
           files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
 
-      - name: Check that .exclude-${{ matrix.os_test }} file is not present
-        id: check_exclude_file
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/.exclude-${{ matrix.os_test }}"
-
       # https://github.com/sclorg/testing-farm-as-github-action
       - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
         id: github_action
-        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile.outputs.files_exists == 'true' }}
+        if: steps.check_dockerfile.outputs.files_exists == 'true'
         uses: sclorg/testing-farm-as-github-action@v1
         with:
           api_key: ${{ secrets[matrix.api_key] }}
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 3950456c..b426f8ee 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -84,16 +84,10 @@ jobs:
         with:
           files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
 
-      - name: Check that .exclude-${{ matrix.os_test }} file is not present
-        id: check_exclude_file
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/.exclude-${{ matrix.os_test }}"
-
       # https://github.com/sclorg/testing-farm-as-github-action
       - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
         id: github_action
-        if: ${{ steps.check_exclude_file.outputs.files_exists == 'false' && steps.check_dockerfile.outputs.files_exists == 'true' }}
+        if: steps.check_dockerfile.outputs.files_exists == 'true'
         uses: sclorg/testing-farm-as-github-action@v1
         with:
           api_key: ${{ secrets[matrix.api_key] }}

From 0d922dc52ef692882eacd297d3b4e6885aa6e325 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 14 Sep 2022 09:38:08 +0200
Subject: [PATCH 297/509] tests: use generic run_all_tests funtion

---
 test/run_test | 66 +++++++++------------------------------------------
 1 file changed, 11 insertions(+), 55 deletions(-)

diff --git a/test/run_test b/test/run_test
index 84a40c73..ac45a1f0 100755
--- a/test/run_test
+++ b/test/run_test
@@ -6,7 +6,7 @@
 # The image has to be available before this script is executed.
 #
 
-set -exo nounset
+set -xo nounset
 shopt -s nullglob
 
 # library from container-common-scripts
@@ -36,14 +36,12 @@ test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
-CIDFILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
+CID_FILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
 volumes_to_clean=
 images_to_clean=()
 files_to_clean=
 test_dir="$(readlink -f "$(dirname "$0")")"
-test_short_summary=''
-TESTSUITE_RESULT=1
 
 _cleanup_commands_space=
 _cleanup_commands=
@@ -63,22 +61,6 @@ function cleanup() {
   # Print a big fat separator to find the error easier
   echo "=================================== Cleanup begins here ============================="
 
-  for cidfile in $CIDFILE_DIR/* ; do
-    CONTAINER=$(cat $cidfile)
-
-    echo "Stopping and removing container $CONTAINER..."
-    docker stop $CONTAINER
-    exit_status=$(docker inspect -f '{{.State.ExitCode}}' $CONTAINER)
-    if [ "$exit_status" != "0" ]; then
-      echo "Dumping logs for $CONTAINER"
-      docker logs $CONTAINER
-    fi
-    docker rm $CONTAINER
-    rm $cidfile
-    echo "Done."
-  done
-  rmdir $CIDFILE_DIR
-
   ct_path_foreach "$volumes_to_clean" cleanup_volume_dir
 
   if test -n "${images_to_clean-}"; then
@@ -94,16 +76,8 @@ function cleanup() {
   echo "$_cleanup_commands" | while read -r line; do
     eval "$line"
   done
-
-  echo "$test_short_summary"
-
-  if [ $TESTSUITE_RESULT -eq 0 ] ; then
-    echo "Tests for ${IMAGE_NAME} succeeded."
-  else
-    echo "Tests for ${IMAGE_NAME} failed."
-  fi
+  echo "================== postgresql-container-specific cleanup ends here ====================="
 }
-trap cleanup EXIT
 
 cleanup_volume_dir ()
 {
@@ -120,7 +94,7 @@ cleanup_volume_dir ()
 
 function get_cid() {
   local id="$1" ; shift || return 1
-  echo $(cat "$CIDFILE_DIR/$id")
+  echo $(cat "$CID_FILE_DIR/$id")
 }
 
 function get_container_ip() {
@@ -182,7 +156,7 @@ function create_container() {
   # TODO: fix all create_container() invocations so that we don't need this,
   # e.g. multiline DOCKER_ARGS var should end by trailing backslashes
   cargs=$(echo "$cargs" | tr  '\n' ' ')
-  cidfile="$CIDFILE_DIR/$name"
+  cidfile="$CID_FILE_DIR/$name"
   # create container with a cidfile in a directory for cleanup
   eval "docker run $cargs --cidfile \$cidfile -d \$IMAGE_NAME \"\$@\""
   echo "Created container $(cat $cidfile)"
@@ -288,8 +262,6 @@ assert_container_creation_succeeds ()
   if test -n "$ADMIN_PASS"; then
     PGUSER=postgres PASS=$ADMIN_PASS DB=$DB test_connection "$name"
   fi
-
-  docker stop "$(get_cid "$name")"
 }
 
 
@@ -439,14 +411,14 @@ function run_tests() {
 function run_slave() {
   local suffix="$1"; shift
   docker run $cluster_args -e POSTGRESQL_MASTER_IP=${master_hostname} \
-    -d --cidfile ${CIDFILE_DIR}/slave-${suffix}.cid $IMAGE_NAME run-postgresql-slave
+    -d --cidfile ${CID_FILE_DIR}/slave-${suffix}.cid $IMAGE_NAME run-postgresql-slave
 }
 
 function run_master() {
   local suffix="$1"; shift
   master_args=${master_args-}
   docker run $cluster_args $master_args \
-    -d --cidfile ${CIDFILE_DIR}/master-${suffix}.cid $IMAGE_NAME run-postgresql-master >/dev/null
+    -d --cidfile ${CID_FILE_DIR}/master-${suffix}.cid $IMAGE_NAME run-postgresql-master >/dev/null
 }
 
 function test_slave_visibility() {
@@ -544,7 +516,7 @@ function run_master_restart_test() {
   test_slave_visibility
 
   echo "Kill the master and create a new one"
-  local cidfile=$CIDFILE_DIR/master-$cid_suffix.cid
+  local cidfile=$CID_FILE_DIR/master-$cid_suffix.cid
   docker kill $(cat $cidfile)
   # Don't forget to remove its .cid file
   rm $cidfile
@@ -621,7 +593,6 @@ $volume_options
 
   echo "  Changing passwords"
 
-  docker stop $(get_cid ${name})
   DOCKER_ARGS="
 -e POSTGRESQL_DATABASE=${database}
 -e POSTGRESQL_USER=${user}
@@ -735,8 +706,6 @@ ${mount_opts}
   # need this to wait for the container to start up
   PGUSER=user     PASS=password           test_connection "$container_name"
   PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name"
-
-  docker stop "$(get_cid $container_name)" >/dev/null
 }
 
 run_s2i_test() {
@@ -822,8 +791,6 @@ run_s2i_enable_ssl_test()
 
   docker run --rm -e PGPASSWORD="password" "$IMAGE_NAME" psql "postgresql://postgres@$CONTAINER_IP:5432/postgres?sslmode=require" || \
     false "FAIL: Did not manage to connect using SSL only."
-
-  docker stop "$(get_cid "$container_name")"
 }
 
 run_s2i_bake_data_test ()
@@ -841,8 +808,6 @@ run_s2i_bake_data_test ()
 
   test "hello world" == "$(docker exec "$(get_cid "$container_name")" \
                            bash -c "psql -tA -c 'SELECT * FROM test;'")"
-
-  docker stop "$(get_cid "$container_name")"
 }
 
 run_pgaudit_test()
@@ -898,20 +863,11 @@ EOSQL"
   grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
 }
 
-function run_all_tests() {
-  for test_case in $TEST_LIST; do
-    : "Running test $test_case"
-    $test_case
-  done;
-}
-
 # configuration defaults
 POSTGRESQL_MAX_CONNECTIONS=100
 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0
 POSTGRESQL_SHARED_BUFFERS=32MB
 
-# Run the chosen tests
-TEST_LIST=${TESTS:-$TEST_LIST} run_all_tests
-
-TESTSUITE_RESULT=0
-echo "All tests passed."
+ct_enable_cleanup
+TEST_SUMMARY=''
+TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset 'postgresql-container_tests'

From b9141e5bb92b7be0115e136a83c7a147265b0f1b Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 14 Sep 2022 09:38:47 +0200
Subject: [PATCH 298/509] adding the newest common/ submodule

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 95018da4..a7862f18 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 95018da4490445cfc5d54b956ccebb0019b5c315
+Subproject commit a7862f18b1162855d1e56bf24a3410001b984327

From 3ed48e3f715f23f9abce321b24df60f7eb36c4c2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Sep 2022 10:19:05 +0200
Subject: [PATCH 299/509] RHEL9 - unsubscribed host is valid only for UBI
 images

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 9912e050..e4ea3912 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -51,14 +51,6 @@ jobs:
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
             tf_scope: "private"
-          - tmt_plan: "rhel9-unsubscribed-docker"
-            os_test: "rhel9"
-            context: "RHEL9 - Unsubscribed host"
-            compose: "RHEL-9.0.0-Nightly"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
           - tmt_plan: "c9s"
             os_test: "c9s"
             context: "CentOS Stream 9"

From f61ff1d7622fe76aba941311f4bdec33883b77f2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 27 Sep 2022 12:02:28 +0200
Subject: [PATCH 300/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index a7862f18..050ce311 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a7862f18b1162855d1e56bf24a3410001b984327
+Subproject commit 050ce3117fa11dadece6845502c73603cbb97d2d

From c71aa4df4b2198326b1a3ef037f3ea656b535632 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 27 Sep 2022 12:02:51 +0200
Subject: [PATCH 301/509] Add missing imagestreams and test-openshift.yaml file

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/imagestreams        | 1 +
 test/test-openshift.yaml | 1 +
 2 files changed, 2 insertions(+)
 create mode 120000 test/imagestreams
 create mode 120000 test/test-openshift.yaml

diff --git a/test/imagestreams b/test/imagestreams
new file mode 120000
index 00000000..7af977a6
--- /dev/null
+++ b/test/imagestreams
@@ -0,0 +1 @@
+../imagestreams/
\ No newline at end of file
diff --git a/test/test-openshift.yaml b/test/test-openshift.yaml
new file mode 120000
index 00000000..9316d8fa
--- /dev/null
+++ b/test/test-openshift.yaml
@@ -0,0 +1 @@
+../common/test-openshift.yaml
\ No newline at end of file

From 68aaf7ee667f8994f99b6c66fc8dff7bc4185a7e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 27 Sep 2022 12:05:53 +0200
Subject: [PATCH 302/509] Enable support for testing postgresql-container in
 CVP pipeline

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-remote-cluster | 6 +++++-
 test/test-lib-postgresql.sh       | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 9bb67139..5ae1bcff 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -10,7 +10,9 @@
 
 THISDIR=$(dirname ${BASH_SOURCE[0]})
 
-source ${THISDIR}/test-lib-postgresql.sh
+source "${THISDIR}/test-lib-postgresql.sh"
+source "${THISDIR}/test-lib-remote-openshift.sh"
+
 TEST_LIST="\
 test_postgresql_integration
 test_postgresql_imagestream
@@ -24,6 +26,8 @@ ct_os_check_compulsory_vars
 
 ct_os_check_login || exit 1
 
+ct_os_tag_image_for_cvp "postgresql"
+
 set -u
 
 # For testing on OpenShift 4 we use internal registry
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 0b12c0f4..7e9074f8 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -29,14 +29,14 @@ function test_postgresql_integration() {
 # Check the imagestream
 function test_postgresql_imagestream() {
   case ${OS} in
-    rhel7|centos7) ;;
+    rhel7|centos7|rhel8) ;;
     *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
   esac
   local tag="-el7"
   if [ "${OS}" == "rhel8" ]; then
     tag="-el8"
   fi
-  ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
+  ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }
 
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From 170a77b6ae1f4f26b18808ea24a5c5c24850308d Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Thu, 13 Oct 2022 12:41:11 +0200
Subject: [PATCH 303/509] update to latest common

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 050ce311..85f06416 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 050ce3117fa11dadece6845502c73603cbb97d2d
+Subproject commit 85f06416bf48f5c66766e605047d81e97d73199f

From 4e8606dabce402e7dd199dfab3e0d232bb8f453d Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Thu, 13 Oct 2022 12:42:02 +0200
Subject: [PATCH 304/509] Using OC_ERR return val for OC failures

---
 test/run-openshift-remote-cluster | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 5ae1bcff..09946f7a 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -20,11 +20,11 @@ test_postgresql_imagestream
 
 trap ct_os_cleanup EXIT SIGINT
 
-ct_os_set_ocp4
+ct_os_set_ocp4 || exit $OC_ERR
 
-ct_os_check_compulsory_vars
+ct_os_check_compulsory_vars || exit $OC_ERR
 
-ct_os_check_login || exit 1
+ct_os_check_login || exit $OC_ERR
 
 ct_os_tag_image_for_cvp "postgresql"
 

From 8d2867ec9582a6b4641905d7c89f3403312393df Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 19 Sep 2022 10:58:46 +0200
Subject: [PATCH 305/509] Remove version 11

There is no Dockerfile for it.
---
 11/README.md                                  |   1 -
 11/cccp.yml                                   |   1 -
 11/content_sets.yml                           |  10 -
 11/root/usr/bin/container-entrypoint          |   3 -
 11/root/usr/bin/run-postgresql                |  58 ---
 11/root/usr/bin/run-postgresql-master         |   5 -
 11/root/usr/bin/run-postgresql-slave          |  37 --
 11/root/usr/bin/usage                         |   4 -
 11/root/usr/libexec/check-container           |  27 -
 11/root/usr/libexec/fix-permissions           |  39 --
 .../container-scripts/postgresql/README.md    | 331 ------------
 .../container-scripts/postgresql/common.sh    | 479 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  23 -
 11/s2i/bin/assemble                           |  14 -
 11/s2i/bin/run                                |   1 -
 11/s2i/bin/usage                              |   1 -
 11/test                                       |   1 -
 Makefile                                      |   2 +-
 22 files changed, 1 insertion(+), 1076 deletions(-)
 delete mode 120000 11/README.md
 delete mode 100644 11/cccp.yml
 delete mode 100644 11/content_sets.yml
 delete mode 100755 11/root/usr/bin/container-entrypoint
 delete mode 100755 11/root/usr/bin/run-postgresql
 delete mode 100755 11/root/usr/bin/run-postgresql-master
 delete mode 100755 11/root/usr/bin/run-postgresql-slave
 delete mode 100755 11/root/usr/bin/usage
 delete mode 100755 11/root/usr/libexec/check-container
 delete mode 100755 11/root/usr/libexec/fix-permissions
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 11/s2i/bin/assemble
 delete mode 120000 11/s2i/bin/run
 delete mode 100755 11/s2i/bin/usage
 delete mode 120000 11/test

diff --git a/11/README.md b/11/README.md
deleted file mode 120000
index d359f030..00000000
--- a/11/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/11/cccp.yml b/11/cccp.yml
deleted file mode 100644
index d89c1915..00000000
--- a/11/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-11-centos7
diff --git a/11/content_sets.yml b/11/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/11/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms
diff --git a/11/root/usr/bin/container-entrypoint b/11/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/11/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/11/root/usr/bin/run-postgresql b/11/root/usr/bin/run-postgresql
deleted file mode 100755
index 2367e57e..00000000
--- a/11/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-
-process_extending_files \
-        "${APP_DATA}/src/postgresql-pre-start" \
-        "${CONTAINER_SCRIPTS_PATH}/pre-start"
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-# Use insanely large timeout (24h) to ensure that the potential recovery has
-# enough time here to happen (unless liveness probe kills us).  Note that in
-# case of server failure this command still exists immediately.
-pg_ctl start -w --timeout 86400 -o "-h ''"
-
-# This is just a pedantic safety measure (the timeout above is unlikely to
-# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
-# returns exit_status=0 even if the server is still starting.  For more info
-# see the issue#297 and
-# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
-pg_isready
-
-if $PG_INITIALIZED ; then
-    process_extending_files \
-        "${APP_DATA}/src/postgresql-init" \
-        "${CONTAINER_SCRIPTS_PATH}/init"
-    migrate_db
-    create_users
-fi
-
-process_extending_files \
-    "${APP_DATA}/src/postgresql-start" \
-    "${CONTAINER_SCRIPTS_PATH}/start"
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/11/root/usr/bin/run-postgresql-master b/11/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/11/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/11/root/usr/bin/run-postgresql-slave b/11/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index 82113b76..00000000
--- a/11/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/11/root/usr/bin/usage b/11/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/11/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/11/root/usr/libexec/check-container b/11/root/usr/libexec/check-container
deleted file mode 100755
index 04a5b625..00000000
--- a/11/root/usr/libexec/check-container
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-if test x"$1" = "x--live"; then
-    # Since livenessProbe is about to detect container deadlocks, and we
-    # so far don't know about real deadlocks to be detected -- we keep
-    # liveness probe to report that container is always ready (as long as
-    # we are able to execute shell, enable collections, etc., which is
-    # good for container sanity testing anyways).
-    exit 0
-fi
-
-# Readiness check follows, the --timeout is set to "infinite" because it
-# is handled externally (readinessProbe.timeoutSeconds).
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
diff --git a/11/root/usr/libexec/fix-permissions b/11/root/usr/libexec/fix-permissions
deleted file mode 100755
index f4b2f86d..00000000
--- a/11/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-documentation="\
-Recursively fix permissions on the given directories to allow GID=0
-read/write regular files and read/write/execute directories.
-
-To run this command, you have to be in the group root=0!"
-
-uid=26
-write=w
-
-usage ()
-{
-    cat >&2 <<EOF
-$0: Error: ${1-usage error}
-
-Usage: $0 [--read-only] DIR [DIR ..]
-
-$documentation
-EOF
-    exit 1
-}
-
-while test $# -gt 0; do
-    case $1 in
-    --read-only) write= ; shift ;;
-    *) break ;;
-    esac
-done
-
-test $# -eq 0 && usage "no DIR specified"
-
-for dir; do
-    test -d "$dir" || usage "no such directory '$dir'"
-    echo >&2 "fixing permissions on '$dir' directory"
-    find "$dir" -exec chown "$uid:0" {} \;
-    find "$dir" -exec chmod "g+r$write" {} \;
-    find "$dir" -type d -exec chmod g+x {} +
-done
diff --git a/11/root/usr/share/container-scripts/postgresql/README.md b/11/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index e0980204..00000000
--- a/11/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,331 +0,0 @@
-PostgreSQL 11 SQL Database Server container image
-===============================================
-
-This container image includes PostgreSQL 11 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
-
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
-
-
-Description
------------
-
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
-
-
-Usage
------
-
-For this, we will assume that you are using the `` image, available via `postgresql:11` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
-```
-
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
-
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
-
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
-
-```
-$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=11 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
-```
-
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/11/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/11/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
-
-
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
-       Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
-       Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `podman run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```
-$ setfacl -m u:26:-wx /your/data/dir
-$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-
-Data migration
---------------
-
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
-$ podman run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
-```
-
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
-Migration from a different kind of PostgreSQL container can likely fail.
-
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
-
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
-
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
-
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
-
-PostgreSQL auto-tuning
-----------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
-
-
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 10 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
-
-
-Extending image
-----------------
-
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `` image,
-available via `postgresql:11` imagestream tag in Openshift.
-
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
-$ oc new-app postgresql:11~https://github.com/sclorg/postgresql-container.git \
-  --name new-postgresql \
-  --context-dir examples/extending-image/ \
-  -e POSTGRESQL_USER=user \
-  -e POSTGRESQL_DATABASE=db \
-  -e POSTGRESQL_PASSWORD=password
-```
-
-or via `s2i`:
-
-```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
-```
-
-The directory passed to Openshift should contain one or more of the
-following directories:
-
-
-##### `postgresql-pre-start/`
-
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
-
-##### `postgresql-cfg/`
-
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
-
-##### `postgresql-init/`
-
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
-
-##### `postgresql-start/`
-
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
-
-
-----------------------------------------------
-
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
-
-
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
-
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
-
-
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/11/root/usr/share/container-scripts/postgresql/common.sh b/11/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 4e1bc94a..00000000
--- a/11/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,479 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# Converts the version in format x.y or x.y.z to a number.
-version2number ()
-{
-    local old_IFS=$IFS
-    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
-    IFS='.'
-    set -- $1
-    while test $depth -ge 1; do
-        depth=$(( depth - 1 ))
-        part=${1-0} ; shift || :
-        printf "%0${width}d" "$part"
-    done
-    IFS=$old_IFS
-}
-
-# On non-intel arches, data_sync_retry = off does not work
-# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
-# Upstream changes that caused this issue:
-# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
-# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
-# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
-# Special handle of data_sync_retry should handle only in some cases.
-# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
-# Return value 0 means the hack is needed.
-function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
-  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
-  # this matches all 12.x and versions of 10.x where we need the hack
-  [ "$version_number" -ge 100700 ] && return 0
-  # this matches all 10.x that were not matched above
-  [ "$version_number" -ge 100000 ] && return 1
-  # this matches all 9.x where need the hack
-  [ "$version_number" -ge 090612 ] && return 0
-  # all rest should be older 9.x releases
-  return 1
-}
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  if should_hack_data_sync_retry ; then
-    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/11/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # On non-intel arches the data_sync_retry set to on
-  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  # Get back the option we changed above
-  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files PATTERN DIR [DIR ...]
-# ---------------------------------------
-# Print all basenames for files matching PATTERN in DIRs.
-get_matched_files ()
-{
-  local pattern=$1 dir
-  shift
-  for dir; do
-    test -d "$dir" || continue
-    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
-  done
-}
-
-# process_extending_files DIR [DIR ...]
-# -------------------------------------
-# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
-# more then one DIR, source only the first occurrence (first found wins).
-process_extending_files()
-{
-  local filename dir
-  while read filename ; do
-    for dir in "$@"; do
-      local file="$dir/$filename"
-      if test -f "$file"; then
-        echo "=> sourcing $file ..."
-        source "$file"
-        set -e # ensure that users don't mistakenly change this
-        break
-      fi
-    done
-  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
-}
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/11/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/11/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/11/root/usr/share/container-scripts/postgresql/scl_enable b/11/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/11/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index 60d70e36..00000000
--- a/11/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-_psql --set=username="$POSTGRESQL_USER" \
-      --set=password="$POSTGRESQL_PASSWORD" \
-<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
-      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
-<<'EOF'
-ALTER USER :"masteruser" WITH REPLICATION;
-ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
-EOF
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
-<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
-fi
diff --git a/11/s2i/bin/assemble b/11/s2i/bin/assemble
deleted file mode 100755
index 6ed8f7aa..00000000
--- a/11/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions --read-only ./
diff --git a/11/s2i/bin/run b/11/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/11/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/11/s2i/bin/usage b/11/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/11/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/11/test b/11/test
deleted file mode 120000
index 419df4f9..00000000
--- a/11/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file
diff --git a/Makefile b/Makefile
index a1904360..cf64682f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 11 12 13
+VERSIONS = 10 12 13
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 

From 6ef6f9f72ad3f4df0bd7d524e5745400a83a2140 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 19 Sep 2022 10:59:28 +0200
Subject: [PATCH 306/509] Switch from manifest.sh to manifest.yml for new
 generator

---
 manifest.sh  | 111 ---------------------------------------------------
 manifest.yml | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 111 deletions(-)
 delete mode 100644 manifest.sh
 create mode 100644 manifest.yml

diff --git a/manifest.sh b/manifest.sh
deleted file mode 100644
index 05a1adc1..00000000
--- a/manifest.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-# Manifest for image directories creation
-# every dest path will be prefixed by $DESTDIR/$version
-
-DESTDIR='' # optional, defaults to $PWD
-
-# Files containing distgen directives
-DISTGEN_RULES="
-    src=src/cccp.yml
-    dest=cccp.yml;
-
-    src=src/root/usr/share/container-scripts/postgresql/README.md
-    dest=root/usr/share/container-scripts/postgresql/README.md;
-
-    src=src/root/usr/share/container-scripts/postgresql/common.sh
-    dest=root/usr/share/container-scripts/postgresql/common.sh;
-
-    src=src/root/usr/bin/run-postgresql-slave
-    dest=root/usr/bin/run-postgresql-slave
-    mode=0755;
-
-    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
-    dest=root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template;
-
-    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
-    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template;
-
-"
-
-# Files containing distgen directives, which are used for each
-# (distro, version) combination not excluded in multispec
-DISTGEN_MULTI_RULES="
-    src=src/Dockerfile
-    dest=Dockerfile;
-
-    src=src/Dockerfile
-    dest=Dockerfile.rhel7;
-
-    src=src/Dockerfile
-    dest=Dockerfile.rhel8;
-
-    src=src/Dockerfile
-    dest=Dockerfile.rhel9;
-
-    src=src/Dockerfile
-    dest=Dockerfile.c9s;
-
-    src=src/Dockerfile
-    dest=Dockerfile.c8s;
-
-    src=src/Dockerfile.fedora
-    dest=Dockerfile.fedora;
-"
-
-# Symbolic links
-SYMLINK_RULES="
-    link_target=root/usr/share/container-scripts/postgresql/README.md
-    link_name=README.md;
-
-    link_target=../test
-    link_name=test;
-
-    link_target=/usr/bin/run-postgresql
-    link_name=s2i/bin/run
-"
-
-# Files to copy
-COPY_RULES="
-    src=src/root/usr/libexec/fix-permissions
-    dest=root/usr/libexec/fix-permissions
-    mode=0755;
-
-    src=src/content_sets.yml
-    dest=content_sets.yml;
-
-    src=src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
-    dest=root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template;
-
-    src=src/root/usr/share/container-scripts/postgresql/scl_enable
-    dest=root/usr/share/container-scripts/postgresql/scl_enable;
-
-    src=src/root/usr/bin/run-postgresql
-    dest=root/usr/bin/run-postgresql
-    mode=0755;
-
-    src=src/root/usr/bin/run-postgresql-master
-    dest=root/usr/bin/run-postgresql-master
-    mode=0755;
-
-    src=src/root/usr/bin/container-entrypoint
-    dest=root/usr/bin/container-entrypoint
-    mode=0755;
-
-    src=src/root/usr/bin/usage
-    dest=root/usr/bin/usage
-    mode=0755;
-
-    src=src/root/usr/libexec/check-container
-    dest=root/usr/libexec/check-container
-    mode=0755;
-
-    src=src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
-    dest=root/usr/share/container-scripts/postgresql/start/set_passwords.sh;
-
-    src=src/s2i/bin/assemble
-    dest=s2i/bin/assemble
-    mode=0755;
-
-    src=src/s2i/bin/usage
-    dest=s2i/bin/usage
-    mode=0755;
-"
diff --git a/manifest.yml b/manifest.yml
new file mode 100644
index 00000000..461c38b8
--- /dev/null
+++ b/manifest.yml
@@ -0,0 +1,110 @@
+# Manifest for image directories creation
+# every dest path will be prefixed by $DESTDIR/$version
+
+# Files containing distgen directives
+DISTGEN_RULES:
+  - src: src/cccp.yml
+    dest: cccp.yml
+
+  - src: src/root/usr/share/container-scripts/postgresql/README.md
+    dest: root/usr/share/container-scripts/postgresql/README.md
+
+  - src: src/root/usr/share/container-scripts/postgresql/common.sh
+    dest: root/usr/share/container-scripts/postgresql/common.sh
+
+  - src: src/root/usr/bin/run-postgresql-slave
+    dest: root/usr/bin/run-postgresql-slave
+    mode: "0755"
+
+  - src: src/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+    dest: root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+
+  - src: src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+    dest: root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+
+
+# Files containing distgen directives, which are used for each
+# (distro, version) combination not excluded in multispec
+DISTGEN_MULTI_RULES:
+  - src: src/Dockerfile
+    dest: Dockerfile.centos7
+
+  - src: src/Dockerfile
+    dest: Dockerfile.rhel7
+
+  - src: src/Dockerfile
+    dest: Dockerfile.rhel8
+
+  - src: src/Dockerfile
+    dest: Dockerfile.rhel9
+
+  - src: src/Dockerfile
+    dest: Dockerfile.c9s
+
+  - src: src/Dockerfile
+    dest: Dockerfile.c8s
+
+  - src: src/Dockerfile.fedora
+    dest: Dockerfile.fedora
+
+
+# Files to copy
+COPY_RULES:
+  - src: src/root/usr/libexec/fix-permissions
+    dest: root/usr/libexec/fix-permissions
+    mode: "0755"
+
+  - src: src/content_sets.yml
+    dest: content_sets.yml
+
+  - src: src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+    dest: root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+
+  - src: src/root/usr/share/container-scripts/postgresql/scl_enable
+    dest: root/usr/share/container-scripts/postgresql/scl_enable
+
+  - src: src/root/usr/bin/run-postgresql
+    dest: root/usr/bin/run-postgresql
+    mode: "0755"
+
+  - src: src/root/usr/bin/run-postgresql-master
+    dest: root/usr/bin/run-postgresql-master
+    mode: "0755"
+
+  - src: src/root/usr/bin/container-entrypoint
+    dest: root/usr/bin/container-entrypoint
+    mode: "0755"
+
+  - src: src/root/usr/bin/usage
+    dest: root/usr/bin/usage
+    mode: "0755"
+
+  - src: src/root/usr/libexec/check-container
+    dest: root/usr/libexec/check-container
+    mode: "0755"
+
+  - src: src/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+    dest: root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+
+  - src: src/s2i/bin/assemble
+    dest: s2i/bin/assemble
+    mode: "0755"
+
+  - src: src/s2i/bin/usage
+    dest: s2i/bin/usage
+    mode: "0755"
+
+
+# Symbolic links
+# This section is the last one on purpose because the generator.py
+# does not allow dead symlinks.
+SYMLINK_RULES:
+  - src: root/usr/share/container-scripts/postgresql/README.md
+    dest: README.md
+
+  - src: ../test
+    dest: test
+
+  - src: /usr/bin/run-postgresql
+    dest: s2i/bin/run
+    check_symlink: false  # Disable check of dead symlinks

From f9679c4154d755ff381b96b7ce8ebce861aa6cd6 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 19 Sep 2022 11:00:25 +0200
Subject: [PATCH 307/509] Clean and fix multispec.yml

---
 specs/multispec.yml | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 9b206420..2e93dc8e 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -92,11 +92,6 @@ specs:
       post_install: >-4
           yum -y reinstall tzdata && \
 
-    fedora:
-      distros:
-        - fedora-31-x86_64
-        - fedora-34-x86_64
-
   version:
     "9.6":
       version: "9.6"
@@ -156,8 +151,6 @@ specs:
 matrix:
   exclude:
     - distros:
-        - fedora-31-x86_64
-        - fedora-34-x86_64
         - rhel-7-x86_64
         - centos-7-x86_64
         - rhel-8-x86_64
@@ -166,8 +159,6 @@ matrix:
         - centos-stream-9-x86_64
       version: "9.6"
     - distros:
-        - fedora-31-x86_64
-        - fedora-34-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
       version: "10"
@@ -176,15 +167,14 @@ matrix:
         - rhel-8-x86_64
         - rhel-9-x86_64
         - centos-7-x86_64
-        - fedora-34-x86_64
         - centos-stream-8-x86_64
         - centos-stream-9-x86_64
       version: "11"
     - distros:
+        - centos-7-x86_64
         - rhel-9-x86_64
-        - fedora-34-x86_64
         - centos-stream-9-x86_64
       version: "12"
     - distros:
-        - fedora-31-x86_64
+        - centos-7-x86_64
       version: "13"

From 7a336a3a2ffea1cc16bb2f4903eb12764852674f Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 3 Oct 2022 13:49:02 +0200
Subject: [PATCH 308/509] Do not overload common make targets

For details, see https://github.com/sclorg/container-common-scripts/pull/294#issuecomment-1265321660
---
 Makefile | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/Makefile b/Makefile
index cf64682f..cfaa0621 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,3 @@ script_env += NOT_RELEASED_VERSIONS="$(NOT_RELEASED_VERSIONS)"
 # Additional upgrade tests.  Not hooked into CI ATM.
 upgrade-tests: $(VERSIONS)
 	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local
-
-build-serial: generate
-
-test-openshift-remote-cluster: generate

From 70a65b845f40ae33952243905cc642061dc7bd9e Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Wed, 12 Oct 2022 08:01:46 +0200
Subject: [PATCH 309/509] Remove useless cccp.yml files

---
 12/cccp.yml         | 1 -
 13/cccp.yml         | 1 -
 manifest.yml        | 3 ---
 specs/multispec.yml | 5 -----
 src/cccp.yml        | 1 -
 5 files changed, 11 deletions(-)
 delete mode 100644 12/cccp.yml
 delete mode 100644 13/cccp.yml
 delete mode 100644 src/cccp.yml

diff --git a/12/cccp.yml b/12/cccp.yml
deleted file mode 100644
index 23374d63..00000000
--- a/12/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-12-centos7
diff --git a/13/cccp.yml b/13/cccp.yml
deleted file mode 100644
index 2a88a7b7..00000000
--- a/13/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: postgresql-13-centos7
diff --git a/manifest.yml b/manifest.yml
index 461c38b8..64a5e92e 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -3,9 +3,6 @@
 
 # Files containing distgen directives
 DISTGEN_RULES:
-  - src: src/cccp.yml
-    dest: cccp.yml
-
   - src: src/root/usr/share/container-scripts/postgresql/README.md
     dest: root/usr/share/container-scripts/postgresql/README.md
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 2e93dc8e..cd8d2afb 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -101,7 +101,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-96-rhel7"
       centos_image_name: "centos/postgresql-96-centos7"
-      cccp_job: "postgresql-96-centos7"
       latest_fedora: "f27"
 
     "10":
@@ -112,7 +111,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos7/postgresql-10-centos7"
-      cccp_job: "postgresql-10-centos7"
       latest_fedora: "f29"
 
     "11":
@@ -121,7 +119,6 @@ specs:
       short: "11"
       prev_short: "10"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f31"
 
     "12":
@@ -132,7 +129,6 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
-      cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f33"
 
     "13":
@@ -144,7 +140,6 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      cccp_job: "postgresql-{{ spec.short }}-centos7"
       latest_fedora: "f34"
 
 
diff --git a/src/cccp.yml b/src/cccp.yml
deleted file mode 100644
index c49e80d4..00000000
--- a/src/cccp.yml
+++ /dev/null
@@ -1 +0,0 @@
-job-id: {{ spec.cccp_job }}

From ecdff565c303f7ae595eb064cc22437bd934e207 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Fri, 14 Oct 2022 14:22:09 +0200
Subject: [PATCH 310/509] Update common submodule

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 85f06416..baa8bb48 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 85f06416bf48f5c66766e605047d81e97d73199f
+Subproject commit baa8bb4813631eeaad4bc1b3755aa510ada12a72

From 642cde251f7f9518b3765b0ff56ef0d5f807e8af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lum=C3=ADr=20=27Frenzy=27=20Balhar?= <lbalhar@redhat.com>
Date: Fri, 14 Oct 2022 14:49:37 +0200
Subject: [PATCH 311/509] Remove version 11 from build and push action (#472)

---
 .github/workflows/build-and-push.yml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 8e785f46..e68153ee 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -56,12 +56,6 @@ jobs:
             suffix: "c8s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-          - dockerfile_path: "11"
-            dockerfile: "Dockerfile.fedora"
-            registry_namespace: "fedora"
-            tag: "11"
-            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
           - dockerfile_path: "12"
             dockerfile: "Dockerfile.fedora"
             registry_namespace: "fedora"

From 4b4994aba5b00c92c3975e58e1b3c5d10b573af0 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Fri, 14 Oct 2022 15:15:49 +0200
Subject: [PATCH 312/509] Generated files should be part of the repository

---
 .gitignore | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 41dd2ca0..11e45256 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,3 @@
 help.1
 /pagila*.rpm
 /postgresql-container-pagila.sql
-/9.[456]
-/10

From 810759ba04491c9dc98c6e60fb5ad88d0d2fcbec Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Fri, 14 Oct 2022 15:16:08 +0200
Subject: [PATCH 313/509] Add version 10, previously ignored by .gitignore

---
 10/Dockerfile.c8s                             |  83 +++
 10/Dockerfile.centos7                         |  89 ++++
 10/Dockerfile.rhel7                           |  93 ++++
 10/Dockerfile.rhel8                           |  84 +++
 10/README.md                                  |   1 +
 10/content_sets.yml                           |  10 +
 10/root/usr/bin/container-entrypoint          |   3 +
 10/root/usr/bin/run-postgresql                |  58 +++
 10/root/usr/bin/run-postgresql-master         |   5 +
 10/root/usr/bin/run-postgresql-slave          |  37 ++
 10/root/usr/bin/usage                         |   4 +
 10/root/usr/libexec/check-container           |  27 +
 10/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 331 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 479 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   9 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 10/s2i/bin/assemble                           |  14 +
 10/s2i/bin/run                                |   1 +
 10/s2i/bin/usage                              |   1 +
 10/test                                       |   1 +
 24 files changed, 1423 insertions(+)
 create mode 100644 10/Dockerfile.c8s
 create mode 100644 10/Dockerfile.centos7
 create mode 100644 10/Dockerfile.rhel7
 create mode 100644 10/Dockerfile.rhel8
 create mode 120000 10/README.md
 create mode 100644 10/content_sets.yml
 create mode 100755 10/root/usr/bin/container-entrypoint
 create mode 100755 10/root/usr/bin/run-postgresql
 create mode 100755 10/root/usr/bin/run-postgresql-master
 create mode 100755 10/root/usr/bin/run-postgresql-slave
 create mode 100755 10/root/usr/bin/usage
 create mode 100755 10/root/usr/libexec/check-container
 create mode 100755 10/root/usr/libexec/fix-permissions
 create mode 100644 10/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 10/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 10/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 10/s2i/bin/assemble
 create mode 120000 10/s2i/bin/run
 create mode 100755 10/s2i/bin/usage
 create mode 120000 10/test

diff --git a/10/Dockerfile.c8s b/10/Dockerfile.c8s
new file mode 100644
index 00000000..7bf0d107
--- /dev/null
+++ b/10/Dockerfile.c8s
@@ -0,0 +1,83 @@
+FROM quay.io/sclorg/s2i-core-c8s:c8s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=10 \
+    POSTGRESQL_PREV_VERSION=9.6 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 10" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql10,postgresql-10" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-10-c8s" \
+      com.redhat.component="postgresql-10-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-10-c8s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:10 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/10/Dockerfile.centos7 b/10/Dockerfile.centos7
new file mode 100644
index 00000000..d5315c79
--- /dev/null
+++ b/10/Dockerfile.centos7
@@ -0,0 +1,89 @@
+FROM quay.io/centos7/s2i-core-centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=10 \
+    POSTGRESQL_PREV_VERSION=9.6 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 10" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql10,rh-postgresql10" \
+      io.openshift.s2i.assemble-user="26" \
+      name="centos7/postgresql-10-centos7" \
+      com.redhat.component="rh-postgresql10-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-10-centos7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql10
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
new file mode 100644
index 00000000..f015cae6
--- /dev/null
+++ b/10/Dockerfile.rhel7
@@ -0,0 +1,93 @@
+FROM rhscl/s2i-core-rhel7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=10 \
+    POSTGRESQL_PREV_VERSION=9.6 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 10" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql10,rh-postgresql10" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhscl/postgresql-10-rhel7" \
+      com.redhat.component="rh-postgresql10-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-10-rhel7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
+RUN yum install -y yum-utils gettext && \
+    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql10
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8
new file mode 100644
index 00000000..33cbdbe3
--- /dev/null
+++ b/10/Dockerfile.rhel8
@@ -0,0 +1,84 @@
+FROM ubi8/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=10 \
+    POSTGRESQL_PREV_VERSION=9.6 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 10" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql10,postgresql-10" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel8/postgresql-10" \
+      com.redhat.component="postgresql-10-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-10" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:10 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/10/README.md b/10/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/10/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/10/content_sets.yml b/10/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/10/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms
diff --git a/10/root/usr/bin/container-entrypoint b/10/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/10/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/10/root/usr/bin/run-postgresql b/10/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/10/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/10/root/usr/bin/run-postgresql-master b/10/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/10/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/10/root/usr/bin/run-postgresql-slave b/10/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..82113b76
--- /dev/null
+++ b/10/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/recovery.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/10/root/usr/bin/usage b/10/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/10/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/10/root/usr/libexec/check-container b/10/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/10/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/10/root/usr/libexec/fix-permissions b/10/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/10/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..523cf19b
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,331 @@
+PostgreSQL 10 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 10 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-10-rhel7` image, available via `postgresql:10` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-10-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=10 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/10/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/10/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 9.6 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `rhscl/postgresql-10-rhel7` image,
+available via `postgresql:10` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:10~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-10-rhel7 new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..3e7fa61d
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,479 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/10/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..ef04eaae
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..26d56693
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,9 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+standby_mode = on
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/10/root/usr/share/container-scripts/postgresql/scl_enable b/10/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/10/s2i/bin/assemble b/10/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/10/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/10/s2i/bin/run b/10/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/10/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/10/s2i/bin/usage b/10/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/10/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/10/test b/10/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/10/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file

From 446e5b540cf2caa07a96389f71d645f08542eda0 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 19 Oct 2022 10:49:37 +0200
Subject: [PATCH 314/509] enable fedora for distgen generation

---
 specs/multispec.yml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index cd8d2afb..b179548c 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -2,6 +2,18 @@ version: 1
 
 specs:
   distroinfo:
+    fedora:
+      distros:
+        - fedora-35-x86_64
+      s2i_base: quay.io/fedora/s2i-core
+      org: "fedora"
+      prod: "fedora"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+      redhat_component: "postgresql-{{ spec.short }}-container"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "postgresql-server postgresql-contrib"
+      environment_setup: >-4
+           { yum -y module enable postgresql:{{ spec.version }} || :; } && \
     centos:
       distros:
         - centos-7-x86_64

From 1a259b92b5ecf19ec6c6421ce38b382c64a5d1b1 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 19 Oct 2022 10:51:31 +0200
Subject: [PATCH 315/509] enable postgres 12 and 13 for centos7

---
 specs/multispec.yml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index b179548c..82d54d09 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -178,10 +178,6 @@ matrix:
         - centos-stream-9-x86_64
       version: "11"
     - distros:
-        - centos-7-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
       version: "12"
-    - distros:
-        - centos-7-x86_64
-      version: "13"

From 50a3680528a7b52a1d78e5bee44c17bd9edbdb86 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 19 Oct 2022 10:54:39 +0200
Subject: [PATCH 316/509] add rule for creating symlink
 Dockerfile->Dockerfile.centos7

---
 manifest.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/manifest.yml b/manifest.yml
index 64a5e92e..9cfc48af 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -96,6 +96,9 @@ COPY_RULES:
 # This section is the last one on purpose because the generator.py
 # does not allow dead symlinks.
 SYMLINK_RULES:
+  - src: ./Dockerfile.centos7
+    dest: Dockerfile
+
   - src: root/usr/share/container-scripts/postgresql/README.md
     dest: README.md
 

From 5089c584cd180a8e56543110bdf890dfee0f0526 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Thu, 20 Oct 2022 13:11:50 +0200
Subject: [PATCH 317/509] remove v 9.6 and 11 from multispec, remove v10 for
 Fedora too

---
 specs/multispec.yml | 41 ++++-------------------------------------
 1 file changed, 4 insertions(+), 37 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 82d54d09..ef656b18 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -105,16 +105,6 @@ specs:
           yum -y reinstall tzdata && \
 
   version:
-    "9.6":
-      version: "9.6"
-      prev_version: "9.5"
-      short: "96"
-      prev_short: "95"
-      common_image_name: "{{ spec.org }}/postgresql-96-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-96-rhel7"
-      centos_image_name: "centos/postgresql-96-centos7"
-      latest_fedora: "f27"
-
     "10":
       version: "10"
       prev_version: "9.6"
@@ -123,15 +113,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-10-rhel7"
       centos_image_name: "centos7/postgresql-10-centos7"
-      latest_fedora: "f29"
-
-    "11":
-      version: "11"
-      prev_version: "10"
-      short: "11"
-      prev_short: "10"
-      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      latest_fedora: "f31"
+      latest_fedora: "f34"
 
     "12":
       version: "12"
@@ -141,7 +123,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
-      latest_fedora: "f33"
+      latest_fedora: "f35"
 
     "13":
       version: "13"
@@ -152,31 +134,16 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f34"
+      latest_fedora: "f35"
 
 
 matrix:
   exclude:
-    - distros:
-        - rhel-7-x86_64
-        - centos-7-x86_64
-        - rhel-8-x86_64
-        - rhel-9-x86_64
-        - centos-stream-8-x86_64
-        - centos-stream-9-x86_64
-      version: "9.6"
     - distros:
         - rhel-9-x86_64
         - centos-stream-9-x86_64
+        - fedora-35-x86_64
       version: "10"
-    - distros:
-        - rhel-7-x86_64
-        - rhel-8-x86_64
-        - rhel-9-x86_64
-        - centos-7-x86_64
-        - centos-stream-8-x86_64
-        - centos-stream-9-x86_64
-      version: "11"
     - distros:
         - rhel-9-x86_64
         - centos-stream-9-x86_64

From 762dc2e510e281c56af01cc91c452d9934807526 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Thu, 20 Oct 2022 13:20:04 +0200
Subject: [PATCH 318/509] add distgen-generated files

---
 10/Dockerfile         |  1 +
 12/Dockerfile         |  1 +
 12/Dockerfile.centos7 | 90 +++++++++++++++++++++++++++++++++++++++++++
 12/Dockerfile.fedora  | 83 +++++++++++++++++++++++++++++++++++++++
 13/Dockerfile         |  1 +
 13/Dockerfile.centos7 | 90 +++++++++++++++++++++++++++++++++++++++++++
 13/Dockerfile.fedora  | 83 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 349 insertions(+)
 create mode 120000 10/Dockerfile
 create mode 120000 12/Dockerfile
 create mode 100644 12/Dockerfile.centos7
 create mode 100644 12/Dockerfile.fedora
 create mode 120000 13/Dockerfile
 create mode 100644 13/Dockerfile.centos7
 create mode 100644 13/Dockerfile.fedora

diff --git a/10/Dockerfile b/10/Dockerfile
new file mode 120000
index 00000000..002d0b93
--- /dev/null
+++ b/10/Dockerfile
@@ -0,0 +1 @@
+./Dockerfile.centos7
\ No newline at end of file
diff --git a/12/Dockerfile b/12/Dockerfile
new file mode 120000
index 00000000..002d0b93
--- /dev/null
+++ b/12/Dockerfile
@@ -0,0 +1 @@
+./Dockerfile.centos7
\ No newline at end of file
diff --git a/12/Dockerfile.centos7 b/12/Dockerfile.centos7
new file mode 100644
index 00000000..bd5c7c9e
--- /dev/null
+++ b/12/Dockerfile.centos7
@@ -0,0 +1,90 @@
+FROM quay.io/centos7/s2i-core-centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=12 \
+    POSTGRESQL_PREV_VERSION=10 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 12" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql12,rh-postgresql12" \
+      io.openshift.s2i.assemble-user="26" \
+      name="centos7/postgresql-12-centos7" \
+      com.redhat.component="rh-postgresql12-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-12-centos7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
+    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql12
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
new file mode 100644
index 00000000..1fc8dfdb
--- /dev/null
+++ b/12/Dockerfile.fedora
@@ -0,0 +1,83 @@
+FROM quay.io/fedora/s2i-core:35
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=12 \
+    POSTGRESQL_PREV_VERSION=10 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 12" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql12" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="fedora/$NAME-12" \
+      version="0" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-12"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" pgaudit" && \
+    dnf -y module enable postgresql:12 && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile b/13/Dockerfile
new file mode 120000
index 00000000..002d0b93
--- /dev/null
+++ b/13/Dockerfile
@@ -0,0 +1 @@
+./Dockerfile.centos7
\ No newline at end of file
diff --git a/13/Dockerfile.centos7 b/13/Dockerfile.centos7
new file mode 100644
index 00000000..4ffeb76e
--- /dev/null
+++ b/13/Dockerfile.centos7
@@ -0,0 +1,90 @@
+FROM quay.io/centos7/s2i-core-centos7
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13,rh-postgresql13" \
+      io.openshift.s2i.assemble-user="26" \
+      name="centos7/postgresql-13-centos7" \
+      com.redhat.component="rh-postgresql13-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-13-centos7" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum install -y centos-release-scl-rh && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
+    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=rh-postgresql13
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# When bash is started non-interactively, to run a shell script, for example it
+# looks for this variable and source the content of this file. This will enable
+# the SCL for all scripts without need to do 'scl enable'.
+ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
+    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
new file mode 100644
index 00000000..1bdfea34
--- /dev/null
+++ b/13/Dockerfile.fedora
@@ -0,0 +1,83 @@
+FROM quay.io/fedora/s2i-core:35
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=12 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 13" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql13" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="fedora/$NAME-13" \
+      version="0" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-13"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" pgaudit" && \
+    dnf -y module enable postgresql:13 && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]

From ae2c7416d0a05899538007d99035f5147b45522c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zuzana=20Mikl=C3=A1nkov=C3=A1?= <zmiklank@redhat.com>
Date: Fri, 21 Oct 2022 10:10:21 +0200
Subject: [PATCH 319/509] use newest build-and-push action (#468)

Main change is, that the distgen will no longer be called before build
of the image in the build-and-push action.
---
 .github/workflows/build-and-push.yml | 54 ++++++++++++++--------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index e68153ee..a95ab111 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -14,72 +14,72 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - dockerfile_path: "10"
-            dockerfile: "Dockerfile"
+          - dockerfile: "10/Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-            suffix: "centos7"
+            image_name: "postgresql-10-centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-          - dockerfile_path: "12"
-            dockerfile: "Dockerfile"
+            docker_context: 10
+          - dockerfile: "12/Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-            suffix: "centos7"
+            image_name: "postgresql-12-centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-          - dockerfile_path: "13"
-            dockerfile: "Dockerfile"
+            docker_context: 12
+          - dockerfile: "13/Dockerfile"
             registry_namespace: "centos7"
             tag: "centos7"
-            suffix: "centos7"
+            image_name: "postgresql-13-centos7"
             quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-          - dockerfile_path: "13"
-            dockerfile: "Dockerfile.c9s"
+            docker_context: 13
+          - dockerfile: "13/Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
-            suffix: "c9s"
+            image_name: "postgresql-13-c9s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-          - dockerfile_path: "10"
-            dockerfile: "Dockerfile.c8s"
+            docker_context: 13
+          - dockerfile: "10/Dockerfile.c8s"
             registry_namespace: "sclorg"
             tag: "c8s"
-            suffix: "c8s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-          - dockerfile_path: "13"
-            dockerfile: "Dockerfile.c8s"
+            image_name: "postgresql-10-c8s"
+            docker_context: 10
+          - dockerfile: "13/Dockerfile.c8s"
             registry_namespace: "sclorg"
             tag: "c8s"
-            suffix: "c8s"
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-          - dockerfile_path: "12"
-            dockerfile: "Dockerfile.fedora"
+            image_name: "postgresql-13-c8s"
+            docker_context: 13
+          - dockerfile: "12/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "12"
             quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
-          - dockerfile_path: "13"
-            dockerfile: "Dockerfile.fedora"
+            image_name: "postgresql-12"
+            docker_context: 12
+          - dockerfile: "13/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "13"
             quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+            image_name: "postgresql-13"
+            docker_context: 13
 
     steps:
       - name: Build and push to quay.io registry
-        uses: sclorg/build-and-push-action@v2
+        uses: sclorg/build-and-push-action@v4
         with:
           registry: "quay.io"
           registry_namespace: ${{ matrix.registry_namespace }}
           registry_username: ${{ secrets[matrix.quayio_username] }}
           registry_token: ${{ secrets[matrix.quayio_token] }}
           dockerfile: ${{ matrix.dockerfile }}
-          docker_context: ${{ matrix.dockerfile_path }}
-          dockerfile_path: ${{ matrix.dockerfile_path }}
+          docker_context: ${{ matrix.docker_context }}
           tag: ${{ matrix.tag }}
-          use_distgen: "true"
-          suffix: ${{ matrix.suffix }}
+          image_name: ${{ matrix.image_name }}

From 46173f74a5c4509895ca18a15d6a4bfe0b2d489c Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 7 Nov 2022 13:31:45 +0100
Subject: [PATCH 320/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index baa8bb48..835ee1e7 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit baa8bb4813631eeaad4bc1b3755aa510ada12a72
+Subproject commit 835ee1e7d957e9eb4002ba0df1e2e5ce1b80e93c

From de2df219afc18b97d99825eebd0e140144031ae1 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 7 Nov 2022 13:32:51 +0100
Subject: [PATCH 321/509] Add support for testing imagestream on RHEL9

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 7e9074f8..3fc7c8d4 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -28,10 +28,6 @@ function test_postgresql_integration() {
 
 # Check the imagestream
 function test_postgresql_imagestream() {
-  case ${OS} in
-    rhel7|centos7|rhel8) ;;
-    *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
-  esac
   local tag="-el7"
   if [ "${OS}" == "rhel8" ]; then
     tag="-el8"

From d03a6b41c08ac657a57e31897c62858e500b0f9f Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 9 Nov 2022 12:06:38 +0100
Subject: [PATCH 322/509] Add tag for RHEL9

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 3fc7c8d4..52e842c6 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -31,6 +31,8 @@ function test_postgresql_imagestream() {
   local tag="-el7"
   if [ "${OS}" == "rhel8" ]; then
     tag="-el8"
+  elif [ "${OS}" == "rhel9" ]; then
+    tag="-el9"
   fi
   ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }

From 217d7ecfe50c401268d6f22563d52da2e859e5a4 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 15 Nov 2022 21:59:00 +0100
Subject: [PATCH 323/509] Add a test in Dockerfile directly to check the
 version

Otherwise when a wrong stream is installed, it's only found by scl test,
which is too late in the process and might even go through uncought,
especially when the scl test is removed for non-SCL distros at some point.
---
 10/Dockerfile.c8s     | 1 +
 10/Dockerfile.centos7 | 1 +
 10/Dockerfile.rhel7   | 1 +
 10/Dockerfile.rhel8   | 1 +
 12/Dockerfile.c8s     | 1 +
 12/Dockerfile.centos7 | 1 +
 12/Dockerfile.fedora  | 1 +
 12/Dockerfile.rhel7   | 1 +
 12/Dockerfile.rhel8   | 1 +
 13/Dockerfile.c8s     | 1 +
 13/Dockerfile.c9s     | 1 +
 13/Dockerfile.centos7 | 1 +
 13/Dockerfile.fedora  | 1 +
 13/Dockerfile.rhel7   | 1 +
 13/Dockerfile.rhel8   | 1 +
 13/Dockerfile.rhel9   | 1 +
 src/Dockerfile        | 1 +
 src/Dockerfile.fedora | 1 +
 18 files changed, 18 insertions(+)

diff --git a/10/Dockerfile.c8s b/10/Dockerfile.c8s
index 7bf0d107..9aff4d3e 100644
--- a/10/Dockerfile.c8s
+++ b/10/Dockerfile.c8s
@@ -45,6 +45,7 @@ RUN yum -y module enable postgresql:10 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/10/Dockerfile.centos7 b/10/Dockerfile.centos7
index d5315c79..2cf2e3f3 100644
--- a/10/Dockerfile.centos7
+++ b/10/Dockerfile.centos7
@@ -45,6 +45,7 @@ RUN yum install -y centos-release-scl-rh && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
index f015cae6..acb94437 100644
--- a/10/Dockerfile.rhel7
+++ b/10/Dockerfile.rhel7
@@ -49,6 +49,7 @@ RUN yum install -y yum-utils gettext && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8
index 33cbdbe3..00e5a917 100644
--- a/10/Dockerfile.rhel8
+++ b/10/Dockerfile.rhel8
@@ -46,6 +46,7 @@ RUN yum -y module enable postgresql:10 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/12/Dockerfile.c8s b/12/Dockerfile.c8s
index 7251587e..946cd278 100644
--- a/12/Dockerfile.c8s
+++ b/12/Dockerfile.c8s
@@ -46,6 +46,7 @@ RUN yum -y module enable postgresql:12 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/12/Dockerfile.centos7 b/12/Dockerfile.centos7
index bd5c7c9e..0d8102e1 100644
--- a/12/Dockerfile.centos7
+++ b/12/Dockerfile.centos7
@@ -46,6 +46,7 @@ RUN yum install -y centos-release-scl-rh && \
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index 1fc8dfdb..2915ad69 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -50,6 +50,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf -y module enable postgresql:12 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
index 0bdbb6be..75e7b688 100644
--- a/12/Dockerfile.rhel7
+++ b/12/Dockerfile.rhel7
@@ -50,6 +50,7 @@ RUN yum install -y yum-utils gettext && \
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index e387a241..2ff4eae9 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -47,6 +47,7 @@ RUN yum -y module enable postgresql:12 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/13/Dockerfile.c8s b/13/Dockerfile.c8s
index e4e526a4..60130b92 100644
--- a/13/Dockerfile.c8s
+++ b/13/Dockerfile.c8s
@@ -46,6 +46,7 @@ RUN yum -y module enable postgresql:13 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
index 69aa8ed2..65bdb635 100644
--- a/13/Dockerfile.c9s
+++ b/13/Dockerfile.c9s
@@ -46,6 +46,7 @@ RUN  { yum -y module enable postgresql:13 || :; } && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/13/Dockerfile.centos7 b/13/Dockerfile.centos7
index 4ffeb76e..70c67bdf 100644
--- a/13/Dockerfile.centos7
+++ b/13/Dockerfile.centos7
@@ -46,6 +46,7 @@ RUN yum install -y centos-release-scl-rh && \
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index 1bdfea34..c9178e84 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -50,6 +50,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf -y module enable postgresql:13 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
index 9bbe5ff9..93939459 100644
--- a/13/Dockerfile.rhel7
+++ b/13/Dockerfile.rhel7
@@ -50,6 +50,7 @@ RUN yum install -y yum-utils gettext && \
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index 0be804fb..622f056c 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -47,6 +47,7 @@ RUN yum -y module enable postgresql:13 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index 23d2a439..f448a5dd 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -47,6 +47,7 @@ RUN { yum -y module enable postgresql:13 || :; } && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/src/Dockerfile b/src/Dockerfile
index 13cc091f..a63d00ea 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -79,6 +79,7 @@ RUN {{ spec.environment_setup }}
 {% endif %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     {% if spec.post_install %}
     {{ spec.post_install }}
     {% endif %}
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 577e775a..0cccbaed 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -52,6 +52,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf -y module enable postgresql:{{ spec.version }} && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \

From 8c54d3c0ae29bd7e4d96b14e7d32d4b5fab975b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zuzana=20Mikl=C3=A1nkov=C3=A1?= <zmiklank@redhat.com>
Date: Fri, 2 Dec 2022 09:21:03 +0100
Subject: [PATCH 324/509] tests: change rhel9.0 compose to rhel9.1 compose
 (#479)

Change the TF compose to rhel-9.1.0-Nightly to find out, if the problem
with tests on RHEL9 machine is present here too.
---
 .github/workflows/container-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index e4ea3912..a9afb0c6 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -46,7 +46,7 @@ jobs:
           - tmt_plan: "rhel9-docker"
             os_test: "rhel9"
             context: "RHEL9"
-            compose: "RHEL-9.0.0-Nightly"
+            compose: "RHEL-9.1.0-Nightly"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"

From de57186cafeb7937e076b9b3368618aefedb72b1 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Fri, 2 Dec 2022 15:29:49 +0100
Subject: [PATCH 325/509] change rhel9 OC test compose from rhel9.0.0 to
 rhel9.1.0

---
 .github/workflows/openshift-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index b426f8ee..52203910 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -51,7 +51,7 @@ jobs:
           - tmt_plan: "rhel9-openshift-4"
             os_test: "rhel9"
             context: "RHEL9 - OpenShift 4"
-            compose: "RHEL-9.0.0-Nightly"
+            compose: "RHEL-9.1.0-Nightly"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"

From 47b78a44a03dac162a26cb2f3a2aa741ab470479 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Fri, 6 Jan 2023 15:50:26 +0100
Subject: [PATCH 326/509] add the latest common submodule

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 835ee1e7..2ce71d45 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 835ee1e7d957e9eb4002ba0df1e2e5ce1b80e93c
+Subproject commit 2ce71d454c33e46f2034e446e914d74a355989a5

From b4e9c16d4c8ec8114d04d74fadf6689b2bb6f966 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Fri, 6 Jan 2023 15:51:06 +0100
Subject: [PATCH 327/509] use ct_init for initialization of the test
 environment

---
 test/run_test | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/test/run_test b/test/run_test
index ac45a1f0..fe80e759 100755
--- a/test/run_test
+++ b/test/run_test
@@ -36,7 +36,6 @@ test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
 test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
-CID_FILE_DIR=$(mktemp --suffix=postgresql_test_cidfiles -d)
 
 volumes_to_clean=
 images_to_clean=()
@@ -868,6 +867,5 @@ POSTGRESQL_MAX_CONNECTIONS=100
 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0
 POSTGRESQL_SHARED_BUFFERS=32MB
 
-ct_enable_cleanup
-TEST_SUMMARY=''
+ct_init
 TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset 'postgresql-container_tests'

From 6009f6a67662390a0e4ec552a3782581ff33974d Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Thu, 12 Jan 2023 11:13:21 +0100
Subject: [PATCH 328/509] tests: remove container after killing it

---
 test/run_test | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/run_test b/test/run_test
index fe80e759..b5a5b132 100755
--- a/test/run_test
+++ b/test/run_test
@@ -517,6 +517,7 @@ function run_master_restart_test() {
   echo "Kill the master and create a new one"
   local cidfile=$CID_FILE_DIR/master-$cid_suffix.cid
   docker kill $(cat $cidfile)
+  docker rm -f $(cat $cidfile)
   # Don't forget to remove its .cid file
   rm $cidfile
 

From 23d48030e2e981183479f26fcff2c7239dc8f038 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zuzana=20Mikl=C3=A1nkov=C3=A1?= <zmiklank@redhat.com>
Date: Fri, 20 Jan 2023 09:04:07 +0100
Subject: [PATCH 329/509] add distgen check to CI tests (#485)

It will be ran with the pull request tests. It will fail the testsuite
before running actual tests if the content was not regenerated properly
in the PR.
---
 .github/workflows/container-tests.yml | 45 +++++++++++++++++++++++++++
 .github/workflows/openshift-tests.yml | 24 ++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index a9afb0c6..67d5445d 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -3,7 +3,52 @@ on:
     types:
       - created
 jobs:
+  distgen-check:
+    name: "Check distgen generated files"
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    steps:
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
+          submodules: true
+
+      - name: Check distgen generated files
+        id: check
+        shell: bash
+        run: |
+          sha=$(git rev-parse HEAD)
+          sudo apt update && sudo apt -y install python3-pip
+          pip3 install distgen
+          result="success"
+          ./common/tests/check_distgen_generated_files.sh || result="failure"
+          echo "result=$result" >> "$GITHUB_OUTPUT"
+          echo "sha=$sha" >> "$GITHUB_OUTPUT"
+
+      - name: Set final commit status
+        uses: myrotvorets/set-commit-status-action@1.1.5
+        with:
+          status: ${{ steps.check.outputs.result }}
+          context: "Distgen check"
+          sha: ${{ steps.check.outputs.sha }}
+
+      - name: Exit on ERR
+        shell: bash
+        run: |
+          _result=${{ steps.check.outputs.result }}
+          if [ "$_result" == failure ]; then
+            echo "Distgen-generated files are not regenerated properly."
+            echo "Please regenerate them with:"
+            echo "'make clean-versions'"
+            echo "'make generate-all'"
+            exit 1
+          fi
   container-tests:
+    needs: distgen-check
     # This job only runs for '[test]' pull request comments by owner, member
     runs-on: ubuntu-20.04
     name: "Container tests: ${{ matrix.version }} - ${{ matrix.context }}"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 52203910..6f0db292 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -3,7 +3,31 @@ on:
     types:
       - created
 jobs:
+  distgen-check:
+    name: "Check distgen generated files"
+    runs-on: ubuntu-20.04
+    if: |
+      github.event.issue.pull_request
+      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    steps:
+      - name: Checkout repo
+        uses: actions/checkout@v2
+        with:
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
+          submodules: true
+
+      - name: Check distgen generated files
+        id: check
+        shell: bash
+        run: |
+          sudo apt update && sudo apt -y install python3-pip
+          pip3 install distgen
+          result="success"
+          ./common/tests/check_distgen_generated_files.sh
+
   openshift-tests:
+    needs: distgen-check
     # This job only runs for '[test-all]' or '[test-openshift] pull request comments by owner, member
     name: "OpenShift tests: ${{ matrix.version }} - ${{ matrix.context }}"
     runs-on: ubuntu-20.04

From fe2525e9aa88058b3180d9419638d8cbe90ca68a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 26 Jan 2023 16:54:30 +0100
Subject: [PATCH 330/509] Add support for testing and pushing postgresql-15

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml  | 7 +++++++
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index a95ab111..84f11a0a 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -70,6 +70,13 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-13"
             docker_context: 13
+          - dockerfile: "15/Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "15"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+            image_name: "postgresql-15"
+            docker_context: 15
 
     steps:
       - name: Build and push to quay.io registry
diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 67d5445d..8e9bb648 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -55,7 +55,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13" ]
+        version: [ "10", "11", "12", "13", "15" ]
         os_test: [ "fedora", "centos7", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
         include:
           - tmt_plan: "fedora"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 6f0db292..0aad827f 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -34,7 +34,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13" ]
+        version: [ "10", "11", "12", "13", "15" ]
         os_test: [ "centos7", "rhel7", "rhel8", "rhel9"]
         include:
           - tmt_plan: "centos7"

From 8ace59ff8a1d6627e508306339c789141daa0363 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 26 Jan 2023 16:54:48 +0100
Subject: [PATCH 331/509] Add the latest container-common-scritps

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 2ce71d45..4d21ab6c 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 2ce71d454c33e46f2034e446e914d74a355989a5
+Subproject commit 4d21ab6c92f5845aaa0c52f30abe4a86ac56c09c

From 98ac6a43aea449ce095f803722cbe64ba1054329 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 9 Feb 2023 14:13:34 +0100
Subject: [PATCH 332/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 835ee1e7..4d21ab6c 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 835ee1e7d957e9eb4002ba0df1e2e5ce1b80e93c
+Subproject commit 4d21ab6c92f5845aaa0c52f30abe4a86ac56c09c

From 29463a85aa1213ba9dbb3b88d147194c1cb08170 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 9 Feb 2023 09:39:22 +0100
Subject: [PATCH 333/509] Add postgresql 15

Except obvious changes, there is a change in providing extra privileges
to the `master` user. There is a change in v15, that public schema is not
accessible for non-superuser as before.

Relevant upstream change:
Remove PUBLIC creation permission on the
[public schema](https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PUBLIC) (Noah Misch)
---
 .../container-scripts/postgresql/common.sh    |   2 +
 12/Dockerfile.fedora                          |   2 +-
 .../container-scripts/postgresql/common.sh    |   2 +
 13/Dockerfile.fedora                          |   2 +-
 .../container-scripts/postgresql/common.sh    |   2 +
 15/Dockerfile.c8s                             |  84 +++
 15/Dockerfile.c9s                             |  83 +++
 15/Dockerfile.fedora                          |  83 +++
 15/Dockerfile.rhel8                           |  85 ++++
 15/Dockerfile.rhel9                           |  85 ++++
 15/README.md                                  |   1 +
 15/content_sets.yml                           |  10 +
 15/root/usr/bin/container-entrypoint          |   3 +
 15/root/usr/bin/run-postgresql                |  58 +++
 15/root/usr/bin/run-postgresql-master         |   5 +
 15/root/usr/bin/run-postgresql-slave          |  39 ++
 15/root/usr/bin/usage                         |   4 +
 15/root/usr/libexec/check-container           |  27 +
 15/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 331 ++++++++++++
 .../container-scripts/postgresql/common.sh    | 481 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   8 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 15/s2i/bin/assemble                           |  14 +
 15/s2i/bin/run                                |   1 +
 15/s2i/bin/usage                              |   1 +
 15/test                                       |   1 +
 Makefile                                      |   2 +-
 specs/multispec.yml                           |  13 +
 src/Dockerfile.fedora                         |   2 +-
 .../container-scripts/postgresql/common.sh    |   2 +
 test/run_test                                 |   6 +-
 35 files changed, 1525 insertions(+), 7 deletions(-)
 create mode 100644 15/Dockerfile.c8s
 create mode 100644 15/Dockerfile.c9s
 create mode 100644 15/Dockerfile.fedora
 create mode 100644 15/Dockerfile.rhel8
 create mode 100644 15/Dockerfile.rhel9
 create mode 120000 15/README.md
 create mode 100644 15/content_sets.yml
 create mode 100755 15/root/usr/bin/container-entrypoint
 create mode 100755 15/root/usr/bin/run-postgresql
 create mode 100755 15/root/usr/bin/run-postgresql-master
 create mode 100755 15/root/usr/bin/run-postgresql-slave
 create mode 100755 15/root/usr/bin/usage
 create mode 100755 15/root/usr/libexec/check-container
 create mode 100755 15/root/usr/libexec/fix-permissions
 create mode 100644 15/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 15/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 15/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 15/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 15/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 15/s2i/bin/assemble
 create mode 120000 15/s2i/bin/run
 create mode 100755 15/s2i/bin/usage
 create mode 120000 15/test

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 3e7fa61d..1b339105 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -227,6 +227,8 @@ function create_users() {
 
   if [ -v POSTGRESQL_MASTER_USER ]; then
     createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
   fi
 }
 
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index 2915ad69..8c078b73 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:35
+FROM quay.io/fedora/s2i-core:37
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index 4b968f5a..fda53386 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -227,6 +227,8 @@ function create_users() {
 
   if [ -v POSTGRESQL_MASTER_USER ]; then
     createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
   fi
 }
 
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index c9178e84..6aaa5cca 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:35
+FROM quay.io/fedora/s2i-core:37
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 8c8b2dd6..15c11037 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -227,6 +227,8 @@ function create_users() {
 
   if [ -v POSTGRESQL_MASTER_USER ]; then
     createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
   fi
 }
 
diff --git a/15/Dockerfile.c8s b/15/Dockerfile.c8s
new file mode 100644
index 00000000..0f198a15
--- /dev/null
+++ b/15/Dockerfile.c8s
@@ -0,0 +1,84 @@
+FROM quay.io/sclorg/s2i-core-c8s:c8s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=15 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 15" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql15,postgresql-15" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-15-c8s" \
+      com.redhat.component="postgresql-15-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-15-c8s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:15 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
new file mode 100644
index 00000000..a7052e60
--- /dev/null
+++ b/15/Dockerfile.c9s
@@ -0,0 +1,83 @@
+FROM quay.io/sclorg/s2i-core-c9s:c9s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=15 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 15" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql15,postgresql-15" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-15-c9s" \
+      com.redhat.component="postgresql-15-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-15-c9s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN  { yum -y module enable postgresql:15 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
new file mode 100644
index 00000000..dfff0d05
--- /dev/null
+++ b/15/Dockerfile.fedora
@@ -0,0 +1,83 @@
+FROM quay.io/fedora/s2i-core:37
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=15 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 15" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql15" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="fedora/$NAME-15" \
+      version="0" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-15"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" pgaudit" && \
+    dnf -y module enable postgresql:15 && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
new file mode 100644
index 00000000..dfa0cd41
--- /dev/null
+++ b/15/Dockerfile.rhel8
@@ -0,0 +1,85 @@
+FROM ubi8/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=15 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 15" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql15,postgresql-15" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel8/postgresql-15" \
+      com.redhat.component="postgresql-15-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-15" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:15 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
new file mode 100644
index 00000000..ae832065
--- /dev/null
+++ b/15/Dockerfile.rhel9
@@ -0,0 +1,85 @@
+FROM ubi9/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=15 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 15" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql15,postgresql-15" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel9/postgresql-15" \
+      com.redhat.component="postgresql-15-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel9/postgresql-15" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN { yum -y module enable postgresql:15 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/15/README.md b/15/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/15/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/15/content_sets.yml b/15/content_sets.yml
new file mode 100644
index 00000000..432c0914
--- /dev/null
+++ b/15/content_sets.yml
@@ -0,0 +1,10 @@
+# This is a file defining which content sets are needed to update content in 
+# this image. Data provided here helps determine which images are vulnerable to
+# specific CVEs. Generally you should only need to update this file when:
+#    1. You start depending on new product
+#    2. You are preparing new product release and your content sets will change
+---
+x86_64:
+- rhel-7-server-rpms
+- rhel-7-server-optional-rpms
+- rhel-server-rhscl-7-rpms
diff --git a/15/root/usr/bin/container-entrypoint b/15/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/15/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/15/root/usr/bin/run-postgresql b/15/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/15/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/15/root/usr/bin/run-postgresql-master b/15/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/15/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/15/root/usr/bin/run-postgresql-slave b/15/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..586bf5d7
--- /dev/null
+++ b/15/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/15/root/usr/bin/usage b/15/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/15/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/15/root/usr/libexec/check-container b/15/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/15/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/15/root/usr/libexec/fix-permissions b/15/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/15/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..95b0dce8
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,331 @@
+PostgreSQL 15 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 15 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `` image, available via `postgresql:15` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=15 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/15/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/15/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    openshift/postgresql-92-centos7
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+Upgrading database (by switching to newer PostgreSQL image version)
+-------------------------------------------------------------------
+
+** Warning! Please, before you decide to do the data directory upgrade, always
+ensure that you've carefully backed up all your data and that you are OK with
+potential manual rollback! **
+
+This image supports automatic upgrade of data directory created by
+the PostgreSQL server version 13 (and _only_ this version) - provided by sclorg
+image.  The upgrade process is designed so that you should be able to just
+switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
+appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via `pg_upgrade` binary, and for
+that purpose the container needs to contain two versions of PostgreSQL server
+(have a look at `man pg_upgrade` for more info).
+
+For the `pg_upgrade` process - and the new server version, we need to initialize
+a brand new data directory.  That's data directory is created automatically by
+container tooling under /var/lib/pgsql/data, which is usually external
+bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
+approach -- it starts both old and new PostgreSQL servers (within container) and
+"dumps" the old datadir while and at the same time it "restores" it into new
+datadir.  This operation requires a lot of data files copying, so you can decide
+what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+**`copy`**  
+       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+
+**`hardlink`**  
+       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
+
+
+Note that because we copy data directory, you need to make sure that you have
+enough space for the copy;  upgrade failure because of not enough space might
+lead to data loss.
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `` image,
+available via `postgresql:15` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:15~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..1f1a11d7
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,481 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/15/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..d133e511
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/15/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/15/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..58d8e336
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,8 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/15/root/usr/share/container-scripts/postgresql/scl_enable b/15/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/15/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/15/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/15/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/15/s2i/bin/assemble b/15/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/15/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/15/s2i/bin/run b/15/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/15/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/15/s2i/bin/usage b/15/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/15/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/15/test b/15/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/15/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file
diff --git a/Makefile b/Makefile
index cfaa0621..71b7f998 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 12 13
+VERSIONS = 10 12 13 15
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index ef656b18..7a6c59be 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -136,6 +136,15 @@ specs:
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       latest_fedora: "f35"
 
+    "15":
+      version: "15"
+      prev_version: "13"
+      short: "15"
+      prev_short: "13"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
+      latest_fedora: "f37"
+
 
 matrix:
   exclude:
@@ -148,3 +157,7 @@ matrix:
         - rhel-9-x86_64
         - centos-stream-9-x86_64
       version: "12"
+    - distros:
+        - rhel-7-x86_64
+        - centos-7-x86_64
+      version: "15"
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 0cccbaed..5b395a9b 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:35
+FROM quay.io/fedora/s2i-core:37
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index a8592ffe..b9ed6770 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -228,6 +228,8 @@ function create_users() {
 
   if [ -v POSTGRESQL_MASTER_USER ]; then
     createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
   fi
 }
 
diff --git a/test/run_test b/test/run_test
index b5a5b132..e619e15b 100755
--- a/test/run_test
+++ b/test/run_test
@@ -625,7 +625,7 @@ run_upgrade_test ()
     # is fixed for non-SCL use cases
     { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 15 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -647,9 +647,9 @@ run_migration_test ()
     local from_version
     # Only test a subset of the migration path on non-intel hosts
     if [ "$(uname -i)" == "x86_64" ]; then
-        local upgrade_path="9.2 9.4 9.5 9.6 10 12 13"
+        local upgrade_path="9.2 9.4 9.5 9.6 10 12 13 15"
     else
-        local upgrade_path="10 12 13"
+        local upgrade_path="10 12 13 15"
     fi
 
     for from_version in $upgrade_path; do

From e3eb6d3c3f8a0a63c7fe4259c405d38f09dc3f8a Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 10 Feb 2023 13:18:22 +0100
Subject: [PATCH 334/509] Add generated checking version

---
 15/Dockerfile.c8s    | 1 +
 15/Dockerfile.c9s    | 1 +
 15/Dockerfile.fedora | 1 +
 15/Dockerfile.rhel8  | 1 +
 15/Dockerfile.rhel9  | 1 +
 5 files changed, 5 insertions(+)

diff --git a/15/Dockerfile.c8s b/15/Dockerfile.c8s
index 0f198a15..9dbb7809 100644
--- a/15/Dockerfile.c8s
+++ b/15/Dockerfile.c8s
@@ -46,6 +46,7 @@ RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
index a7052e60..7d8fcba8 100644
--- a/15/Dockerfile.c9s
+++ b/15/Dockerfile.c9s
@@ -46,6 +46,7 @@ RUN  { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index dfff0d05..9681e82c 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -50,6 +50,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf -y module enable postgresql:15 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index dfa0cd41..060df710 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -47,6 +47,7 @@ RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index ae832065..3233429d 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -47,6 +47,7 @@ RUN { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y reinstall tzdata && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \

From b8f7aa4514f8a07570cca9a50f047d34e39f6345 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 10 Feb 2023 13:18:48 +0100
Subject: [PATCH 335/509] Expect RHEL9 and cXs images being tested for
 migration

---
 test/pg-test-lib.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 76d9ced7..4d6e2c58 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -39,6 +39,18 @@ get_image_id ()
                 ns=rhel8
                 local image=registry.redhat.io/$ns/postgresql-${version}
                 ;;
+            rhel9)
+                ns=rhel9
+                local image=registry.redhat.io/$ns/postgresql-${version}
+                ;;
+            c8s)
+                ns=c8s
+                local image=quay.io/sclorg/postgresql-${version}-$ns
+                ;;
+            c9s)
+                ns=c9s
+                local image=quay.io/sclorg/postgresql-${version}-$ns
+                ;;
             esac
             docker pull "$image" >/dev/null
             echo "$image"

From fb4b7a7b49bc7c180829e20a37a563c7c0aba9c3 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 10 Feb 2023 22:00:22 +0100
Subject: [PATCH 336/509] Check properly all important commands after set -e
 was removed

---
 test/run_test | 254 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 164 insertions(+), 90 deletions(-)

diff --git a/test/run_test b/test/run_test
index e619e15b..04346fee 100755
--- a/test/run_test
+++ b/test/run_test
@@ -6,7 +6,7 @@
 # The image has to be available before this script is executed.
 #
 
-set -xo nounset
+set -o nounset
 shopt -s nullglob
 
 # library from container-common-scripts
@@ -118,7 +118,6 @@ function test_connection() {
   local sleep_time=2
   for i in $(seq $max_attempts); do
     echo "    Trying to connect..."
-    set +e
     # Don't let the code come here if neither user nor admin is able to
     # connect.
     if [ -v PGUSER ] && [ -v PASS ]; then
@@ -127,7 +126,6 @@ function test_connection() {
       PGUSER=postgres PASS=$ADMIN_PASS CONTAINER_IP=$ip DB=postgres postgresql_cmd <<< "SELECT 1;"
     fi
     status=$?
-    set -e
     if [ $status -eq 0 ]; then
       echo "  Success!"
       return 0
@@ -138,26 +136,38 @@ function test_connection() {
 }
 
 function test_postgresql() {
+  local ret=0
   echo "  Testing PostgreSQL"
-  postgresql_cmd <<< "CREATE EXTENSION 'uuid-ossp';" # to test contrib package
-  postgresql_cmd <<< "CREATE TABLE tbl (col1 VARCHAR(20), col2 VARCHAR(20));"
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo1', 'bar1');"
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo2', 'bar2');"
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo3', 'bar3');"
-  postgresql_cmd <<< "SELECT * FROM tbl;"
+  postgresql_cmd <<< "CREATE EXTENSION 'uuid-ossp';" || ret=1 # to test contrib package
+  postgresql_cmd <<< "CREATE TABLE tbl (col1 VARCHAR(20), col2 VARCHAR(20));" || ret=2
+  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo1', 'bar1');" || ret=3
+  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo2', 'bar2');" || ret=4
+  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo3', 'bar3');" || ret=5
+  postgresql_cmd <<< "SELECT * FROM tbl;" || ret=6
   #postgresql_cmd <<< "DROP TABLE tbl;"
-  echo "  Success!"
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 function create_container() {
   local name=$1 ; shift
   local cargs=${DOCKER_ARGS:-}
+  local ret=0
   # TODO: fix all create_container() invocations so that we don't need this,
   # e.g. multiline DOCKER_ARGS var should end by trailing backslashes
   cargs=$(echo "$cargs" | tr  '\n' ' ')
   cidfile="$CID_FILE_DIR/$name"
   # create container with a cidfile in a directory for cleanup
   eval "docker run $cargs --cidfile \$cidfile -d \$IMAGE_NAME \"\$@\""
+  ret=$?
+
+  if [ $ret -ne 0 ]; then
+    echo "ERROR: Creation of container didn't succeed"
+    return 1
+  fi
+
   echo "Created container $(cat $cidfile)"
 }
 
@@ -208,14 +218,13 @@ function assert_local_access() {
 
 # Make sure the invocation of docker run fails.
 function assert_container_creation_fails() {
+  local ret=0
 
   # Time the docker run command. It should fail. If it doesn't fail,
   # postgresql will keep running so we kill it with SIGKILL to make sure
   # timeout returns a non-zero value.
-  set +e
   timeout -s 9 --preserve-status 60s docker run --rm "$@" $IMAGE_NAME
   ret=$?
-  set -e
 
   # Timeout will exit with a high number.
   if [ $ret -gt 30 ]; then
@@ -234,6 +243,7 @@ assert_container_creation_succeeds ()
   local name=pg-success-"$(ct_random_string)"
   local PGUSER='' PGPASS=''  DB=''  ADMIN_PASS=
   local docker_args=
+  local ret=0
 
   for arg; do
     docker_args+=" $(printf "%q" "$arg")"
@@ -252,40 +262,49 @@ assert_container_creation_succeeds ()
     fi
   done
 
-  DOCKER_ARGS=$docker_args create_container "$name"
+  DOCKER_ARGS=$docker_args create_container "$name" || ret=1
 
   if test -n "$PGUSER" && test -n "$PGPASS"; then
-    PGUSER=$PGUSER PASS=$PGPASS DB=$DB test_connection "$name"
+    PGUSER=$PGUSER PASS=$PGPASS DB=$DB test_connection "$name" || ret=2
   fi
 
   if test -n "$ADMIN_PASS"; then
-    PGUSER=postgres PASS=$ADMIN_PASS DB=$DB test_connection "$name"
+    PGUSER=postgres PASS=$ADMIN_PASS DB=$DB test_connection "$name" || ret=3
   fi
+
+  return $ret
 }
 
 
 function try_image_invalid_combinations() {
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass "$@"
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_DATABASE=db "$@"
-  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db "$@"
+  local ret=0
+  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass "$@" || ret=1
+  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_DATABASE=db "$@" || ret=2
+  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db "$@" || ret=3
+  return $ret
 }
 
 function run_container_creation_tests() {
+  local ret=0
   echo "  Testing image entrypoint usage"
-  try_image_invalid_combinations
-  try_image_invalid_combinations  -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-
-  VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-  assert_container_creation_fails -e POSTGRESQL_USER= -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_fails -e POSTGRESQL_USER=$VERY_LONG_IDENTIFIER -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=$VERY_LONG_IDENTIFIER -e POSTGRESQL_ADMIN_PASSWORD=admin_pass
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\""
-  echo "  Success!"
-
-  assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD="the @password"
-  assert_container_creation_succeeds -e POSTGRESQL_PASSWORD="the pass" -e POSTGRESQL_USER="the user" -e POSTGRESQL_DATABASE="the db"
+  try_image_invalid_combinations || ret=1
+  try_image_invalid_combinations  -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=2
+
+VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+  assert_container_creation_fails -e POSTGRESQL_USER= -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=3
+  assert_container_creation_fails -e POSTGRESQL_USER=$VERY_LONG_IDENTIFIER -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=4
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=5
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=6
+  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=$VERY_LONG_IDENTIFIER -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=7
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\"" || ret=8
+
+  assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD="the @password" || ret=9
+  assert_container_creation_succeeds -e POSTGRESQL_PASSWORD="the pass" -e POSTGRESQL_USER="the user" -e POSTGRESQL_DATABASE="the db" || ret=10
+
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 function test_config_option() {
@@ -321,11 +340,15 @@ assert_runtime_option ()
 
 function run_configuration_tests() {
   local name=$1 ; shift
+  local ret=0
   echo "  Testing image configuration settings"
-  test_config_option ${name} max_connections ${POSTGRESQL_MAX_CONNECTIONS}
-  test_config_option ${name} max_prepared_transactions ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-  test_config_option ${name} shared_buffers ${POSTGRESQL_SHARED_BUFFERS}
-  echo "  Success!"
+  test_config_option ${name} max_connections ${POSTGRESQL_MAX_CONNECTIONS} || ret=1
+  test_config_option ${name} max_prepared_transactions ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS} || ret=2
+  test_config_option ${name} shared_buffers ${POSTGRESQL_SHARED_BUFFERS} || ret=3
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 test_scl_usage() {
@@ -355,6 +378,7 @@ test_scl_usage() {
 function run_tests() {
   echo "  Testing general usage (run_tests) with '$1' as argument"
   local name=$1 ; shift
+  local ret=0
 
   user_login=false
   admin_login=false
@@ -383,28 +407,30 @@ function run_tests() {
   fi
   DOCKER_ARGS="${DOCKER_ARGS:-} $envs" create_container $name
   CONTAINER_IP=$(get_container_ip $name)
-  test_connection $name
+  test_connection $name || ret=1
   echo "  Testing scl usage"
-  test_scl_usage $name 'psql --version' "$VERSION"
+  test_scl_usage $name 'psql --version' "$VERSION" || ret=2
 
   echo "  Testing login accesses"
-  assert_login_access "${PGUSER:-}"     "${PASS-}"            "$user_login"
-  assert_login_access "${PGUSER:-}"     "${PASS-}_foo"        false
+  assert_login_access "${PGUSER:-}"     "${PASS-}"            "$user_login" || ret=3
+  assert_login_access "${PGUSER:-}"     "${PASS-}_foo"        false || ret=4
 
-  assert_login_access postgres          "${ADMIN_PASS-}"      "$admin_login"
-  assert_login_access postgres          "${ADMIN_PASS-}_foo"  false
+  assert_login_access postgres          "${ADMIN_PASS-}"      "$admin_login" || ret=5  assert_login_access postgres          "${ADMIN_PASS-}_foo"  false || ret=6
 
-  assert_local_access $name
-  run_configuration_tests $name
-  echo "  Success!"
+  assert_local_access $name || ret=7
+  run_configuration_tests $name || ret=8
 
   if $user_login; then
-    test_postgresql $name
+    test_postgresql $name || ret=9
   fi
 
   if $admin_login; then
-    DB=postgres PGUSER=postgres PASS=$ADMIN_PASS test_postgresql $name
+    DB=postgres PGUSER=postgres PASS=$ADMIN_PASS test_postgresql $name || ret=10
+  fi
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
   fi
+  return $ret
 }
 
 function run_slave() {
@@ -503,6 +529,7 @@ function run_master_restart_test() {
   local table_name="t1"
   local master_ip=
   local slave_cids=
+  local ret=0
 
   create_volume_dir
   local master_args="-v ${volume_dir}:/var/lib/pgsql/data:Z"
@@ -526,20 +553,25 @@ function run_master_restart_test() {
 
   # Update master_ip in slaves
   for slave in $slave_cids; do
-    docker exec -u 0 $slave bash -c "sed \"s/$master_ip/$CONTAINER_IP/g\" /etc/hosts >/tmp/hosts && cp /tmp/hosts /etc/hosts"
+    docker exec -u 0 $slave bash -c "sed \"s/$master_ip/$CONTAINER_IP/g\" /etc/hosts >/tmp/hosts && cp /tmp/hosts /etc/hosts" || ret=1
   done
   master_ip=$CONTAINER_IP
   # Check if the new master sees existing slaves
-  test_slave_visibility
+  test_slave_visibility || ret=2
 
   # Check if the replication works
-  table_name="t1" test_value_replication
+  table_name="t1" test_value_replication || ret=3
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 function run_replication_test() {
   local DB=postgres
   local PGUSER=master
   local PASS=master
+  local ret=0
 
   echo "Testing master-slave replication"
   local cluster_args="-e POSTGRESQL_ADMIN_PASSWORD=pass -e POSTGRESQL_MASTER_USER=$PGUSER -e POSTGRESQL_MASTER_PASSWORD=$PASS"
@@ -548,14 +580,18 @@ function run_replication_test() {
   local slave_cids=
 
   # Setup the cluster
-  setup_replication_cluster
+  setup_replication_cluster || ret=1
 
   # Check if the master knows about the slaves
   CONTAINER_IP=$master_ip
-  test_slave_visibility
+  test_slave_visibility || ret=2
 
   # Do some real work to test replication in practice
-  table_name="t1" test_value_replication
+  table_name="t1" test_value_replication || ret=3
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 function run_change_password_test() {
@@ -566,8 +602,9 @@ function run_change_password_test() {
   local user='user'
   local password='password'
   local admin_password='adminPassword'
+  local ret=0
 
-  create_volume_dir
+  create_volume_dir || ret=1
   local volume_options="-v ${volume_dir}:/var/lib/pgsql/data:Z"
 
   DOCKER_ARGS="
@@ -576,7 +613,7 @@ function run_change_password_test() {
 -e POSTGRESQL_PASSWORD=${password}
 -e POSTGRESQL_ADMIN_PASSWORD=${admin_password}
 $volume_options
-" create_container ${name}
+" create_container ${name} || ret=2
 
   # need to set these because `postgresql_cmd` relies on global variables
   PGUSER=${user}
@@ -584,12 +621,12 @@ $volume_options
 
   # need this to wait for the container to start up
   CONTAINER_IP=$(get_container_ip ${name})
-  test_connection ${name}
+  test_connection ${name} || ret=3
 
   echo "  Testing login"
 
-  assert_login_access ${user} ${password} true
-  assert_login_access 'postgres' ${admin_password} true
+  assert_login_access ${user} ${password} true || ret=4
+  assert_login_access 'postgres' ${admin_password} true || ret=5
 
   echo "  Changing passwords"
 
@@ -599,28 +636,32 @@ $volume_options
 -e POSTGRESQL_PASSWORD=NEW_${password}
 -e POSTGRESQL_ADMIN_PASSWORD=NEW_${admin_password}
 $volume_options
-" create_container "${name}_NEW"
+" create_container "${name}_NEW" || ret=6
 
   # need to set this because `postgresql_cmd` relies on global variables
   PASS="NEW_${password}"
 
   # need this to wait for the container to start up
   CONTAINER_IP=$(get_container_ip "${name}_NEW")
-  test_connection "${name}_NEW"
+  test_connection "${name}_NEW" || ret=7
 
   echo "  Testing login with new passwords"
 
-  assert_login_access ${user} "NEW_${password}" true
-  assert_login_access ${user} ${password} false
+  assert_login_access ${user} "NEW_${password}" true || ret=8
+  assert_login_access ${user} ${password} false || ret=9
 
-  assert_login_access 'postgres' "NEW_${admin_password}" true
-  assert_login_access 'postgres' ${admin_password} false
+  assert_login_access 'postgres' "NEW_${admin_password}" true || ret=10
+  assert_login_access 'postgres' ${admin_password} false || ret=11
 
-  echo "  Success!"
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_upgrade_test ()
 {
+  local ret=0
     # Do not run on Fedora or RHEL8 until the upgrade script
     # is fixed for non-SCL use cases
     { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
@@ -637,11 +678,16 @@ run_upgrade_test ()
     docker pull "$(get_image_id "$prev:remote")" || return 0
 
     # TODO: We run this script from $VERSION directory, through test/run symlink.
-    test/run_upgrade_test "$prev:remote" "$VERSION:local"
+    test/run_upgrade_test "$prev:remote" "$VERSION:local" || ret=1
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_migration_test ()
 {
+  local ret=0
     [ "${OS}" == "fedora" ] && return 0
 
     local from_version
@@ -658,8 +704,12 @@ run_migration_test ()
             || break
         # Skip if the previous image is not available in the registry
         docker pull "$(get_image_id "$from_version:remote")" || continue
-        test/run_migration_test $from_version:remote $VERSION:local
+        test/run_migration_test $from_version:remote $VERSION:local || ret=1
     done
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_doc_test() {
@@ -689,8 +739,9 @@ run_doc_test() {
 test_the_app_image () {
   local container_name=$1
   local mount_opts=$2
+  local ret=0
   echo "    Testing s2i app image with invalid configuration"
-  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db
+  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db || ret=1
   echo "    Testing s2i app image with correct configuration"
 
     DOCKER_ARGS="
@@ -701,25 +752,30 @@ test_the_app_image () {
 -e POSTGRESQL_BACKUP_USER=backuser
 -e POSTGRESQL_BACKUP_PASSWORD=pass
 ${mount_opts}
-" create_container "$container_name"
+" create_container "$container_name" || ret=2
 
   # need this to wait for the container to start up
-  PGUSER=user     PASS=password           test_connection "$container_name"
-  PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name"
+  PGUSER=user     PASS=password           test_connection "$container_name" || ret=3
+  PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name" || ret=4
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_s2i_test() {
   local temp_file
+  local ret=0
   echo "  Testing s2i usage"
-  ct_s2i_usage "${IMAGE_NAME}" --pull-policy=never 1>/dev/null
+  ct_s2i_usage "${IMAGE_NAME}" --pull-policy=never 1>/dev/null || ret=1
 
   echo "  Testing s2i build"
 
   local s2i_image_name=$IMAGE_NAME-testapp_$(ct_random_string)
   images_to_clean+=( "$s2i_image_name" )
 
-  ct_s2i_build_as_df "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
-  IMAGE_NAME=$s2i_image_name test_the_app_image s2i_config_build ""
+  ct_s2i_build_as_df "file://${test_dir}/test-app" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null || ret=2
+  IMAGE_NAME=$s2i_image_name test_the_app_image s2i_config_build "" || ret=3
 
   echo "  Testing s2i mount"
   create_temp_file
@@ -728,22 +784,31 @@ run_s2i_test() {
   # Test against original image, not the s2i one.  But even if so, we expect
   # user mouns the directory under "s2i" direcetory $APP_DATA/src.
   local mount_point=/opt/app-root/src/postgresql-init/add_backup_user.sh
-  test_the_app_image _s2i_test_mount "-v ${temp_file}:$mount_point:z,ro"
-  echo "  Success!"
+  test_the_app_image _s2i_test_mount "-v ${temp_file}:$mount_point:z,ro" || ret=4
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 function run_general_tests() {
-  PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin
-  PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin
-  DB=postgres ADMIN_PASS=r00t run_tests only_admin
+  local ret=0
+  PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin || ret=1
+  PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin || ret=2
+  DB=postgres ADMIN_PASS=r00t run_tests only_admin || ret=3
   # Test with arbitrary uid for the container
-  DOCKER_ARGS="-u 12345" PGUSER=user2 PASS=pass run_tests no_admin_altuid
-  DOCKER_ARGS="-u 12345" PGUSER=user3 PASS=pass1 ADMIN_PASS=r00t run_tests admin_altuid
-  DB=postgres DOCKER_ARGS="-u 12345" ADMIN_PASS=rOOt run_tests only_admin_altuid
+  DOCKER_ARGS="-u 12345" PGUSER=user2 PASS=pass run_tests no_admin_altuid || ret=4
+  DOCKER_ARGS="-u 12345" PGUSER=user3 PASS=pass1 ADMIN_PASS=r00t run_tests admin_altuid || ret=5
+  DB=postgres DOCKER_ARGS="-u 12345" ADMIN_PASS=rOOt run_tests only_admin_altuid || ret=6
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_test_cfg_hook()
 {
+  local ret=0
   local volume_dir name=pg-test-cfg-dir
   volume_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
   add_cleanup_command /bin/rm -rf "$volume_dir"
@@ -755,14 +820,14 @@ run_test_cfg_hook()
 -e POSTGRESQL_ADMIN_PASSWORD=password
 -v $volume_dir:/opt/app-root/src:Z
   " create_container "$name"
-  assert_runtime_option "$name" shared_buffers 111MB
+  assert_runtime_option "$name" shared_buffers 111MB || ret=1
 
   # Check that POSTGRESQL_SHARED_BUFFERS has effect.
   DOCKER_ARGS="
 -e POSTGRESQL_ADMIN_PASSWORD=password
 -e POSTGRESQL_SHARED_BUFFERS=113MB
   " create_container "$name-2"
-  assert_runtime_option "$name-2" shared_buffers 113MB
+  assert_runtime_option "$name-2" shared_buffers 113MB || ret=2
 
   # Check that volume has priority over POSTGRESQL_SHARED_BUFFERS.
   DOCKER_ARGS="
@@ -770,7 +835,11 @@ run_test_cfg_hook()
 -e POSTGRESQL_SHARED_BUFFERS=113MB
 -v $volume_dir:/opt/app-root/src:Z
   " create_container "$name-3"
-  assert_runtime_option "$name-3" shared_buffers 111MB
+  assert_runtime_option "$name-3" shared_buffers 111MB || ret=3
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 run_s2i_enable_ssl_test()
@@ -812,6 +881,7 @@ run_s2i_bake_data_test ()
 
 run_pgaudit_test()
 {
+  local ret=0
   # extension pgaudit is not available for older versions
   case ${VERSION} in
     9.6|10|11) echo "pgaudit not expected, test skipped."; return ;;
@@ -836,7 +906,7 @@ run_pgaudit_test()
 -v ${data_dir}:/var/lib/pgsql/data:Z
   " create_container "$name"
 
-  assert_runtime_option "$name" shared_preload_libraries pgaudit
+  assert_runtime_option "$name" shared_preload_libraries pgaudit || ret=1
   wait_ready "$name"
 
   # enable the pgaudit extension
@@ -846,7 +916,7 @@ run_pgaudit_test()
 CREATE EXTENSION pgaudit;
 SET pgaudit.log = 'read, ddl';
 CREATE DATABASE pgaudittest;
-EOSQL"
+EOSQL" || ret=2
 
   # simulate some trafic that should be audited
   docker exec -i $(get_cid "$name") bash -c "psql pgaudittest <<EOSQL
@@ -854,13 +924,17 @@ SET pgaudit.log = 'read, ddl';
 CREATE TABLE account (id int, name text, password text, description text);
 INSERT INTO account (id, name, password, description) VALUES (1, 'user1', 'HASH1', 'blah, blah');
 SELECT * FROM account;
-EOSQL"
+EOSQL" || ret=3
 
   # give server some time for write all audit messages
   sleep 1
 
-  grep -E 'AUDIT: SESSION,.*,.*,DDL,CREATE DATABASE,,,CREATE DATABASE pgaudittest' "${data_dir}"/userdata/log/postgresql-*.log
-  grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
+  grep -E 'AUDIT: SESSION,.*,.*,DDL,CREATE DATABASE,,,CREATE DATABASE pgaudittest' "${data_dir}"/userdata/log/postgresql-*.log || ret=4
+  grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log || ret=5
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 # configuration defaults

From ba95c43801e8a0a24e8703fd8c62d62f20b595c4 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 13 Feb 2023 13:09:22 +0100
Subject: [PATCH 337/509] Get back to f35 for older versions as I'm not able to
 build modules

Reported: https://pagure.io/releng/issue/11280
---
 12/Dockerfile.fedora  | 2 +-
 13/Dockerfile.fedora  | 2 +-
 src/Dockerfile.fedora | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index 8c078b73..2915ad69 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:37
+FROM quay.io/fedora/s2i-core:35
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index 6aaa5cca..c9178e84 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:37
+FROM quay.io/fedora/s2i-core:35
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 5b395a9b..1503425c 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,8 @@
+{% if spec.version == "15" %}
 FROM quay.io/fedora/s2i-core:37
+{% else %}
+FROM quay.io/fedora/s2i-core:35
+{% endif %}
 
 # PostgreSQL image for OpenShift.
 # Volumes:

From b610f74310c4ce033ac6713a3acedb2d992fb1f6 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 13 Feb 2023 16:30:50 +0100
Subject: [PATCH 338/509] Update README.md files to catch more recent versions

---
 .../container-scripts/postgresql/README.md    |  4 +--
 .../container-scripts/postgresql/README.md    |  4 +--
 .../container-scripts/postgresql/README.md    |  4 +--
 .../container-scripts/postgresql/README.md    |  4 +--
 README.md                                     | 35 +++++++++++--------
 .../container-scripts/postgresql/README.md    |  4 +--
 6 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index 523cf19b..dcf1a8a5 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -133,7 +133,7 @@ $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
+    rhel8/postgresql-13
 ```
 
 The migration is done the **dump and restore** way (running `pg_dumpall` against
@@ -147,7 +147,7 @@ result of scripted, unattended migration. In most common cases, successful
 migration is expected (but not guaranteed!), given you migrate from
 a previous version of PostgreSQL server container, that is created using
 the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
 Migration from a different kind of PostgreSQL container can likely fail.
 
 If this **all** or **nothing** principle is inadequate for you, and you know
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index f92d9665..0aeb8307 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -133,7 +133,7 @@ $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
+    rhel8/postgresql-13
 ```
 
 The migration is done the **dump and restore** way (running `pg_dumpall` against
@@ -147,7 +147,7 @@ result of scripted, unattended migration. In most common cases, successful
 migration is expected (but not guaranteed!), given you migrate from
 a previous version of PostgreSQL server container, that is created using
 the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
 Migration from a different kind of PostgreSQL container can likely fail.
 
 If this **all** or **nothing** principle is inadequate for you, and you know
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index fb1dbfa2..4205164e 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -133,7 +133,7 @@ $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
+    rhel8/postgresql-13
 ```
 
 The migration is done the **dump and restore** way (running `pg_dumpall` against
@@ -147,7 +147,7 @@ result of scripted, unattended migration. In most common cases, successful
 migration is expected (but not guaranteed!), given you migrate from
 a previous version of PostgreSQL server container, that is created using
 the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
 Migration from a different kind of PostgreSQL container can likely fail.
 
 If this **all** or **nothing** principle is inadequate for you, and you know
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index 95b0dce8..913bdca4 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -133,7 +133,7 @@ $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
+    rhel8/postgresql-13
 ```
 
 The migration is done the **dump and restore** way (running `pg_dumpall` against
@@ -147,7 +147,7 @@ result of scripted, unattended migration. In most common cases, successful
 migration is expected (but not guaranteed!), given you migrate from
 a previous version of PostgreSQL server container, that is created using
 the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
 Migration from a different kind of PostgreSQL container can likely fail.
 
 If this **all** or **nothing** principle is inadequate for you, and you know
diff --git a/README.md b/README.md
index d1d4f996..d78daa69 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,13 @@ Images available on Quay are:
 * CentOS 7 [postgresql-13](https://quay.io/repository/centos7/postgresql-13-centos7)
 * CentOS Stream 8 [postgresql-10](https://quay.io/repository/sclorg/postgresql-10-c8s)
 * CentOS Stream 8 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c8s)
+* CentOS Stream 8 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c8s)
 * CentOS Stream 9 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c9s)
+* CentOS Stream 9 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c9s)
 * Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
 * Fedora [postgresql-12](https://quay.io/repository/fedora/postgresql-12)
 * Fedora [postgresql-13](https://quay.io/repository/fedora/postgresql-13)
+* Fedora [postgresql-15](https://quay.io/repository/fedora/postgresql-15)
 
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
 Users can choose between RHEL, Fedora and CentOS based images.
@@ -32,6 +35,7 @@ PostgreSQL versions currently supported are:
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
 * [postgresql-13](https://github.com/sclorg/postgresql-container/tree/generated/13)
+* [postgresql-15](https://github.com/sclorg/postgresql-container/tree/generated/15)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -46,31 +50,31 @@ CentOS versions currently supported are:
 
 Installation
 ----------------------
-Choose either the CentOS7 or RHEL7 based image:
+Choose either the CentOS Stream 9 or RHEL9 based image:
 
-*  **RHEL7 based image**
+*  **RHEL9 based image**
 
-    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/postgresql-13-rhel7).
+    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhel9/postgresql-13).
     To download it run:
     ```
-    podman pull registry.redhat.io/rhscl/postgresql-13-rhel7
+    podman pull registry.redhat.io/rhel9/postgresql-13
     ```
 
-    To build a RHEL7 based image, you need to run Docker build on a properly
+    To build a RHEL9 based image, you need to run Docker build on a properly
     subscribed RHEL machine.
 
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=rhel7 VERSIONS=13
+    $ make build TARGET=rhel9 VERSIONS=13
     ```
 
-*  **CentOS7 based image**
+*  **CentOS Stream 9 based image**
 
     These images are available on Quay.io. To download it run:
 
     ```
-    $ podman pull quay.io/centos7/postgresql-13-centos7
+    $ podman pull https://quay.io/repository/sclorg/postgresql-13-c9s
     ```
 
     To build a PostgreSQL image from scratch run:
@@ -78,7 +82,7 @@ Choose either the CentOS7 or RHEL7 based image:
     ```
     $ git clone --recursive https://github.com/sclorg/postgresql-container.git
     $ cd postgresql
-    $ make build TARGET=centos7 VERSIONS=13
+    $ make build TARGET=c9s VERSIONS=13
     ```
 
 Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments.
@@ -103,6 +107,9 @@ see [usage documentation](https://github.com/sclorg/postgresql-container/tree/ge
 For information about usage of Dockerfile for PostgreSQL 13,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/13).
 
+For information about usage of Dockerfile for PostgreSQL 15,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/15).
+
 For versions which are not supported anymore:
 
 * [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
@@ -114,23 +121,23 @@ Test
 This repository also provides a test framework, which checks basic functionality
 of the PostgreSQL image.
 
-Users can choose between testing PostgreSQL based on a RHEL or CentOS image.
+Users can choose between testing PostgreSQL based on a RHEL or CentOS Stream image.
 
 *  **RHEL based image**
 
-    To test a RHEL7 based PostgreSQL image, you need to run the test on a properly
+    To test a RHEL9 based PostgreSQL image, you need to run the test on a properly
     subscribed RHEL machine.
 
     ```
     $ cd postgresql
-    $ make test TARGET=rhel7 VERSIONS=13
+    $ make test TARGET=rhel9 VERSIONS=13
     ```
 
-*  **CentOS based image**
+*  **CentOS Stream based image**
 
     ```
     $ cd postgresql
-    $ make test TARGET=centos7 VERSIONS=13
+    $ make test TARGET=c9s VERSIONS=13
     ```
 +By using the `TESTS` parameter you can choose a test case subset to be run against the image, eg:
 
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 73d9ad54..150b3cef 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -133,7 +133,7 @@ $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
     [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    openshift/postgresql-92-centos7
+    rhel8/postgresql-13
 ```
 
 The migration is done the **dump and restore** way (running `pg_dumpall` against
@@ -147,7 +147,7 @@ result of scripted, unattended migration. In most common cases, successful
 migration is expected (but not guaranteed!), given you migrate from
 a previous version of PostgreSQL server container, that is created using
 the same principles as this one (e.g. migration from
-`openshift/postgresql-92-centos7` to `centos/postgresql-95-centos7`).
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
 Migration from a different kind of PostgreSQL container can likely fail.
 
 If this **all** or **nothing** principle is inadequate for you, and you know

From cfdc68049a65f2ae6672f42042694c119902b300 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 13 Feb 2023 16:34:35 +0100
Subject: [PATCH 339/509] Return mising new-line

---
 test/run_test | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 04346fee..f281aa79 100755
--- a/test/run_test
+++ b/test/run_test
@@ -415,7 +415,8 @@ function run_tests() {
   assert_login_access "${PGUSER:-}"     "${PASS-}"            "$user_login" || ret=3
   assert_login_access "${PGUSER:-}"     "${PASS-}_foo"        false || ret=4
 
-  assert_login_access postgres          "${ADMIN_PASS-}"      "$admin_login" || ret=5  assert_login_access postgres          "${ADMIN_PASS-}_foo"  false || ret=6
+  assert_login_access postgres          "${ADMIN_PASS-}"      "$admin_login" || ret=5
+  assert_login_access postgres          "${ADMIN_PASS-}_foo"  false || ret=6
 
   assert_local_access $name || ret=7
   run_configuration_tests $name || ret=8

From e773fe833d57d8df51dfbdfed355d62e185ff2ff Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 13 Feb 2023 16:44:57 +0100
Subject: [PATCH 340/509] Do not claim nor test that upgrade works where it
 does not

---
 .../container-scripts/postgresql/README.md    | 36 -------------------
 .../container-scripts/postgresql/README.md    | 36 -------------------
 .../container-scripts/postgresql/README.md    | 36 -------------------
 .../container-scripts/postgresql/README.md    | 36 -------------------
 .../container-scripts/postgresql/README.md    |  2 ++
 test/run_test                                 |  6 ++--
 6 files changed, 5 insertions(+), 147 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index dcf1a8a5..e46787a7 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -208,42 +208,6 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 9.6 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
 
 
 Extending image
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 0aeb8307..5fdd9437 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -208,42 +208,6 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 10 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
 
 
 Extending image
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index 4205164e..fbbc5047 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -208,42 +208,6 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 12 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
 
 
 Extending image
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index 913bdca4..7a4e4efb 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -208,42 +208,6 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
-Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version 13 (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
-
-**`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
-
-**`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
-
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
 
 
 Extending image
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 150b3cef..4ae6b343 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -208,6 +208,7 @@ container starts it will reset the passwords to the values stored in the
 environment variables.
 
 
+{% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
 Upgrading database (by switching to newer PostgreSQL image version)
 -------------------------------------------------------------------
 
@@ -244,6 +245,7 @@ what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
 Note that because we copy data directory, you need to make sure that you have
 enough space for the copy;  upgrade failure because of not enough space might
 lead to data loss.
+{% endif %}
 
 
 Extending image
diff --git a/test/run_test b/test/run_test
index f281aa79..7fd1f966 100755
--- a/test/run_test
+++ b/test/run_test
@@ -663,11 +663,11 @@ $volume_options
 run_upgrade_test ()
 {
   local ret=0
-    # Do not run on Fedora or RHEL8 until the upgrade script
+    # Do not run on Fedora or RHEL8+ until the upgrade script
     # is fixed for non-SCL use cases
-    { [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
+    { [ "${OS}" != "centos7" ] && [ "${OS}" != "rhel7" ]; } && return 0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 15 none" prev= act=
+    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break

From 5a4fb21508d5079a4bc85b066552e88c3e023292 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 13 Feb 2023 16:48:48 +0100
Subject: [PATCH 341/509] Add devel repos (manually, cannot find out how to do
 it by distgen)

---
 15/.devel-repo-rhel8 | 0
 15/.devel-repo-rhel9 | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 15/.devel-repo-rhel8
 create mode 100644 15/.devel-repo-rhel9

diff --git a/15/.devel-repo-rhel8 b/15/.devel-repo-rhel8
new file mode 100644
index 00000000..e69de29b
diff --git a/15/.devel-repo-rhel9 b/15/.devel-repo-rhel9
new file mode 100644
index 00000000..e69de29b

From 7b8de33b598c79eff484ec668c9e2f35ea26074c Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 10:16:15 +0100
Subject: [PATCH 342/509] Add devel repo directly to the Dockerfile before we
 can selectively enable where we need

---
 10/Dockerfile.rhel7  | 2 --
 12/Dockerfile.rhel7  | 2 --
 13/Dockerfile.rhel7  | 2 --
 15/.devel-repo-rhel8 | 0
 15/.devel-repo-rhel9 | 0
 15/Dockerfile.rhel8  | 1 +
 15/Dockerfile.rhel9  | 1 +
 specs/multispec.yml  | 2 ++
 src/Dockerfile       | 2 +-
 9 files changed, 5 insertions(+), 7 deletions(-)
 delete mode 100644 15/.devel-repo-rhel8
 delete mode 100644 15/.devel-repo-rhel9

diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
index acb94437..ec9e5c78 100644
--- a/10/Dockerfile.rhel7
+++ b/10/Dockerfile.rhel7
@@ -42,8 +42,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
index 75e7b688..33ab8c44 100644
--- a/12/Dockerfile.rhel7
+++ b/12/Dockerfile.rhel7
@@ -42,8 +42,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
index 93939459..f9bd6137 100644
--- a/13/Dockerfile.rhel7
+++ b/13/Dockerfile.rhel7
@@ -42,8 +42,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
diff --git a/15/.devel-repo-rhel8 b/15/.devel-repo-rhel8
deleted file mode 100644
index e69de29b..00000000
diff --git a/15/.devel-repo-rhel9 b/15/.devel-repo-rhel9
deleted file mode 100644
index e69de29b..00000000
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 060df710..6b413247 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -42,6 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo
 RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 3233429d..39792894 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -42,6 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-9-devel.repo
 RUN { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 7a6c59be..d28579a0 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -59,6 +59,7 @@ specs:
        redhat_component: "postgresql-{{ spec.short }}-container"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
+       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo"
        environment_setup: >-4
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
@@ -73,6 +74,7 @@ specs:
        redhat_component: "postgresql-{{ spec.short }}-container"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
+       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-9-devel.repo"
        environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
        post_install: >-4
diff --git a/src/Dockerfile b/src/Dockerfile
index a63d00ea..272bc7d4 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -52,7 +52,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-{% if spec.repo_enable_reason %}
+{% if spec.repo_enable_reason and spec.version == "15" %}
 {{ spec.repo_enable_reason }}
 {% endif %}
 RUN {{ spec.environment_setup }}

From d615fc3300e507f10cf104d413f863b11b245987 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 10:19:19 +0100
Subject: [PATCH 343/509] Removing content_sets.yml as suggested during review

---
 10/content_sets.yml  | 10 ----------
 12/content_sets.yml  | 10 ----------
 13/content_sets.yml  | 10 ----------
 15/content_sets.yml  | 10 ----------
 manifest.yml         |  3 ---
 src/content_sets.yml | 10 ----------
 6 files changed, 53 deletions(-)
 delete mode 100644 10/content_sets.yml
 delete mode 100644 12/content_sets.yml
 delete mode 100644 13/content_sets.yml
 delete mode 100644 15/content_sets.yml
 delete mode 100644 src/content_sets.yml

diff --git a/10/content_sets.yml b/10/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/10/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms
diff --git a/12/content_sets.yml b/12/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/12/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms
diff --git a/13/content_sets.yml b/13/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/13/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms
diff --git a/15/content_sets.yml b/15/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/15/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms
diff --git a/manifest.yml b/manifest.yml
index 9cfc48af..44fb951f 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -51,9 +51,6 @@ COPY_RULES:
     dest: root/usr/libexec/fix-permissions
     mode: "0755"
 
-  - src: src/content_sets.yml
-    dest: content_sets.yml
-
   - src: src/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
     dest: root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 
diff --git a/src/content_sets.yml b/src/content_sets.yml
deleted file mode 100644
index 432c0914..00000000
--- a/src/content_sets.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is a file defining which content sets are needed to update content in 
-# this image. Data provided here helps determine which images are vulnerable to
-# specific CVEs. Generally you should only need to update this file when:
-#    1. You start depending on new product
-#    2. You are preparing new product release and your content sets will change
----
-x86_64:
-- rhel-7-server-rpms
-- rhel-7-server-optional-rpms
-- rhel-server-rhscl-7-rpms

From 89f457b677d2bae66606b085d0c449d14ab74b47 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 10:40:49 +0100
Subject: [PATCH 344/509] Do not exit when login fails, just return failure

---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 7fd1f966..a63b6a5f 100755
--- a/test/run_test
+++ b/test/run_test
@@ -207,7 +207,7 @@ function assert_login_access() {
     fi
   fi
   echo "    $PGUSER($PASS) login assertion failed"
-  exit 1
+  return 1
 }
 
 function assert_local_access() {

From bc7fc44cf58a240a9addfca0200f0b531d308f12 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 12:24:13 +0100
Subject: [PATCH 345/509] Fix url for rhel8 compose

---
 15/Dockerfile.rhel8 | 2 +-
 specs/multispec.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 6b413247..3c7b06bb 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -42,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo
+ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-8-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo
 RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index d28579a0..3ea83687 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -59,7 +59,7 @@ specs:
        redhat_component: "postgresql-{{ spec.short }}-container"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
-       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo"
+       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-8-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo"
        environment_setup: >-4
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4

From 032e2944bffc68df1ff2472f37207077856b3d21 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 13:54:44 +0100
Subject: [PATCH 346/509] Revert "Add devel repo directly to the Dockerfile
 before we can selectively enable where we need"

This reverts commit bc7fc44cf58a240a9addfca0200f0b531d308f12.
This reverts commit 7b8de33b598c79eff484ec668c9e2f35ea26074c.

This is too dangerous, as the devel repo might be taken to downstream by
accident.
---
 10/Dockerfile.rhel7 | 2 ++
 12/Dockerfile.rhel7 | 2 ++
 13/Dockerfile.rhel7 | 2 ++
 15/Dockerfile.rhel8 | 1 -
 15/Dockerfile.rhel9 | 1 -
 specs/multispec.yml | 2 --
 src/Dockerfile      | 2 +-
 7 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
index ec9e5c78..acb94437 100644
--- a/10/Dockerfile.rhel7
+++ b/10/Dockerfile.rhel7
@@ -42,6 +42,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
index 33ab8c44..75e7b688 100644
--- a/12/Dockerfile.rhel7
+++ b/12/Dockerfile.rhel7
@@ -42,6 +42,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
index f9bd6137..93939459 100644
--- a/13/Dockerfile.rhel7
+++ b/13/Dockerfile.rhel7
@@ -42,6 +42,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
+# in base RHEL
 RUN yum install -y yum-utils gettext && \
     prepare-yum-repositories rhel-server-rhscl-7-rpms && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 3c7b06bb..060df710 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -42,7 +42,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-8-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo
 RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 39792894..3233429d 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -42,7 +42,6 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-9-devel.repo
 RUN { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 3ea83687..7a6c59be 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -59,7 +59,6 @@ specs:
        redhat_component: "postgresql-{{ spec.short }}-container"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
-       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-8-devel.repo /etc/yum.repos.d/rolling-rhel-8-devel.repo"
        environment_setup: >-4
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
@@ -74,7 +73,6 @@ specs:
        redhat_component: "postgresql-{{ spec.short }}-container"
        img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
        pkgs: "postgresql-server postgresql-contrib"
-       repo_enable_reason: "ADD http://git.app.eng.bos.redhat.com/git/RH_Software_Collections.git/plain/Containers/osbs-repos-signed-pkgs/rolling-rhel-9-devel.repo /etc/yum.repos.d/rolling-rhel-9-devel.repo"
        environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
        post_install: >-4
diff --git a/src/Dockerfile b/src/Dockerfile
index 272bc7d4..a63d00ea 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -52,7 +52,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-{% if spec.repo_enable_reason and spec.version == "15" %}
+{% if spec.repo_enable_reason %}
 {{ spec.repo_enable_reason }}
 {% endif %}
 RUN {{ spec.environment_setup }}

From 48cdabc7f2d82337be47dc509b59e82f9e1b4d11 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 16:38:51 +0100
Subject: [PATCH 347/509] Make reinstalling tzdata more robust when an update
 is in repo

---
 10/Dockerfile.rhel8 | 2 +-
 12/Dockerfile.rhel8 | 2 +-
 13/Dockerfile.rhel8 | 2 +-
 13/Dockerfile.rhel9 | 2 +-
 15/Dockerfile.rhel8 | 2 +-
 15/Dockerfile.rhel9 | 2 +-
 specs/multispec.yml | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8
index 00e5a917..e188c7e5 100644
--- a/10/Dockerfile.rhel8
+++ b/10/Dockerfile.rhel8
@@ -47,7 +47,7 @@ RUN yum -y module enable postgresql:10 && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index 2ff4eae9..e83fd4fe 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -48,7 +48,7 @@ RUN yum -y module enable postgresql:12 && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index 622f056c..986c1e67 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -48,7 +48,7 @@ RUN yum -y module enable postgresql:13 && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index f448a5dd..50b91331 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -48,7 +48,7 @@ RUN { yum -y module enable postgresql:13 || :; } && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 060df710..b68f9781 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -48,7 +48,7 @@ RUN yum -y module enable postgresql:15 && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 3233429d..51d003e1 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -48,7 +48,7 @@ RUN { yum -y module enable postgresql:15 || :; } && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 7a6c59be..97e82ef2 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -62,7 +62,7 @@ specs:
        environment_setup: >-4
            yum -y module enable postgresql:{{ spec.version }} && \
        post_install: >-4
-           yum -y reinstall tzdata && \
+           (yum -y reinstall tzdata || yum -y update tzdata ) && \
     rhel9:
        distros:
          - rhel-9-x86_64
@@ -76,7 +76,7 @@ specs:
        environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
        post_install: >-4
-           yum -y reinstall tzdata && \
+           (yum -y reinstall tzdata || yum -y update tzdata ) && \
     c9s:
       distros:
         - centos-stream-9-x86_64

From 09b84c7528094bc5368c285d4b91a0f3a9f3dceb Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 14 Feb 2023 16:42:07 +0100
Subject: [PATCH 348/509] Fix link in the main README.md

---
 README.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index d78daa69..c59e1ffc 100644
--- a/README.md
+++ b/README.md
@@ -32,10 +32,10 @@ For more information about concepts used in these container images, see the
 Versions
 ---------------
 PostgreSQL versions currently supported are:
-* [postgresql-10](https://github.com/sclorg/postgresql-container/tree/generated/10)
-* [postgresql-12](https://github.com/sclorg/postgresql-container/tree/generated/12)
-* [postgresql-13](https://github.com/sclorg/postgresql-container/tree/generated/13)
-* [postgresql-15](https://github.com/sclorg/postgresql-container/tree/generated/15)
+* [postgresql-10](https://github.com/sclorg/postgresql-container/tree/master/10)
+* [postgresql-12](https://github.com/sclorg/postgresql-container/tree/master/12)
+* [postgresql-13](https://github.com/sclorg/postgresql-container/tree/master/13)
+* [postgresql-15](https://github.com/sclorg/postgresql-container/tree/master/15)
 
 RHEL versions currently supported are:
 * RHEL7
@@ -99,16 +99,16 @@ Usage
 ---------------------------------
 
 For information about usage of Dockerfile for PostgreSQL 10,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/10).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/10).
 
 For information about usage of Dockerfile for PostgreSQL 12,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/12).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/12).
 
 For information about usage of Dockerfile for PostgreSQL 13,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/13).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/13).
 
 For information about usage of Dockerfile for PostgreSQL 15,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/generated/15).
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/15).
 
 For versions which are not supported anymore:
 

From 23b61de535ce0f2192eb80fd0a91a4fa38185f87 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 17 Feb 2023 12:59:51 +0100
Subject: [PATCH 349/509] Add build-and-push action config to v15

---
 .github/workflows/build-and-push.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 84f11a0a..d1b6d987 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -42,6 +42,13 @@ jobs:
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 13
+          - dockerfile: "15/Dockerfile.c9s"
+            registry_namespace: "sclorg"
+            tag: "c9s"
+            image_name: "postgresql-15-c9s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            docker_context: 15
           - dockerfile: "10/Dockerfile.c8s"
             registry_namespace: "sclorg"
             tag: "c8s"
@@ -56,6 +63,13 @@ jobs:
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             image_name: "postgresql-13-c8s"
             docker_context: 13
+          - dockerfile: "15/Dockerfile.c8s"
+            registry_namespace: "sclorg"
+            tag: "c8s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            image_name: "postgresql-15-c8s"
+            docker_context: 15
           - dockerfile: "12/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "12"

From ed304c3739ff6f26f73c07612f3f21cb7873fe95 Mon Sep 17 00:00:00 2001
From: Robert Aistleitner <r.aistleitner@ubitec.at>
Date: Thu, 13 Oct 2022 12:09:33 +0200
Subject: [PATCH 350/509] Recover database before trying to upgrade to the new
 version using `pg_upgrade`

If the last shutdown of the database was not clean and a recovery
of the database is necessary on startup, the pg_upgrade will fail.

This can be solved by booting up the old (previous) postgres server
and stop it properly before the migration with pg_upgrade is triggered.

https://github.com/sclorg/postgresql-container/issues/469
---
 10/root/usr/share/container-scripts/postgresql/common.sh | 9 +++++++++
 12/root/usr/share/container-scripts/postgresql/common.sh | 9 +++++++++
 13/root/usr/share/container-scripts/postgresql/common.sh | 9 +++++++++
 15/root/usr/share/container-scripts/postgresql/common.sh | 9 +++++++++
 .../usr/share/container-scripts/postgresql/common.sh     | 9 +++++++++
 5 files changed, 45 insertions(+)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 1b339105..60e75a07 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -328,6 +328,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index fda53386..7452d749 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -328,6 +328,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 15c11037..e35c7047 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -328,6 +328,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 1f1a11d7..0bf4e0f1 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -328,6 +328,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index b9ed6770..f27ba668 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -329,6 +329,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"

From a1c5263f64faf4d81aa4ae227caf2ca93868c149 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 17 Feb 2023 13:33:43 +0100
Subject: [PATCH 351/509] Replace uname -i/-p with -m

uname -i functionality is non-portable and the custom patch Fedora was carrying around was recently dropped:

https://src.fedoraproject.org/rpms/coreutils/c/cd953e11dd78cada371f0389171cea671949141b?branch=rawhide

The rhbz#548834 suggests to use uname -m instead.

Also relevant discussion happens at rhbz#2158752
---
 10/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 12/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 13/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 15/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 test/run_test                                             | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 1b339105..b7304695 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -130,7 +130,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index fda53386..fd749f86 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -130,7 +130,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 15c11037..097f1ddd 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -130,7 +130,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 1f1a11d7..ed149b33 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -130,7 +130,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index b9ed6770..cf4da723 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -131,7 +131,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/test/run_test b/test/run_test
index a63b6a5f..9af79c6c 100755
--- a/test/run_test
+++ b/test/run_test
@@ -693,7 +693,7 @@ run_migration_test ()
 
     local from_version
     # Only test a subset of the migration path on non-intel hosts
-    if [ "$(uname -i)" == "x86_64" ]; then
+    if [ "$(uname -m)" == "x86_64" ]; then
         local upgrade_path="9.2 9.4 9.5 9.6 10 12 13 15"
     else
         local upgrade_path="10 12 13 15"

From ebde6630f6ee4fdb9b5a4befd6b83d00eb729bfc Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:20:06 +0100
Subject: [PATCH 352/509] Enable testing PostgreSQL 14 on Fedora host

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 4 ++--
 .github/workflows/openshift-tests.yml | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 8e9bb648..26743ce5 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -55,7 +55,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13", "15" ]
+        version: [ "10", "11", "12", "13", "14", "15" ]
         os_test: [ "fedora", "centos7", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
         include:
           - tmt_plan: "fedora"
@@ -75,7 +75,7 @@ jobs:
           - tmt_plan: "rhel7-docker"
             os_test: "rhel7"
             context: "RHEL7"
-            compose: "RHEL-7.9-Released"
+            compose: "RHEL-7-LatestUpdated"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 0aad827f..73fd9f22 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -48,7 +48,7 @@ jobs:
           - tmt_plan: "rhel7-openshift-3"
             os_test: "rhel7"
             context: "RHEL7 - OpenShift 3"
-            compose: "RHEL-7.9-Released"
+            compose: "RHEL-7-LatestUpdated"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"
             tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
@@ -57,7 +57,7 @@ jobs:
           - tmt_plan: "rhel7-openshift-4"
             os_test: "rhel7"
             context: "RHEL7 - OpenShift 4"
-            compose: "RHEL-7.9-Released"
+            compose: "RHEL-7-LatestUpdated"
             test_name: "test-openshift-4"
             api_key: "TF_INTERNAL_API_KEY"
             branch: "master"

From c4ccba988dde1e53846ff468c61f71a2611a3248 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 23 Feb 2023 11:02:49 +0100
Subject: [PATCH 353/509] Fix typo in GitHub Action for openshift

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/openshift-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 73fd9f22..1fac5c13 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -8,7 +8,7 @@ jobs:
     runs-on: ubuntu-20.04
     if: |
       github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
+      && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - name: Checkout repo

From caabec606700339e197fc1ff7165e7669d472d2e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:16:42 +0100
Subject: [PATCH 354/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 4d21ab6c..c1f46d90 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 4d21ab6c92f5845aaa0c52f30abe4a86ac56c09c
+Subproject commit c1f46d905f42267cbf0c0f6994c0f8e018bec3f8

From 1147b864893b438aa43050851c7d246b20ac858d Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:16:58 +0100
Subject: [PATCH 355/509] Add support for postgresql 14 for Fedora

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile              |  2 +-
 specs/multispec.yml   | 19 +++++++++++++++++++
 src/Dockerfile.fedora |  2 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 71b7f998..eba393f5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 12 13 15
+VERSIONS = 10 12 13 14 15
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 97e82ef2..a62c9c91 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -136,6 +136,17 @@ specs:
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       latest_fedora: "f35"
 
+    "14":
+      version: "14"
+      prev_version: "13"
+      short: "14"
+      prev_short: "13"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
+      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
+      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
+      latest_fedora: "f37"
+
     "15":
       version: "15"
       prev_version: "13"
@@ -157,6 +168,14 @@ matrix:
         - rhel-9-x86_64
         - centos-stream-9-x86_64
       version: "12"
+    - distros:
+        - centos-7-x86_64
+        - rhel-7-x86_64
+        - centos-stream-8-x86_64
+        - rhel-8-x86_64
+        - centos-stream-9-x86_64
+        - rhel-9-x86_64
+      version: "14"
     - distros:
         - rhel-7-x86_64
         - centos-7-x86_64
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 1503425c..f279329c 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,4 @@
-{% if spec.version == "15" %}
+{% if spec.version == "14" or spec.version == "15" %}
 FROM quay.io/fedora/s2i-core:37
 {% else %}
 FROM quay.io/fedora/s2i-core:35

From 5c26b72038e72a16f45f507336692fa9fe34397c Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:21:12 +0100
Subject: [PATCH 356/509] Add support for pushing PostgreSQL 14 to Fedora
 quay.io registry

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index d1b6d987..e5775731 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -84,6 +84,13 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-13"
             docker_context: 13
+          - dockerfile: "14/Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "14"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+            image_name: "postgresql-14"
+            docker_context: 14
           - dockerfile: "15/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "15"

From 1e890371639a1b52f9ca5b94e78bae3d13e6f600 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:36:58 +0100
Subject: [PATCH 357/509] Add dist-gen generated content for version 14

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 14/Dockerfile.fedora                          |  84 +++
 14/README.md                                  |   1 +
 14/root/usr/bin/container-entrypoint          |   3 +
 14/root/usr/bin/run-postgresql                |  58 +++
 14/root/usr/bin/run-postgresql-master         |   5 +
 14/root/usr/bin/run-postgresql-slave          |  39 ++
 14/root/usr/bin/usage                         |   4 +
 14/root/usr/libexec/check-container           |  27 +
 14/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 295 +++++++++++
 .../container-scripts/postgresql/common.sh    | 481 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   8 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 14/s2i/bin/assemble                           |  14 +
 14/s2i/bin/run                                |   1 +
 14/s2i/bin/usage                              |   1 +
 14/test                                       |   1 +
 20 files changed, 1115 insertions(+)
 create mode 100644 14/Dockerfile.fedora
 create mode 120000 14/README.md
 create mode 100755 14/root/usr/bin/container-entrypoint
 create mode 100755 14/root/usr/bin/run-postgresql
 create mode 100755 14/root/usr/bin/run-postgresql-master
 create mode 100755 14/root/usr/bin/run-postgresql-slave
 create mode 100755 14/root/usr/bin/usage
 create mode 100755 14/root/usr/libexec/check-container
 create mode 100755 14/root/usr/libexec/fix-permissions
 create mode 100644 14/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 14/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 14/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 14/s2i/bin/assemble
 create mode 120000 14/s2i/bin/run
 create mode 100755 14/s2i/bin/usage
 create mode 120000 14/test

diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora
new file mode 100644
index 00000000..586b11bf
--- /dev/null
+++ b/14/Dockerfile.fedora
@@ -0,0 +1,84 @@
+FROM quay.io/fedora/s2i-core:37
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=14 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 14" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql14" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="fedora/$NAME-14" \
+      version="0" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-14"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" pgaudit" && \
+    dnf -y module enable postgresql:14 && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/14/README.md b/14/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/14/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/14/root/usr/bin/container-entrypoint b/14/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/14/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/14/root/usr/bin/run-postgresql b/14/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/14/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/14/root/usr/bin/run-postgresql-master b/14/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/14/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/14/root/usr/bin/run-postgresql-slave b/14/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..586bf5d7
--- /dev/null
+++ b/14/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/14/root/usr/bin/usage b/14/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/14/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/14/root/usr/libexec/check-container b/14/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/14/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/14/root/usr/libexec/fix-permissions b/14/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/14/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..0d33bee4
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,295 @@
+PostgreSQL 14 SQL Database Server container image
+===============================================
+
+This container image includes PostgreSQL 14 SQL database server for OpenShift and general usage.
+Users can choose between RHEL, CentOS and Fedora based images.
+The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
+the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
+and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+The resulting image can be run using [podman](https://github.com/containers/libpod).
+
+Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+
+
+Description
+-----------
+
+This container image provides a containerized packaging of the PostgreSQL postgres daemon
+and client application. The postgres server daemon accepts connections from clients
+and provides access to content from PostgreSQL databases on behalf of the clients.
+You can find more information on the PostgreSQL project from the project Web site
+(https://www.postgresql.org/).
+
+
+Usage
+-----
+
+For this, we will assume that you are using the `rhscl/postgresql-14-rhel7` image, available via `postgresql:14` imagestream tag in Openshift.
+If you want to set only the mandatory environment variables and not store the database
+in a host directory, execute the following command:
+
+```
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-14-rhel7
+```
+
+This will create a container named `postgresql_database` running PostgreSQL with
+database `db` and user with credentials `user:pass`. 
+> Note: user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed
+and mapped to the host. If you want your database to be persistent across container
+executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
+below). This will be the PostgreSQL database cluster directory.
+
+The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=14 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory is not initialized, the entrypoint script will
+first run [`initdb`](http://www.postgresql.org/docs/14/static/app-initdb.html)
+and setup necessary database users and passwords. After the database is initialized,
+or if it was already present, [`postgres`](http://www.postgresql.org/docs/14/static/app-postgres.html)
+is executed and will run as PID 1. You can stop the detached container by running
+`podman stop postgresql_database`.
+
+
+
+Environment variables and volumes
+---------------------------------
+
+The image recognizes the following environment variables that you can set during
+initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+       User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+       Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+       Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+       Password for the `postgres` admin account (optional)
+
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+       Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+       Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+       Set to 'yes' to ignore sql import errors
+
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+       The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+       Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+       PostgreSQL database cluster directory
+
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+
+Data migration
+--------------
+
+PostgreSQL container supports migration of data from remote PostgreSQL server.
+You can run it like:
+
+```
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    rhel8/postgresql-13
+```
+
+The migration is done the **dump and restore** way (running `pg_dumpall` against
+remote cluster and importing the dump locally by `psql`).  Because the process
+is streamed (unix pipeline), there are no intermediate dump files created during
+this process to not waste additional storage space.
+
+If some SQL commands fail during applying, the default behavior
+of the migration script is to fail as well to ensure the **all** or **nothing**
+result of scripted, unattended migration. In most common cases, successful
+migration is expected (but not guaranteed!), given you migrate from
+a previous version of PostgreSQL server container, that is created using
+the same principles as this one (e.g. migration from
+`rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different kind of PostgreSQL container can likely fail.
+
+If this **all** or **nothing** principle is inadequate for you, and you know
+what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
+which does **best effort** migration (some data might be lost, it is up to user
+to review the standard error output and fix the issues manually in
+post-migration time).
+
+Please keep in mind that the container image provides help for users'
+convenience, but fully automatic migration is not guaranteed.  Thus, before you
+start proceeding with the database migration, get prepared to perform manual
+steps in order to get all your data migrated.
+
+Note that you might not use variables like `POSTGRESQL_USER` in migration
+scenario, all the data (including info about databases, roles or passwords are
+copied from old cluster).  Ensure that you use the same
+`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
+PostgreSQL container.  If some non-default configuration is done on remote
+cluster, you might need to copy the configuration files manually, too.
+
+Security warning:  Note that the IP communication between old and new PostgreSQL
+clusters is not encrypted by default, it is up to user to configure SSL on
+remote cluster or ensure security via different means.
+
+PostgreSQL auto-tuning
+----------------------
+
+When the PostgreSQL image is run with the `--memory` parameter set and if there
+are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
+based on the value provided in the `--memory` parameter.
+
+The values are calculated based on the
+[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
+formulas. For the `shared_buffers` we use 1/4 of given memory and for the
+`effective_cache_size` we set the value to 1/2 of the given memory.
+
+PostgreSQL admin account
+------------------------
+The admin account `postgres` has no password set by default, only allowing local
+connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
+variable when initializing your container. This will allow you to login to the
+`postgres` account remotely. Local connections will still not require a password.
+
+
+Changing passwords
+------------------
+
+Since passwords are part of the image configuration, the only supported method
+to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
+`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any way other than through
+the environment variables aforementioned will cause a mismatch between the
+values stored in the variables and the actual passwords. Whenever a database
+container starts it will reset the passwords to the values stored in the
+environment variables.
+
+
+
+
+Extending image
+----------------
+
+This image can be extended in Openshift using the `Source` build strategy or via the standalone
+[source-to-image](https://github.com/openshift/source-to-image) application (where available).
+For this, we will assume that you are using the `rhscl/postgresql-14-rhel7` image,
+available via `postgresql:14` imagestream tag in Openshift.
+
+For example to build customized image `new-postgresql`
+with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+
+```
+$ oc new-app postgresql:14~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-14-rhel7 new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the
+following directories:
+
+
+##### `postgresql-pre-start/`
+
+Source all `*.sh` files from this directory during early start of the
+container.  There's no PostgreSQL daemon running on background.
+
+
+##### `postgresql-cfg/`
+
+Contained configuration files (`*.conf`) will be included at the end of image
+postgresql.conf file.
+
+
+##### `postgresql-init/`
+
+Contained shell scripts (`*.sh`) are sourced when the database is freshly
+initialized (after successful initdb run which made the data directory
+non-empty).  At the time of sourcing these scripts, the local PostgreSQL
+server is running.  For re-deployments scenarios with persistent data
+directory, the scripts are not sourced (no-op).
+
+
+##### `postgresql-start/`
+
+Same sematics as `postgresql-init/`, except that these scripts are
+always sourced (after `postgresql-init/` scripts, if they exist).
+
+
+----------------------------------------------
+
+During the s2i build all provided files are copied into `/opt/app-root/src`
+directory in the new image. Only one
+file with the same name can be used for customization and user provided files
+are preferred over default files in `/usr/share/container-scripts/`-
+so it is possible to overwrite them.
+
+
+Troubleshooting
+---------------
+At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
+
+    podman logs <container>
+
+Then log output is redirected to logging collector process and will appear in directory "pg_log".
+
+
+See also
+--------
+Dockerfile and other sources for this container image are available on
+https://github.com/sclorg/postgresql-container.
+In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
+for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
+the Dockerfile for RHEL9 is called Dockerfile.rhel9,
+and the Dockerfile for Fedora is called Dockerfile.fedora.
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..a99ee557
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,481 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -p)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/14/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..d133e511
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..58d8e336
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,8 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/14/root/usr/share/container-scripts/postgresql/scl_enable b/14/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/14/s2i/bin/assemble b/14/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/14/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/14/s2i/bin/run b/14/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/14/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/14/s2i/bin/usage b/14/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/14/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/14/test b/14/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/14/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file

From a7e01e7fc4381101177263319034a6135ae51140 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 22 Feb 2023 12:38:12 +0100
Subject: [PATCH 358/509] Update main README.md file

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 14/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 README.md                                                | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index a99ee557..7261e532 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -130,7 +130,7 @@ version2number ()
 # These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
 # Return value 0 means the hack is needed.
 function should_hack_data_sync_retry() {
-  [ "$(uname -p)" == 'x86_64' ] && return 1
+  [ "$(uname -m)" == 'x86_64' ] && return 1
   local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
   # this matches all 12.x and versions of 10.x where we need the hack
   [ "$version_number" -ge 100700 ] && return 0
diff --git a/README.md b/README.md
index c59e1ffc..e7dc0b27 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ Images available on Quay are:
 * Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
 * Fedora [postgresql-12](https://quay.io/repository/fedora/postgresql-12)
 * Fedora [postgresql-13](https://quay.io/repository/fedora/postgresql-13)
+* Fedora [postgresql-14](https://quay.io/repository/fedora/postgresql-14)
 * Fedora [postgresql-15](https://quay.io/repository/fedora/postgresql-15)
 
 This repository contains Dockerfiles for PostgreSQL images for OpenShift.
@@ -35,6 +36,7 @@ PostgreSQL versions currently supported are:
 * [postgresql-10](https://github.com/sclorg/postgresql-container/tree/master/10)
 * [postgresql-12](https://github.com/sclorg/postgresql-container/tree/master/12)
 * [postgresql-13](https://github.com/sclorg/postgresql-container/tree/master/13)
+* [postgresql-14](https://github.com/sclorg/postgresql-container/tree/master/14)
 * [postgresql-15](https://github.com/sclorg/postgresql-container/tree/master/15)
 
 RHEL versions currently supported are:
@@ -107,6 +109,9 @@ see [usage documentation](https://github.com/sclorg/postgresql-container/tree/ma
 For information about usage of Dockerfile for PostgreSQL 13,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/13).
 
+For information about usage of Dockerfile for PostgreSQL 14,
+see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/14).
+
 For information about usage of Dockerfile for PostgreSQL 15,
 see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/15).
 

From a3402fea7ba159635dca31bb69476cb5bd32df62 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 23 Mar 2020 09:13:10 +0100
Subject: [PATCH 359/509] Allow logging to /dev/stderr

For easier debugging, it should be pretty easy to switch daemon to log into the /dev/stderr.
This adds such a feature by setting POSTGRESQL_LOG_DESTINATION environment variable to /dev/stderr.
Requested at https://github.com/sclorg/postgresql-container/issues/353
---
 .../container-scripts/postgresql/README.md    |  3 ++
 .../container-scripts/postgresql/common.sh    | 12 ++++++
 .../container-scripts/postgresql/README.md    |  3 ++
 .../container-scripts/postgresql/common.sh    | 12 ++++++
 .../container-scripts/postgresql/README.md    |  3 ++
 .../container-scripts/postgresql/common.sh    | 12 ++++++
 .../container-scripts/postgresql/README.md    |  3 ++
 .../container-scripts/postgresql/common.sh    | 12 ++++++
 common                                        |  2 +-
 .../container-scripts/postgresql/README.md    |  3 ++
 .../container-scripts/postgresql/common.sh    | 12 ++++++
 test/run_test                                 | 37 +++++++++++++++++++
 12 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index e46787a7..f1d35905 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index b7304695..a7fd2b17 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -159,6 +161,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 5fdd9437..3cc179e1 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index fd749f86..7c08b2ef 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -159,6 +161,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index fbbc5047..624c4a49 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 097f1ddd..94059325 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -159,6 +161,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index 7a4e4efb..c8490927 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index ed149b33..8a9771ac 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -159,6 +161,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
diff --git a/common b/common
index 4d21ab6c..c1f46d90 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 4d21ab6c92f5845aaa0c52f30abe4a86ac56c09c
+Subproject commit c1f46d905f42267cbf0c0f6994c0f8e018bec3f8
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 4ae6b343..e27f3275 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index cf4da723..69c65a9a 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -160,6 +162,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
diff --git a/test/run_test b/test/run_test
index 9af79c6c..ee31b96e 100755
--- a/test/run_test
+++ b/test/run_test
@@ -29,6 +29,7 @@ run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 run_pgaudit_test
+run_logging_test
 "
 
 test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
@@ -938,6 +939,42 @@ EOSQL" || ret=3
   return $ret
 }
 
+run_logging_test()
+{
+  local data_dir name=pg-test-logging
+
+  # create a dir for data
+  create_volume_dir
+  data_dir="${volume_dir}"
+
+  DOCKER_ARGS="
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-e POSTGRESQL_LOG_DESTINATION=/dev/stderr
+-v ${data_dir}:/var/lib/pgsql/data:Z
+  " create_container "$name"
+
+  assert_runtime_option "$name" log_destination logging_collector log_directory log_filename
+  wait_ready "$name"
+
+  # enable the pgaudit extension
+  echo 'psql -U nonexistent' | docker exec -i $(get_cid "$name") bash || :
+
+  # give server some time for write all audit messages
+  sleep 1
+
+  # check whether we have a correct output in the container log
+  if ! docker logs $(get_cid "$name") 2>&1 | grep -q 'FATAL:  role "nonexistent" does not exist' ; then
+    echo "ERROR: the container log does not include expected error message"
+    return 1
+  fi
+
+  # the traditional log file should not exist
+  while f in "${data_dir}"/userdata/log/postgresql-*.log ] ; do
+    echo "ERROR: the traditional log file $f should not exist"
+    return 1
+  done
+}
+
 # configuration defaults
 POSTGRESQL_MAX_CONNECTIONS=100
 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0

From 7cb1bee3439d01a91d9b3d87b9cc3f9435ed747c Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 1 Mar 2023 10:31:14 +0100
Subject: [PATCH 360/509] Improve the test for logging to stderr

---
 test/run_test | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/test/run_test b/test/run_test
index ee31b96e..30a60445 100755
--- a/test/run_test
+++ b/test/run_test
@@ -956,23 +956,29 @@ run_logging_test()
   assert_runtime_option "$name" log_destination logging_collector log_directory log_filename
   wait_ready "$name"
 
-  # enable the pgaudit extension
+  # try loggin in as a user that does not exist to trigger an error log message
   echo 'psql -U nonexistent' | docker exec -i $(get_cid "$name") bash || :
 
   # give server some time for write all audit messages
   sleep 1
 
   # check whether we have a correct output in the container log
-  if ! docker logs $(get_cid "$name") 2>&1 | grep -q 'FATAL:  role "nonexistent" does not exist' ; then
+  if docker logs $(get_cid "$name") 2>&1 | grep -q 'FATAL:  role "nonexistent" does not exist' ; then
+    echo "    PASS: the container log does include expected error message"
+  else
     echo "ERROR: the container log does not include expected error message"
     return 1
   fi
 
   # the traditional log file should not exist
-  while f in "${data_dir}"/userdata/log/postgresql-*.log ] ; do
-    echo "ERROR: the traditional log file $f should not exist"
-    return 1
+  for f in "${data_dir}"/userdata/log/postgresql-*.log ; do
+    if test -f "$f" ; then
+      echo "ERROR: the traditional log file $f should not exist"
+      return 1
+    fi
   done
+  echo "    PASS: the traditional log file under ${data_dir}/userdata/log/postgresql-*.log does not exist"
+  echo "  Success!"
 }
 
 # configuration defaults

From 1fea00f5dcb864ec8faa6612010970d78a5dc73a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 28 Feb 2023 13:57:23 +0100
Subject: [PATCH 361/509] Fix OpenShift tests. Allow persistent and ephemeral
 template for testing. Check run_latest_imagestreams.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/postgresql-ephemeral-template.json  |  1 +
 test/postgresql-persistent-template.json |  1 +
 test/run-openshift-remote-cluster        |  1 +
 test/test-lib-postgresql.sh              | 35 +++++++++++++++++-------
 4 files changed, 28 insertions(+), 10 deletions(-)
 create mode 120000 test/postgresql-ephemeral-template.json
 create mode 120000 test/postgresql-persistent-template.json

diff --git a/test/postgresql-ephemeral-template.json b/test/postgresql-ephemeral-template.json
new file mode 120000
index 00000000..d37d8892
--- /dev/null
+++ b/test/postgresql-ephemeral-template.json
@@ -0,0 +1 @@
+../examples/postgresql-ephemeral-template.json
\ No newline at end of file
diff --git a/test/postgresql-persistent-template.json b/test/postgresql-persistent-template.json
new file mode 120000
index 00000000..8556e17f
--- /dev/null
+++ b/test/postgresql-persistent-template.json
@@ -0,0 +1 @@
+../examples/postgresql-persistent-template.json
\ No newline at end of file
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 09946f7a..60ebf938 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -16,6 +16,7 @@ source "${THISDIR}/test-lib-remote-openshift.sh"
 TEST_LIST="\
 test_postgresql_integration
 test_postgresql_imagestream
+run_latest_imagestreams_test
 "
 
 trap ct_os_cleanup EXIT SIGINT
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 52e842c6..afbc193f 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -14,16 +14,19 @@ source "${THISDIR}"/test-lib-remote-openshift.sh
 
 function test_postgresql_integration() {
   local service_name=postgresql
-  ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent
-  ct_os_test_template_app_func "${IMAGE_NAME}" \
-                               "${t}" \
-                               "${service_name}" \
-                               "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
-                               "-p POSTGRESQL_VERSION=${VERSION} \
-                                -p DATABASE_SERVICE_NAME="${service_name}-testing" \
-                                -p POSTGRESQL_USER=testu \
-                                -p POSTGRESQL_PASSWORD=testp \
-                                -p POSTGRESQL_DATABASE=testdb"
+  TEMPLATES="postgresql-ephemeral-template.json
+  postgresql-persistent-template.json"
+  for template in $TEMPLATES; do
+    ct_os_test_template_app_func "${IMAGE_NAME}" \
+                                 "${THISDIR}/${template}" \
+                                 "${service_name}" \
+                                 "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
+                                 "-p POSTGRESQL_VERSION=${VERSION} \
+                                  -p DATABASE_SERVICE_NAME="${service_name}-testing" \
+                                  -p POSTGRESQL_USER=testu \
+                                  -p POSTGRESQL_PASSWORD=testp \
+                                  -p POSTGRESQL_DATABASE=testdb"
+  done
 }
 
 # Check the imagestream
@@ -37,4 +40,16 @@ function test_postgresql_imagestream() {
   ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }
 
+
+function run_latest_imagestreams_test() {
+  local result=1
+  # Switch to root directory of a container
+  echo "Testing the latest version in imagestreams"
+  pushd "${THISDIR}/.." >/dev/null || return 1
+  ct_check_latest_imagestreams
+  result=$?
+  popd >/dev/null || return 1
+  return $result
+}
+
 # vim: set tabstop=2:shiftwidth=2:expandtab:

From 2d76a1892135c0a923f4e1c4cca475854bf60782 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 28 Feb 2023 15:21:06 +0100
Subject: [PATCH 362/509] test_postgresql_imagestream for version 15 is not
 supported yet.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index afbc193f..c2fd0dcc 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -37,6 +37,13 @@ function test_postgresql_imagestream() {
   elif [ "${OS}" == "rhel9" ]; then
     tag="-el9"
   fi
+  # TODO
+  # Delete this as soon as postgresql image reached GA
+  if [ "${VERSION}" == "15" ]; then
+    echo "WARNING: Version ${VERSION} does not reach GA."
+    echo "WARNING: Remove this condition as soon as it will be available."
+    return 0
+  fi
   ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }
 

From 29f518a1fe81fd8650b3600c546f6f7f3af91111 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 1 Mar 2023 15:29:54 +0100
Subject: [PATCH 363/509] Call templates from examples directory.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/postgresql-ephemeral-template.json  | 1 -
 test/postgresql-persistent-template.json | 1 -
 test/test-lib-postgresql.sh              | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)
 delete mode 120000 test/postgresql-ephemeral-template.json
 delete mode 120000 test/postgresql-persistent-template.json

diff --git a/test/postgresql-ephemeral-template.json b/test/postgresql-ephemeral-template.json
deleted file mode 120000
index d37d8892..00000000
--- a/test/postgresql-ephemeral-template.json
+++ /dev/null
@@ -1 +0,0 @@
-../examples/postgresql-ephemeral-template.json
\ No newline at end of file
diff --git a/test/postgresql-persistent-template.json b/test/postgresql-persistent-template.json
deleted file mode 120000
index 8556e17f..00000000
--- a/test/postgresql-persistent-template.json
+++ /dev/null
@@ -1 +0,0 @@
-../examples/postgresql-persistent-template.json
\ No newline at end of file
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index c2fd0dcc..de943a0b 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -18,7 +18,7 @@ function test_postgresql_integration() {
   postgresql-persistent-template.json"
   for template in $TEMPLATES; do
     ct_os_test_template_app_func "${IMAGE_NAME}" \
-                                 "${THISDIR}/${template}" \
+                                 "${THISDIR}/examples/${template}" \
                                  "${service_name}" \
                                  "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
                                  "-p POSTGRESQL_VERSION=${VERSION} \

From ef2bd86540fe8fadfc596cc66cf1ebc92f3f2a26 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Tue, 7 Mar 2023 16:36:33 +0100
Subject: [PATCH 364/509] tests: use the tfaga wrapper in the testing actions

---
 .github/workflows/container-tests.yml | 97 +++------------------------
 .github/workflows/openshift-tests.yml | 89 ++++--------------------
 2 files changed, 20 insertions(+), 166 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 26743ce5..66bd5d32 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -49,105 +49,24 @@ jobs:
           fi
   container-tests:
     needs: distgen-check
-    # This job only runs for '[test]' pull request comments by owner, member
     runs-on: ubuntu-20.04
-    name: "Container tests: ${{ matrix.version }} - ${{ matrix.context }}"
+    name: "Container tests: ${{ matrix.version }} - ${{ matrix.os_test }}"
     strategy:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "14", "15" ]
         os_test: [ "fedora", "centos7", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
-        include:
-          - tmt_plan: "fedora"
-            os_test: "fedora"
-            context: "Fedora"
-            compose: "Fedora-latest"
-            api_key: "TF_PUBLIC_API_KEY"
-            branch: "main"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
-          - tmt_plan: "centos7"
-            os_test: "centos7"
-            context: "CentOS7"
-            compose: "CentOS-7"
-            api_key: "TF_PUBLIC_API_KEY"
-            branch: "main"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
-          - tmt_plan: "rhel7-docker"
-            os_test: "rhel7"
-            context: "RHEL7"
-            compose: "RHEL-7-LatestUpdated"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
-          - tmt_plan: "rhel8-docker"
-            os_test: "rhel8"
-            context: "RHEL8"
-            compose: "RHEL-8.6.0-Nightly"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
-          - tmt_plan: "rhel9-docker"
-            os_test: "rhel9"
-            context: "RHEL9"
-            compose: "RHEL-9.1.0-Nightly"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
-          - tmt_plan: "c9s"
-            os_test: "c9s"
-            context: "CentOS Stream 9"
-            compose: "CentOS-Stream-9"
-            api_key: "TF_PUBLIC_API_KEY"
-            branch: "main"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
-          - tmt_plan: "c8s"
-            os_test: "c8s"
-            context: "CentOS Stream 8"
-            compose: "CentOS-Stream-8"
-            api_key: "TF_PUBLIC_API_KEY"
-            branch: "main"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
+        test_case: [ "container" ]
 
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ github.event.issue.number }}/head"
-
-      - name: Prepare needed variables
-        shell: bash
-        id: vars
-        run: |
-          dockerfile="Dockerfile.${{ matrix.os_test }}"
-          if [[ ${{ matrix.os_test }} == "centos7" ]]; then
-            dockerfile="Dockerfile"
-          fi
-          echo "::set-output name=DOCKERFILE_NAME::${dockerfile}"
-
-      - name: Check that ${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }} is present
-        id: check_dockerfile
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
-
-      # https://github.com/sclorg/testing-farm-as-github-action
-      - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
-        id: github_action
-        if: steps.check_dockerfile.outputs.files_exists == 'true'
-        uses: sclorg/testing-farm-as-github-action@v1
+      - uses: sclorg/tfaga-wrapper@main
         with:
-          api_key: ${{ secrets[matrix.api_key] }}
-          git_url: ${{ matrix.tmt_repo }}
-          git_ref: ${{ matrix.branch }}
-          tf_scope: ${{ matrix.tf_scope }}
-          tmt_plan_regex: ${{ matrix.tmt_plan }}
-          pull_request_status_name: "${{ matrix.context }} - ${{ matrix.version }}"
-          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};SINGLE_VERSION=${{ matrix.version }};OS=${{ matrix.os_test }};TEST_NAME=test"
-          compose: ${{ matrix.compose }}
+          os_test: ${{ matrix.os_test }}
+          version: ${{ matrix.version }}
+          test_case: ${{ matrix.test_case }}
+          public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }}
+          private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }}
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 1fac5c13..c3ec4082 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -29,96 +29,31 @@ jobs:
   openshift-tests:
     needs: distgen-check
     # This job only runs for '[test-all]' or '[test-openshift] pull request comments by owner, member
-    name: "OpenShift tests: ${{ matrix.version }} - ${{ matrix.context }}"
+    name: "${{ matrix.test_case }} tests: ${{ matrix.version }} - ${{ matrix.os_test }}"
     runs-on: ubuntu-20.04
     strategy:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "15" ]
         os_test: [ "centos7", "rhel7", "rhel8", "rhel9"]
-        include:
-          - tmt_plan: "centos7"
+        test_case: [ "openshift-3", "openshift-4" ]
+        exclude:
+          - test_case: "openshift-4"
             os_test: "centos7"
-            context: "CentOS7 - OpenShift 3"
-            api_key: "TF_PUBLIC_API_KEY"
-            branch: "main"
-            tmt_repo: "https://github.com/sclorg/sclorg-testing-farm"
-            compose: "CentOS-7"
-            test_name: "test-openshift"
-          - tmt_plan: "rhel7-openshift-3"
-            os_test: "rhel7"
-            context: "RHEL7 - OpenShift 3"
-            compose: "RHEL-7-LatestUpdated"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            test_name: "test-openshift"
-            tf_scope: "private"
-          - tmt_plan: "rhel7-openshift-4"
-            os_test: "rhel7"
-            context: "RHEL7 - OpenShift 4"
-            compose: "RHEL-7-LatestUpdated"
-            test_name: "test-openshift-4"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
-          - tmt_plan: "rhel8-openshift-4"
+          - test_case: "openshift-3"
             os_test: "rhel8"
-            context: "RHEL8 - OpenShift 4"
-            compose: "RHEL-8.6.0-Nightly"
-            test_name: "test-openshift-4"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
-          - tmt_plan: "rhel9-openshift-4"
+          - test_case: "openshift-3"
             os_test: "rhel9"
-            context: "RHEL9 - OpenShift 4"
-            compose: "RHEL-9.1.0-Nightly"
-            test_name: "test-openshift-4"
-            api_key: "TF_INTERNAL_API_KEY"
-            branch: "master"
-            tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
-            tf_scope: "private"
 
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
-      - name: Checkout repo
-        uses: actions/checkout@v2
-        with:
-          ref: "refs/pull/${{ github.event.issue.number }}/head"
-
-      - name: Prepare needed variables
-        shell: bash
-        id: vars
-        run: |
-          dockerfile="Dockerfile.${{ matrix.os_test }}"
-          if [[ ${{ matrix.os_test }} == "centos7" ]]; then
-            dockerfile="Dockerfile"
-          fi
-          echo "::set-output name=DOCKERFILE_NAME::${dockerfile}"
-
-      - name: Check that ${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }} is present
-        id: check_dockerfile
-        uses: andstor/file-existence-action@v1
-        with:
-          files: "${{ matrix.version }}/${{ steps.vars.outputs.DOCKERFILE_NAME }}"
-
-      # https://github.com/sclorg/testing-farm-as-github-action
-      - name: Schedule tests for ${{ matrix.version }} - ${{ matrix.context }}
-        id: github_action
-        if: steps.check_dockerfile.outputs.files_exists == 'true'
-        uses: sclorg/testing-farm-as-github-action@v1
+      - uses: sclorg/tfaga-wrapper@main
         with:
-          api_key: ${{ secrets[matrix.api_key] }}
-          git_url: ${{ matrix.tmt_repo }}
-          git_ref: ${{ matrix.branch }}
-          tf_scope: ${{ matrix.tf_scope }}
-          tmt_plan_regex: ${{ matrix.tmt_plan }}
-          pull_request_status_name: "${{ matrix.context }} - ${{ matrix.version }}"
-          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};SINGLE_VERSION=${{ matrix.version }};OS=${{ matrix.os_test }};TEST_NAME=${{ matrix.test_name }}"
-          compose: ${{ matrix.compose }}
+          os_test: ${{ matrix.os_test }}
+          version: ${{ matrix.version }}
+          test_case: ${{ matrix.test_case }}
+          public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }}
+          private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }}

From f87950292eeddc83665c2b3c8b36009443492ae7 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Tue, 7 Mar 2023 16:37:12 +0100
Subject: [PATCH 365/509] tests: use better error logging in container tests
 action

---
 .github/workflows/container-tests.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 66bd5d32..0100e89f 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -41,10 +41,10 @@ jobs:
         run: |
           _result=${{ steps.check.outputs.result }}
           if [ "$_result" == failure ]; then
-            echo "Distgen-generated files are not regenerated properly."
-            echo "Please regenerate them with:"
-            echo "'make clean-versions'"
-            echo "'make generate-all'"
+            echo "::error::Distgen-generated files are not regenerated properly."
+            echo "::warning::Please regenerate them with:"
+            echo "::warning::'make clean-versions'"
+            echo "::warning::'make generate-all'"
             exit 1
           fi
   container-tests:

From ca79f4de4583e582098097dc40a6a6cdc8af3004 Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 8 Mar 2023 11:55:27 +0100
Subject: [PATCH 366/509] fix wrong nss_wrapper behavior when used with
 --userns=keep-id

Fixes: #339
---
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index cf4da723..4c1fcdd0 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -178,7 +178,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd

From baea0ee0e3ca22234bb6148dddd9d354ed9cf34f Mon Sep 17 00:00:00 2001
From: Petr Kubat <pkubat@redhat.com>
Date: Wed, 8 Mar 2023 11:56:30 +0100
Subject: [PATCH 367/509] generate sources

---
 10/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 12/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 13/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 15/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index b7304695..b0b63877 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index fd749f86..5001db01 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 097f1ddd..7f1f335f 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index ed149b33..ec322369 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd

From 5a59537bf9d2ec53e9f34dfa78b59f253b7c0fb3 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 31 Mar 2023 13:20:08 +0200
Subject: [PATCH 368/509] Add support for building and pushin to quay.io
 version 12

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index e5775731..6c397c97 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -56,6 +56,13 @@ jobs:
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             image_name: "postgresql-10-c8s"
             docker_context: 10
+          - dockerfile: "12/Dockerfile.c8s"
+            registry_namespace: "sclorg"
+            tag: "c8s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            image_name: "postgresql-12-c8s"
+            docker_context: 12
           - dockerfile: "13/Dockerfile.c8s"
             registry_namespace: "sclorg"
             tag: "c8s"

From 5d487183e740def6ec47b96291e1b435c4963d4b Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 3 Apr 2023 12:02:01 +0200
Subject: [PATCH 369/509] regenerate sources also for pg 14

---
 .../container-scripts/postgresql/README.md    |  3 +++
 .../container-scripts/postgresql/common.sh    | 23 ++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
index 0d33bee4..a7f90a55 100644
--- a/14/root/usr/share/container-scripts/postgresql/README.md
+++ b/14/root/usr/share/container-scripts/postgresql/README.md
@@ -101,6 +101,9 @@ The following environment variables influence the PostgreSQL configuration file.
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
        Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 7261e532..97508b19 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -18,6 +18,8 @@ else
     export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
 fi
 
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
 export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
 export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
 
@@ -159,6 +161,16 @@ function generate_postgresql_config() {
     echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -177,7 +189,7 @@ function generate_postgresql_recovery_config() {
 function generate_passwd_file() {
   export USER_ID=$(id -u)
   export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID /etc/passwd > "$HOME/passwd"
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
   echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
   export LD_PRELOAD=libnss_wrapper.so
   export NSS_WRAPPER_PASSWD=${HOME}/passwd
@@ -328,6 +340,15 @@ run_pgupgrade ()
       ;;
   esac
 
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
   # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
   # there's some problem.
   test ! -e "$PGDATA_new"

From 415e87a14322157dfa4fb6abb709ad2a23a16bd1 Mon Sep 17 00:00:00 2001
From: Igor Brandao <ibrandao@redhat.com>
Date: Fri, 31 Mar 2023 10:25:21 -0300
Subject: [PATCH 370/509] Adding improvements and README to the enable-ssl
 example

+ Allows user to mount their keys in a single directory without having
to mount secrets on top configurations file in `/opt/app-root/src`
e.g:
```bash
oc set volume --add --type=secret --secret-name mysecret \
--mount-path /opt/app-root/src/tls --default-mode 0640 dc/myapp
```

Removing `chmod` command from the pre-start script

+ Certs are better to be mounted in OpenShift with the proper
permissions already set from the `pod.spec.volumes.secret.defaultMode`
+ This also can cause fail when using the deployment with regular user
in OpenShift. e.g:
```
=> sourcing /opt/app-root/src/postgresql-pre-start/enable_ssl.sh ...
chmod: changing permissions of 'server.key': Operation not permitted
```

Moving example cert and key to the certs dir

Fixing pipeline fail when trying to adjust permissions

+ This fixes the pipeline test fixing the TLS key permission to make
postgres happy

Fixing the pipeline fail and improving README examples

+ Fixed the `run_s2i_enable_ssl_test` by adding back the `chmod` command
+ Improved README by adding examples on how to use in `anyuid` mode or
in the `restricted` scc mode.
---
 examples/enable-ssl/README.md                 | 51 +++++++++++++++++++
 .../enable-ssl/{server.crt => certs/tls.crt}  |  0
 .../enable-ssl/{server.key => certs/tls.key}  |  0
 examples/enable-ssl/postgresql-cfg/ssl.conf   |  4 +-
 .../postgresql-pre-start/enable_ssl.sh        |  4 +-
 5 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 examples/enable-ssl/README.md
 rename examples/enable-ssl/{server.crt => certs/tls.crt} (100%)
 rename examples/enable-ssl/{server.key => certs/tls.key} (100%)

diff --git a/examples/enable-ssl/README.md b/examples/enable-ssl/README.md
new file mode 100644
index 00000000..135ed97d
--- /dev/null
+++ b/examples/enable-ssl/README.md
@@ -0,0 +1,51 @@
+#### enable-ssl
+
+This example demonstrates how to extend the postgresql container by enabling SSL/TLS.  
+
+The following instructions assumes the use of OpenShift.  
+
+1. Deploy postgres:  
+```bash
+oc new-app --name psql-ssl postgresql:13-el7~https://github.com/sclorg/postgresql-container.git \
+  --context-dir examples/enable-ssl \
+  -e POSTGRESQL_USER=myUser \
+  -e POSTGRESQL_PASSWORD=myPassword \
+  -e POSTGRESQL_DATABASE=myDB
+```
+
+2. Create your secrets:  
+```bash
+openssl genrsa -out tls.key 2048
+openssl req -new -x509 -key tls.key -out tls.cert
+oc create secret tls db-ssl-keys --key tls.key --cert tls.cert
+```
+
+3. Bind your secrets into postgres deploymentConfig:  
+```bash
+oc set volume --add \
+    --type=secret \
+    --secret-name=db-ssl-keys \
+    --default-mode=0640 \
+    --mount-path=/opt/app-root/src/certs/ \
+    dc/psql-ssl
+```
+
+By default the `postgresql-pre-start/enable_ssl.sh` needs a service account with `anyuid` SCC.  
+To use in the default `restriced` mode jump to step `5.`  
+_The step 4. example must be executed by a cluster-admin role._  
+  
+4. Create the service account and attach to the deploymentConfig:  
+```bash
+oc create sa psql-ssl-sa
+oc adm policy add-scc-to-user anyuid -z psql-ssl-sa
+oc set sa dc/psql-ssl psql-ssl-sa
+```
+  
+5. Overwriting the `pre-start` scripts enabling the execution with `restricted` SCC mode:  
+```bash
+oc create secret generic psql-custom-prestart --from-literal empty="overwriting-prestart"
+oc set volume dc/psql-ssl --add \
+  --type secret \
+  --secret-name psql-custom-prestart \
+  --mount-path /opt/app-root/src/postgresql-pre-start/
+```
diff --git a/examples/enable-ssl/server.crt b/examples/enable-ssl/certs/tls.crt
similarity index 100%
rename from examples/enable-ssl/server.crt
rename to examples/enable-ssl/certs/tls.crt
diff --git a/examples/enable-ssl/server.key b/examples/enable-ssl/certs/tls.key
similarity index 100%
rename from examples/enable-ssl/server.key
rename to examples/enable-ssl/certs/tls.key
diff --git a/examples/enable-ssl/postgresql-cfg/ssl.conf b/examples/enable-ssl/postgresql-cfg/ssl.conf
index 7237ac05..d34917d1 100644
--- a/examples/enable-ssl/postgresql-cfg/ssl.conf
+++ b/examples/enable-ssl/postgresql-cfg/ssl.conf
@@ -1,5 +1,5 @@
 ssl = on
-ssl_cert_file = '/opt/app-root/src/server.crt' # server certificate
-ssl_key_file =  '/opt/app-root/src/server.key' # server private key
+ssl_cert_file = '/opt/app-root/src/certs/tls.crt' # server certificate
+ssl_key_file =  '/opt/app-root/src/certs/tls.key' # server private key
 #ssl_ca_file                                   # trusted certificate authorities
 #ssl_crl_file                                  # certificates revoked by certificate authorities
diff --git a/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh b/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
index 68369121..00743098 100644
--- a/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
+++ b/examples/enable-ssl/postgresql-pre-start/enable_ssl.sh
@@ -1,4 +1,6 @@
 #!/bin/bash
 
 # Postgresql server will reject key files with liberal permissions
-chmod og-rwx server.key
+# This might fail in OpenShift when using a restricted SCC
+# Make sure to run this deployment with an OpenShift service account using  the anyuid SCC
+chmod og-rwx certs/tls.key

From be628e516f152b6875a3b345036e14e2cff563b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sloup?= <osloup@redhat.com>
Date: Mon, 10 Apr 2023 11:37:49 +0200
Subject: [PATCH 371/509] feat: Remove unused upgrade test from Makefile Remove
 the upgrade-tests option from Makefile. This test was used for the upgrade
 path from RHEL7 to RHEL8 but was not hooked in CI. Today we use a newer
 version of the test in the common repository, and it is unnecessary to have
 it here. This option does not work anyway since the run_upgrade_test was
 significantly changed, and this option was probably forgotten in the
 Makefile.

---
 Makefile | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/Makefile b/Makefile
index eba393f5..6cd33a76 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,3 @@ include common/common.mk
 clean-hook: clean-versions
 
 script_env += NOT_RELEASED_VERSIONS="$(NOT_RELEASED_VERSIONS)"
-
-# Additional upgrade tests.  Not hooked into CI ATM.
-upgrade-tests: $(VERSIONS)
-	OS=$(OS) test/run_upgrade_test 9.2:remote 9.4:local 9.5:local 9.6:local 10:local

From dc8dc7a27a1fdeb27e1d93f5219fed1e3f4dc245 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sloup?= <osloup@redhat.com>
Date: Mon, 10 Apr 2023 11:38:24 +0200
Subject: [PATCH 372/509] docs: Update documentation and add contribution
 process Update all markdown files to new syntax Add reference to SSL/TLS docs

---
 README.md                                     | 227 ++++++-------
 .../container-scripts/postgresql/README.md    | 313 ++++++------------
 2 files changed, 212 insertions(+), 328 deletions(-)

diff --git a/README.md b/README.md
index e7dc0b27..d46ec964 100644
--- a/README.md
+++ b/README.md
@@ -1,154 +1,157 @@
-PostgreSQL container images
-========================
+# PostgreSQL Container Images
 
 [![Build and push images to Quay.io registry](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml/badge.svg)](https://github.com/sclorg/postgresql-container/actions/workflows/build-and-push.yml)
 
-Images available on Quay are:
-* CentOS 7 [postgresql-10](https://quay.io/repository/centos7/postgresql-10-centos7)
-* CentOS 7 [postgresql-12](https://quay.io/repository/centos7/postgresql-12-centos7)
-* CentOS 7 [postgresql-13](https://quay.io/repository/centos7/postgresql-13-centos7)
-* CentOS Stream 8 [postgresql-10](https://quay.io/repository/sclorg/postgresql-10-c8s)
-* CentOS Stream 8 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c8s)
-* CentOS Stream 8 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c8s)
-* CentOS Stream 9 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c9s)
-* CentOS Stream 9 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c9s)
-* Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
-* Fedora [postgresql-12](https://quay.io/repository/fedora/postgresql-12)
-* Fedora [postgresql-13](https://quay.io/repository/fedora/postgresql-13)
-* Fedora [postgresql-14](https://quay.io/repository/fedora/postgresql-14)
-* Fedora [postgresql-15](https://quay.io/repository/fedora/postgresql-15)
-
-This repository contains Dockerfiles for PostgreSQL images for OpenShift.
-Users can choose between RHEL, Fedora and CentOS based images.
-
-For more information about using these images with OpenShift, please see the
-official [OpenShift Documentation](https://docs.okd.io/latest/openshift_images/using-templates.html).
-
-For more information about contributing, see
-[the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).
-For more information about concepts used in these container images, see the
-[Landing page](https://github.com/sclorg/welcome).
-
-
-Versions
----------------
+Images available on Quay.io are:
+
+- CentOS 7 [postgresql-10](https://quay.io/repository/centos7/postgresql-10-centos7)
+- CentOS 7 [postgresql-12](https://quay.io/repository/centos7/postgresql-12-centos7)
+- CentOS 7 [postgresql-13](https://quay.io/repository/centos7/postgresql-13-centos7)
+- CentOS Stream 8 [postgresql-10](https://quay.io/repository/sclorg/postgresql-10-c8s)
+- CentOS Stream 8 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c8s)
+- CentOS Stream 8 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c8s)
+- CentOS Stream 9 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c9s)
+- CentOS Stream 9 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c9s)
+- Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
+- Fedora [postgresql-12](https://quay.io/repository/fedora/postgresql-12)
+- Fedora [postgresql-13](https://quay.io/repository/fedora/postgresql-13)
+- Fedora [postgresql-14](https://quay.io/repository/fedora/postgresql-14)
+- Fedora [postgresql-15](https://quay.io/repository/fedora/postgresql-15)
+
+This repository provides Dockerfiles for PostgreSQL container images, optimized for use with OpenShift. These images are available in RHEL, Fedora, and CentOS-based variants.
+
+For more information about using these images with OpenShift, please refer to the official [OpenShift Documentation](https://docs.okd.io/latest/openshift_images/using-templates.html).
+
+To contribute to this project, please review [the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md).
+For learning more information about concepts used in these container images, see the [Landing page](https://github.com/sclorg/welcome).
+
+## Versions
+
 PostgreSQL versions currently supported are:
-* [postgresql-10](https://github.com/sclorg/postgresql-container/tree/master/10)
-* [postgresql-12](https://github.com/sclorg/postgresql-container/tree/master/12)
-* [postgresql-13](https://github.com/sclorg/postgresql-container/tree/master/13)
-* [postgresql-14](https://github.com/sclorg/postgresql-container/tree/master/14)
-* [postgresql-15](https://github.com/sclorg/postgresql-container/tree/master/15)
+
+- [postgresql-10](https://github.com/sclorg/postgresql-container/tree/master/10)
+- [postgresql-12](https://github.com/sclorg/postgresql-container/tree/master/12)
+- [postgresql-13](https://github.com/sclorg/postgresql-container/tree/master/13)
+- [postgresql-14](https://github.com/sclorg/postgresql-container/tree/master/14)
+- [postgresql-15](https://github.com/sclorg/postgresql-container/tree/master/15)
 
 RHEL versions currently supported are:
-* RHEL7
-* RHEL8
-* RHEL9
+
+- RHEL7
+- RHEL8
+- RHEL9
 
 CentOS versions currently supported are:
-* CentOS7
-* CentOS Stream 8
-* CentOS Stream 9
 
+- CentOS7
+- CentOS Stream 8
+- CentOS Stream 9
+
+## Installation
+
+Choose either the CentOS Stream 9 or RHEL9-based image:
+
+- **RHEL9 based image**
+
+  These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhel9/postgresql-13).
+  To download the image, execute the following command:
 
-Installation
-----------------------
-Choose either the CentOS Stream 9 or RHEL9 based image:
+  ```bash
+  podman pull registry.redhat.io/rhel9/postgresql-13
+  ```
 
-*  **RHEL9 based image**
+  To build a RHEL9-based image, ensure you run Docker build on a RHEL machine with a valid subscription.
 
-    These images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhel9/postgresql-13).
-    To download it run:
-    ```
-    podman pull registry.redhat.io/rhel9/postgresql-13
-    ```
+  ```bash
+  $ git clone --recursive https://github.com/sclorg/postgresql-container.git
+  $ cd postgresql
+  $ make build TARGET=rhel9 VERSIONS=13
+  ```
 
-    To build a RHEL9 based image, you need to run Docker build on a properly
-    subscribed RHEL machine.
+- **CentOS Stream 9 based image**
 
-    ```
-    $ git clone --recursive https://github.com/sclorg/postgresql-container.git
-    $ cd postgresql
-    $ make build TARGET=rhel9 VERSIONS=13
-    ```
+  These images are available on Quay.io. To download the image, execute the following command:
 
-*  **CentOS Stream 9 based image**
+  ```bash
+  $ podman pull https://quay.io/repository/sclorg/postgresql-13-c9s
+  ```
 
-    These images are available on Quay.io. To download it run:
+  To build a PostgreSQL image from scratch, perform the following steps:
 
-    ```
-    $ podman pull https://quay.io/repository/sclorg/postgresql-13-c9s
-    ```
+  ```bash
+  $ git clone --recursive https://github.com/sclorg/postgresql-container.git
+  $ cd postgresql
+  $ make build TARGET=c9s VERSIONS=13
+  ```
 
-    To build a PostgreSQL image from scratch run:
+Note: While the installation steps utilize `podman`, you can substitute these calls with `docker` with the same arguments.
 
-    ```
-    $ git clone --recursive https://github.com/sclorg/postgresql-container.git
-    $ cd postgresql
-    $ make build TARGET=c9s VERSIONS=13
-    ```
+**Warning: By omitting the `VERSIONS` parameter, the build/test action will be executed on all provided versions of PostgreSQL.**
 
-Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments.
+## Contributing Guidelines
 
-**Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
-on all provided versions of PostgreSQL.**
+This repository utilizes [distgen](https://github.com/devexp-db/distgen/) for generating image source files. If you are interested in updating a Dockerfile, please modify the relevant sections in the `specs/multispec.yml` file and/or the `Dockerfile.template` (or other distgen files), and then execute `make generate`.
 
-Contributing
---------------------------------
+Before you begin, ensure that you have `distgen` installed by running `dg --version`. If `distgen` is not installed on your system, follow the installation guide available at [distgen's GitHub repository](https://github.com/devexp-db/distgen/).
+Additionally, for testing purposes, install `go-md2man` from this repository [go-md2man](https://github.com/cpuguy83/go-md2man) or via `dnf install go-md2man`.
 
-In this repository [distgen](https://github.com/devexp-db/distgen/) is used for generating image source files. If you'd like update a Dockerfile, please make changes in specs/multispec.yml and/or Dockerfile.template (or other distgen file) and run `make generate`.
+To contribute, please follow these steps:
 
-Usage
----------------------------------
+1. Fork the repository
+2. Run `git submodule update --init` to download the `common` submodule containing the `common/common.mk` makefile.
+3. Implement a new feature or bug fix in the templates (found in the `src` directory) or update values in the `specs/multispec.yml` file.
+   - Note: If no changes are made to these directories, file regeneration is not necessary.
+4. Regenerate all files by executing `make generate`.
+5. Consider running CI tests, as described in the Test section below.
+6. Commit the files and generated files in two separated commits with a conventional commit message for each.
+7. Open a pull request for review!
 
-For information about usage of Dockerfile for PostgreSQL 10,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/10).
+## Usage
 
-For information about usage of Dockerfile for PostgreSQL 12,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/12).
+For detailed information on the usage of specific PostgreSQL Dockerfiles, please refer to the corresponding usage documentation:
 
-For information about usage of Dockerfile for PostgreSQL 13,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/13).
+- [PostgreSQL 10 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/10)
+- [PostgreSQL 12 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/12)
+- [PostgreSQL 13 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/13)
+- [PostgreSQL 14 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/14)
+- [PostgreSQL 15 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/15)
 
-For information about usage of Dockerfile for PostgreSQL 14,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/14).
+For unsupported versions, you may refer to:
 
-For information about usage of Dockerfile for PostgreSQL 15,
-see [usage documentation](https://github.com/sclorg/postgresql-container/tree/master/15).
+- [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
+- [PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4)
 
-For versions which are not supported anymore:
+## Test
 
-* [PostgreSQL 9.2](https://github.com/sclorg/postgresql-container/blob/f213e5d0/9.2)
-* [PostgreSQL 9.4](https://github.com/sclorg/postgresql-container/blob/2ab68e86/9.4)
+This repository includes a testing framework that verifies the basic functionality of the PostgreSQL image. Users can choose to test the image based on RHEL or CentOS Stream.
 
-Test
----------------------------------
+- **RHEL-based image**
 
-This repository also provides a test framework, which checks basic functionality
-of the PostgreSQL image.
+  To test a RHEL9-based PostgreSQL image, ensure you are running the test on a properly subscribed RHEL machine.
 
-Users can choose between testing PostgreSQL based on a RHEL or CentOS Stream image.
+  ```bash
+  $ cd postgresql
+  $ make test TARGET=rhel9 VERSIONS=13
+  ```
 
-*  **RHEL based image**
+- **CentOS Stream-based image**
 
-    To test a RHEL9 based PostgreSQL image, you need to run the test on a properly
-    subscribed RHEL machine.
+  ```bash
+  $ cd postgresql
+  $ make test TARGET=c9s VERSIONS=13
+  ```
 
-    ```
-    $ cd postgresql
-    $ make test TARGET=rhel9 VERSIONS=13
-    ```
+- To run a specific subset of test cases, use the `TESTS` parameter:
 
-*  **CentOS Stream based image**
+  ```bash
+  $ cd postgresql
+  $ make test VERSIONS=13 TESTS="run_general_tests run_replication_test"
+  ```
 
-    ```
-    $ cd postgresql
-    $ make test TARGET=c9s VERSIONS=13
-    ```
-+By using the `TESTS` parameter you can choose a test case subset to be run against the image, eg:
+**Note: By omitting the `VERSIONS` parameter, the build/test action will be performed on all provided versions of PostgreSQL.**
 
-    $ cd postgresql
-    $ make test VERSIONS=13 TESTS="run_general_tests run_replication_test"
+The test command is utilized from the `common` submodule. While it is possible to run `make test-openshift-4`, it is typically not necessary. All commands for the Makefile can be found in `common/Makefile`. The `make test` command will execute all tests required by the CI.
 
+## Enabling SSL/TLS for PostgreSQL container
 
-**Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed
-on all provided versions of PostgreSQL.**
+For comprehensive information and instructions on enabling SSL/TLS, please refer to the `examples/enable-ssl/README.md`.
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index e27f3275..e5fdbac7 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL {{ spec.version }} SQL Database Server container image
-===============================================
+# PostgreSQL {{ spec.version }} SQL Database Server Container Image
 
-This container image includes PostgreSQL {{ spec.version }} SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL {{ spec.version }} SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `{{ spec.rhel_image_name }}` image, which is accessible via the `postgresql:{{ spec.version }}` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image, available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 {{ spec.rhel_image_name }}
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION={{ spec.version }} -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/{{ spec.version }}/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
-
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,130 +104,67 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
-
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
-
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
-
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
-
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
-
-PostgreSQL auto-tuning
-----------------------
-
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
-
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
-
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
-
-
-Changing passwords
-------------------
-
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
+
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
+
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
+
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
+
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
+
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
+
+## PostgreSQL Auto-Tuning
 
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
+
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
+
+## PostgreSQL Admin Account
+
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
+
+## Changing Passwords
+
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
 Upgrading database (by switching to newer PostgreSQL image version)
--------------------------------------------------------------------
-
-** Warning! Please, before you decide to do the data directory upgrade, always
-ensure that you've carefully backed up all your data and that you are OK with
-potential manual rollback! **
-
-This image supports automatic upgrade of data directory created by
-the PostgreSQL server version {{ spec.prev_version }} (and _only_ this version) - provided by sclorg
-image.  The upgrade process is designed so that you should be able to just
-switch from *image A* to *image B*, and set the `$POSTGRESQL_UPGRADE` variable
-appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via `pg_upgrade` binary, and for
-that purpose the container needs to contain two versions of PostgreSQL server
-(have a look at `man pg_upgrade` for more info).
-
-For the `pg_upgrade` process - and the new server version, we need to initialize
-a brand new data directory.  That's data directory is created automatically by
-container tooling under /var/lib/pgsql/data, which is usually external
-bind-mountpoint.  The `pg_upgrade` execution is then similar to dump&restore
-approach -- it starts both old and new PostgreSQL servers (within container) and
-"dumps" the old datadir while and at the same time it "restores" it into new
-datadir.  This operation requires a lot of data files copying, so you can decide
-what type of upgrade you'll do by setting `$POSTGRESQL_UPGRADE` appropriately:
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+
+This image supports automatic upgrade of data directories created by the PostgreSQL server version {{ spec.prev_version }} (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
 
 **`copy`**  
-       The data files are copied from old datadir to new datadir.  This option has low risk of data loss in case of some upgrade failure.
+ Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
 
 **`hardlink`**  
-       Data files are hard-linked from old to the new data directory, which brings performance optimization - but the old directory becomes unusable, even in case of failure.
-
+ Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
 
-Note that because we copy data directory, you need to make sure that you have
-enough space for the copy;  upgrade failure because of not enough space might
-lead to data loss.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
 {% endif %}
 
+## Extending Image
 
-Extending image
-----------------
-
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `{{ spec.rhel_image_name }}` image,
-available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `{{ spec.rhel_image_name }}` image, available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-```
+```bash
 $ oc new-app postgresql:{{ spec.version }}~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -277,60 +179,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git {{ spec.rhel_image_name }} new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.

From 3a9ca456595feff93a990e1c3710445821b38994 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sloup?= <osloup@redhat.com>
Date: Mon, 10 Apr 2023 11:39:10 +0200
Subject: [PATCH 373/509] docs: Regenerate docs with script to update
 PostgreSQL README.md files

---
 .../container-scripts/postgresql/README.md    | 245 +++++-------------
 .../container-scripts/postgresql/README.md    | 245 +++++-------------
 .../container-scripts/postgresql/README.md    | 245 +++++-------------
 .../container-scripts/postgresql/README.md    | 245 +++++-------------
 .../container-scripts/postgresql/README.md    | 245 +++++-------------
 5 files changed, 355 insertions(+), 870 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index f1d35905..8e3df377 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL 10 SQL Database Server container image
-===============================================
+# PostgreSQL 10 SQL Database Server Container Image
 
-This container image includes PostgreSQL 10 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 10 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `rhscl/postgresql-10-rhel7` image, which is accessible via the `postgresql:10` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-10-rhel7` image, available via `postgresql:10` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-10-rhel7
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=10 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/10/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/10/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/10/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/10/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,92 +104,45 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
 
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
 
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
 
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
 
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
 
-PostgreSQL auto-tuning
-----------------------
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
 
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
+## PostgreSQL Auto-Tuning
 
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
 
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
 
+## PostgreSQL Admin Account
 
-Changing passwords
-------------------
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
 
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+## Changing Passwords
 
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
 
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 
+## Extending Image
 
-Extending image
-----------------
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-10-rhel7` image, available via `postgresql:10` imagestream tag in Openshift.
 
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `rhscl/postgresql-10-rhel7` image,
-available via `postgresql:10` imagestream tag in Openshift.
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
+```bash
 $ oc new-app postgresql:10~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -239,60 +157,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-10-rhel7 new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 3cc179e1..c7e5add9 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL 12 SQL Database Server container image
-===============================================
+# PostgreSQL 12 SQL Database Server Container Image
 
-This container image includes PostgreSQL 12 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 12 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `rhscl/postgresql-12-rhel7` image, which is accessible via the `postgresql:12` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-12-rhel7` image, available via `postgresql:12` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-12-rhel7
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=12 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/12/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/12/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/12/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/12/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,92 +104,45 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
 
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
 
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
 
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
 
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
 
-PostgreSQL auto-tuning
-----------------------
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
 
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
+## PostgreSQL Auto-Tuning
 
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
 
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
 
+## PostgreSQL Admin Account
 
-Changing passwords
-------------------
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
 
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+## Changing Passwords
 
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
 
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 
+## Extending Image
 
-Extending image
-----------------
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-12-rhel7` image, available via `postgresql:12` imagestream tag in Openshift.
 
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `rhscl/postgresql-12-rhel7` image,
-available via `postgresql:12` imagestream tag in Openshift.
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
+```bash
 $ oc new-app postgresql:12~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -239,60 +157,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-12-rhel7 new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index 624c4a49..d0cf8e95 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL 13 SQL Database Server container image
-===============================================
+# PostgreSQL 13 SQL Database Server Container Image
 
-This container image includes PostgreSQL 13 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 13 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `rhscl/postgresql-13-rhel7` image, which is accessible via the `postgresql:13` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-13-rhel7` image, available via `postgresql:13` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-13-rhel7
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=13 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/13/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/13/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/13/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/13/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,92 +104,45 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
 
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
 
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
 
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
 
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
 
-PostgreSQL auto-tuning
-----------------------
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
 
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
+## PostgreSQL Auto-Tuning
 
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
 
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
 
+## PostgreSQL Admin Account
 
-Changing passwords
-------------------
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
 
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+## Changing Passwords
 
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
 
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 
+## Extending Image
 
-Extending image
-----------------
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-13-rhel7` image, available via `postgresql:13` imagestream tag in Openshift.
 
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `rhscl/postgresql-13-rhel7` image,
-available via `postgresql:13` imagestream tag in Openshift.
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
+```bash
 $ oc new-app postgresql:13~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -239,60 +157,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-13-rhel7 new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
index a7f90a55..57a53c8d 100644
--- a/14/root/usr/share/container-scripts/postgresql/README.md
+++ b/14/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL 14 SQL Database Server container image
-===============================================
+# PostgreSQL 14 SQL Database Server Container Image
 
-This container image includes PostgreSQL 14 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 14 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `rhscl/postgresql-14-rhel7` image, which is accessible via the `postgresql:14` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `rhscl/postgresql-14-rhel7` image, available via `postgresql:14` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-14-rhel7
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=14 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/14/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/14/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/14/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/14/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,92 +104,45 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
 
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
 
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
 
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
 
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
 
-PostgreSQL auto-tuning
-----------------------
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
 
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
+## PostgreSQL Auto-Tuning
 
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
 
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
 
+## PostgreSQL Admin Account
 
-Changing passwords
-------------------
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
 
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+## Changing Passwords
 
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
 
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 
+## Extending Image
 
-Extending image
-----------------
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-14-rhel7` image, available via `postgresql:14` imagestream tag in Openshift.
 
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `rhscl/postgresql-14-rhel7` image,
-available via `postgresql:14` imagestream tag in Openshift.
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
+```bash
 $ oc new-app postgresql:14~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -239,60 +157,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-14-rhel7 new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index c8490927..953027fd 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -1,115 +1,83 @@
-PostgreSQL 15 SQL Database Server container image
-===============================================
+# PostgreSQL 15 SQL Database Server Container Image
 
-This container image includes PostgreSQL 15 SQL database server for OpenShift and general usage.
-Users can choose between RHEL, CentOS and Fedora based images.
-The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
-the CentOS images are available on [Quay.io](https://quay.io/organization/centos7),
-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
-The resulting image can be run using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 15 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
-Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
+## Overview
 
-Description
------------
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
 
-This container image provides a containerized packaging of the PostgreSQL postgres daemon
-and client application. The postgres server daemon accepts connections from clients
-and provides access to content from PostgreSQL databases on behalf of the clients.
-You can find more information on the PostgreSQL project from the project Web site
-(https://www.postgresql.org/).
+## Usage
 
+Assuming you are utilizing the `` image, which is accessible via the `postgresql:15` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
-Usage
------
-
-For this, we will assume that you are using the `` image, available via `postgresql:15` imagestream tag in Openshift.
-If you want to set only the mandatory environment variables and not store the database
-in a host directory, execute the following command:
-
-```
+```bash
 $ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
 ```
 
-This will create a container named `postgresql_database` running PostgreSQL with
-database `db` and user with credentials `user:pass`. 
-> Note: user `postgres` is reserved for internal usage
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
 
-Port 5432 will be exposed
-and mapped to the host. If you want your database to be persistent across container
-executions, also add a `-v /host/db/path:/var/lib/pgsql/data` argument (see
-below). This will be the PostgreSQL database cluster directory.
+> Note: The user `postgres` is reserved for internal usage
 
-The same can be achieved in an Openshift instance using templates provided by Openshift or available in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
 
-```
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
 $ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=15 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
 ```
 
-If the database cluster directory is not initialized, the entrypoint script will
-first run [`initdb`](http://www.postgresql.org/docs/15/static/app-initdb.html)
-and setup necessary database users and passwords. After the database is initialized,
-or if it was already present, [`postgres`](http://www.postgresql.org/docs/15/static/app-postgres.html)
-is executed and will run as PID 1. You can stop the detached container by running
-`podman stop postgresql_database`.
-
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/15/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/15/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
 
+## Environment Variables and Volumes
 
-Environment variables and volumes
----------------------------------
-
-The image recognizes the following environment variables that you can set during
-initialization by passing `-e VAR=VALUE` to the Docker run command.
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
 
 **`POSTGRESQL_USER`**  
-       User name for PostgreSQL account to be created
+ User name for PostgreSQL account to be created
 
 **`POSTGRESQL_PASSWORD`**  
-       Password for the user account
+ Password for the user account
 
 **`POSTGRESQL_DATABASE`**  
-       Database name
+ Database name
 
 **`POSTGRESQL_ADMIN_PASSWORD`**  
-       Password for the `postgres` admin account (optional)
-
+ Password for the `postgres` admin account (optional)
 
 Alternatively, the following options are related to migration scenario:
 
 **`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
-       Hostname/IP to migrate from
+ Hostname/IP to migrate from
 
 **`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
-       Password for the remote 'postgres' admin user
+ Password for the remote 'postgres' admin user
 
 **`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
-       Set to 'yes' to ignore sql import errors
-
+ Set to 'yes' to ignore sql import errors
 
 The following environment variables influence the PostgreSQL configuration file. They are all optional.
 
 **`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
-       The maximum number of client connections allowed
+ The maximum number of client connections allowed
 
 **`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
-       Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
 
 **`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-       Sets how much memory is dedicated to PostgreSQL to use for caching data
+Sets how much memory is dedicated to PostgreSQL to use for caching data
 
 **`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-       Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
 
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
-       Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
-       PostgreSQL database cluster directory
-
+ PostgreSQL database cluster directory
 
 **Notice: When mouting a directory from the host into the container, ensure that the mounted
 directory has the appropriate permissions and that the owner and group of the directory
@@ -119,19 +87,16 @@ Typically (unless you use `podman run -u` option) processes in container
 run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
 for example by:
 
-```
+```bash
 $ setfacl -m u:26:-wx /your/data/dir
 $ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
 ```
 
+## Data Migration
 
-Data migration
---------------
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
 
-PostgreSQL container supports migration of data from remote PostgreSQL server.
-You can run it like:
-
-```
+```bash
 $ podman run -d --name postgresql_database \
     -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
     -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
@@ -139,92 +104,45 @@ $ podman run -d --name postgresql_database \
     rhel8/postgresql-13
 ```
 
-The migration is done the **dump and restore** way (running `pg_dumpall` against
-remote cluster and importing the dump locally by `psql`).  Because the process
-is streamed (unix pipeline), there are no intermediate dump files created during
-this process to not waste additional storage space.
-
-If some SQL commands fail during applying, the default behavior
-of the migration script is to fail as well to ensure the **all** or **nothing**
-result of scripted, unattended migration. In most common cases, successful
-migration is expected (but not guaranteed!), given you migrate from
-a previous version of PostgreSQL server container, that is created using
-the same principles as this one (e.g. migration from
-`rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different kind of PostgreSQL container can likely fail.
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
 
-If this **all** or **nothing** principle is inadequate for you, and you know
-what you are doing, there's optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option
-which does **best effort** migration (some data might be lost, it is up to user
-to review the standard error output and fix the issues manually in
-post-migration time).
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
 
-Please keep in mind that the container image provides help for users'
-convenience, but fully automatic migration is not guaranteed.  Thus, before you
-start proceeding with the database migration, get prepared to perform manual
-steps in order to get all your data migrated.
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
 
-Note that you might not use variables like `POSTGRESQL_USER` in migration
-scenario, all the data (including info about databases, roles or passwords are
-copied from old cluster).  Ensure that you use the same
-`OPTIONAL_CONFIGURATION_VARIABLES` as you used for initialization of the old
-PostgreSQL container.  If some non-default configuration is done on remote
-cluster, you might need to copy the configuration files manually, too.
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
 
-Security warning:  Note that the IP communication between old and new PostgreSQL
-clusters is not encrypted by default, it is up to user to configure SSL on
-remote cluster or ensure security via different means.
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
 
-PostgreSQL auto-tuning
-----------------------
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
 
-When the PostgreSQL image is run with the `--memory` parameter set and if there
-are no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` those values are automatically calculated
-based on the value provided in the `--memory` parameter.
+## PostgreSQL Auto-Tuning
 
-The values are calculated based on the
-[upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-formulas. For the `shared_buffers` we use 1/4 of given memory and for the
-`effective_cache_size` we set the value to 1/2 of the given memory.
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
 
-PostgreSQL admin account
-------------------------
-The admin account `postgres` has no password set by default, only allowing local
-connections.  You can set it by setting the `POSTGRESQL_ADMIN_PASSWORD` environment
-variable when initializing your container. This will allow you to login to the
-`postgres` account remotely. Local connections will still not require a password.
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
 
+## PostgreSQL Admin Account
 
-Changing passwords
-------------------
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
 
-Since passwords are part of the image configuration, the only supported method
-to change passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and
-`POSTGRESQL_ADMIN_PASSWORD`, respectively.
+## Changing Passwords
 
-Changing database passwords through SQL statements or any way other than through
-the environment variables aforementioned will cause a mismatch between the
-values stored in the variables and the actual passwords. Whenever a database
-container starts it will reset the passwords to the values stored in the
-environment variables.
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
 
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
 
+## Extending Image
 
-Extending image
-----------------
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `` image, available via `postgresql:15` imagestream tag in Openshift.
 
-This image can be extended in Openshift using the `Source` build strategy or via the standalone
-[source-to-image](https://github.com/openshift/source-to-image) application (where available).
-For this, we will assume that you are using the `` image,
-available via `postgresql:15` imagestream tag in Openshift.
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
-For example to build customized image `new-postgresql`
-with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image` run:
-
-```
+```bash
 $ oc new-app postgresql:15~https://github.com/sclorg/postgresql-container.git \
   --name new-postgresql \
   --context-dir examples/extending-image/ \
@@ -239,60 +157,39 @@ or via `s2i`:
 $ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
 ```
 
-The directory passed to Openshift should contain one or more of the
-following directories:
-
+The directory passed to Openshift should contain one or more of the following directories:
 
 ##### `postgresql-pre-start/`
 
-Source all `*.sh` files from this directory during early start of the
-container.  There's no PostgreSQL daemon running on background.
-
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
 
 ##### `postgresql-cfg/`
 
-Contained configuration files (`*.conf`) will be included at the end of image
-postgresql.conf file.
-
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
 
 ##### `postgresql-init/`
 
-Contained shell scripts (`*.sh`) are sourced when the database is freshly
-initialized (after successful initdb run which made the data directory
-non-empty).  At the time of sourcing these scripts, the local PostgreSQL
-server is running.  For re-deployments scenarios with persistent data
-directory, the scripts are not sourced (no-op).
-
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
 
 ##### `postgresql-start/`
 
-Same sematics as `postgresql-init/`, except that these scripts are
-always sourced (after `postgresql-init/` scripts, if they exist).
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
 
+---
 
-----------------------------------------------
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
 
-During the s2i build all provided files are copied into `/opt/app-root/src`
-directory in the new image. Only one
-file with the same name can be used for customization and user provided files
-are preferred over default files in `/usr/share/container-scripts/`-
-so it is possible to overwrite them.
+## Troubleshooting
 
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
 
-Troubleshooting
----------------
-At first the postgres daemon writes its logs to the standard output, so these are available in the container log. The log can be examined by running:
-
-    podman logs <container>
+```bash
+podman logs <container>
+```
 
-Then log output is redirected to logging collector process and will appear in directory "pg_log".
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
 
+## Additional Resources
 
-See also
---------
-Dockerfile and other sources for this container image are available on
-https://github.com/sclorg/postgresql-container.
-In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile
-for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
-the Dockerfile for RHEL9 is called Dockerfile.rhel9,
-and the Dockerfile for Fedora is called Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.

From bfcd3c41267ff58133a4fbaa28fb44b75ff59d9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sloup?= <osloup@redhat.com>
Date: Tue, 11 Apr 2023 11:32:30 +0200
Subject: [PATCH 374/509] fix: Edit run_doc_test so it is compatible with new
 documentation It is needed to fix the run_doc_test in test/run_test as it was
 incompatible with changes in the latest documentation. The test checks if
 important information is included in documentation but with a corrected word
 case.

---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 30a60445..e7205a02 100755
--- a/test/run_test
+++ b/test/run_test
@@ -722,7 +722,7 @@ run_doc_test() {
   for f in help.1 ; do
     docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
     # Check whether the files include some important information
-    for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' volume 5432 ; do
+    for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' Volume 5432 ; do
       if ! cat ${tmpdir}/$(basename ${f}) | grep -E -q -e "${term}" ; then
         echo "ERROR: File /${f} does not include '${term}'."
         return 1

From 235d39b18b5cb6463146a0d81bf7762d828b0920 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sloup?= <osloup@redhat.com>
Date: Tue, 18 Apr 2023 02:52:55 +0200
Subject: [PATCH 375/509] docs: Rewrite SSL documentation

---
 examples/enable-ssl/README.md | 40 ++++++++++++-----------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/examples/enable-ssl/README.md b/examples/enable-ssl/README.md
index 135ed97d..fdbd0077 100644
--- a/examples/enable-ssl/README.md
+++ b/examples/enable-ssl/README.md
@@ -1,10 +1,16 @@
-#### enable-ssl
+# Enabling SSL/TLS for PostgreSQL container
 
-This example demonstrates how to extend the postgresql container by enabling SSL/TLS.  
+This example demonstrates extending the PostgreSQL container by enabling SSL/TLS.
 
-The following instructions assumes the use of OpenShift.  
+## Initial configuration
+
+In this example, we will assume that you are using OpenShift. Suppose you do not have Openshift enabled or installed. In that case, you can install it on RHEL via the tutorial [here](https://docs.openshift.com/container-platform/4.12/installing/index.html) or on Fedora with `dnf install origin-clients` ([Openshift Fedora Developer](https://developer.fedoraproject.org/deployment/ocopenshift/about.html)) and `dnf install podman-docker`. You also need to have a valid KUBECONFIG file.
+
+## Example of how to enable SSL to PostgreSQL
+
+1. Deploy postgres:
+   You should use your configuration for `myUser`, `myPassword` and `myDB`
 
-1. Deploy postgres:  
 ```bash
 oc new-app --name psql-ssl postgresql:13-el7~https://github.com/sclorg/postgresql-container.git \
   --context-dir examples/enable-ssl \
@@ -13,14 +19,16 @@ oc new-app --name psql-ssl postgresql:13-el7~https://github.com/sclorg/postgresq
   -e POSTGRESQL_DATABASE=myDB
 ```
 
-2. Create your secrets:  
+2. Create your secrets:
+
 ```bash
 openssl genrsa -out tls.key 2048
 openssl req -new -x509 -key tls.key -out tls.cert
 oc create secret tls db-ssl-keys --key tls.key --cert tls.cert
 ```
 
-3. Bind your secrets into postgres deploymentConfig:  
+3. Bind your secrets into postgres deploymentConfig:
+
 ```bash
 oc set volume --add \
     --type=secret \
@@ -29,23 +37,3 @@ oc set volume --add \
     --mount-path=/opt/app-root/src/certs/ \
     dc/psql-ssl
 ```
-
-By default the `postgresql-pre-start/enable_ssl.sh` needs a service account with `anyuid` SCC.  
-To use in the default `restriced` mode jump to step `5.`  
-_The step 4. example must be executed by a cluster-admin role._  
-  
-4. Create the service account and attach to the deploymentConfig:  
-```bash
-oc create sa psql-ssl-sa
-oc adm policy add-scc-to-user anyuid -z psql-ssl-sa
-oc set sa dc/psql-ssl psql-ssl-sa
-```
-  
-5. Overwriting the `pre-start` scripts enabling the execution with `restricted` SCC mode:  
-```bash
-oc create secret generic psql-custom-prestart --from-literal empty="overwriting-prestart"
-oc set volume dc/psql-ssl --add \
-  --type secret \
-  --secret-name psql-custom-prestart \
-  --mount-path /opt/app-root/src/postgresql-pre-start/
-```

From cd2ace34d590f8b3f28b639f59dbe40be25bb51e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 19 Apr 2023 10:15:15 +0200
Subject: [PATCH 376/509] Add the latest container-common-scripts

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index c1f46d90..0f7afd10 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit c1f46d905f42267cbf0c0f6994c0f8e018bec3f8
+Subproject commit 0f7afd1042769b31344a67436b281ce76a0c0bc2

From 46f346952c29543b69b44b78745160e4dcc6cddd Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 19 Apr 2023 10:15:56 +0200
Subject: [PATCH 377/509] Fix calling funcion ct_os_upload_image

First parameter is needed to determin OpenShift version

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-local-cluster | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
index c3550c0f..35a0f09e 100755
--- a/test/run-openshift-local-cluster
+++ b/test/run-openshift-local-cluster
@@ -122,7 +122,7 @@ function test_postgresql_pure_image() {
 
   ct_os_new_project
   # Create a specific imagestream tag for the image so that oc cannot use anything else
-  ct_os_upload_image "${image_name}" "$image_name_no_namespace"
+  ct_os_upload_image "v3" "${image_name}" "$image_name_no_namespace"
 
   ct_os_deploy_pure_image "$image_name_no_namespace" \
                           --name "${service_name}" \
@@ -141,7 +141,7 @@ function test_postgresql_template() {
   local service_name="${image_name_no_namespace%%:*}-testing"
 
   ct_os_new_project
-  ct_os_upload_image "${image_name}" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "${image_name}" "postgresql:$VERSION"
 
   ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
@@ -189,7 +189,7 @@ function test_postgresql_update() {
 
 
   ct_os_new_project
-  ct_os_upload_image "$old_image" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "$old_image" "postgresql:$VERSION"
   ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
                               POSTGRESQL_VERSION="$VERSION" \
@@ -204,7 +204,7 @@ function test_postgresql_update() {
   pod_ip=$(ct_os_get_service_ip "$service_name")
   insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
 
-  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
   : "Waiting for a few seconds while the pods get restarted"
   sleep 5
 
@@ -225,7 +225,7 @@ function test_postgresql_replication() {
   local master_name="" master_ip="" slave_name="" slave_ip=""
 
   ct_os_new_project
-  ct_os_upload_image "${image_name}" "$istag"
+  ct_os_upload_image "v3" "${image_name}" "$istag"
 
   ct_os_deploy_template_image "$TEMPLATES/replica/postgresql_replica.json" \
                               NAMESPACE="$(oc project -q)" \
@@ -293,7 +293,7 @@ function test_postgresql_persistent_redeploy() {
   local registry="" old_image="" pod_ip=""
 
   ct_os_new_project
-  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
 
   ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
@@ -331,7 +331,7 @@ function test_postgresql_ephemeral_redeploy() {
   local registry="" old_image="" pod_ip=""
 
   ct_os_new_project
-  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
 
   ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \
@@ -370,7 +370,7 @@ function test_postgresql_configmap_start() {
   local test_string=""
 
   ct_os_new_project
-  ct_os_upload_image "$image_name" "postgresql:$VERSION"
+  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
 
   ct_os_deploy_template_image "$template" \
                               NAMESPACE="$(oc project -q)" \

From ae6bfeab8e854793f81e8fd41c4e42b307124137 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 18 May 2023 12:48:09 +0200
Subject: [PATCH 378/509] This test is removed from the test suite

In our CI is failing sporadically and solution is not available yet.
Let's remove it from test but the test function remains.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common        | 2 +-
 test/run_test | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/common b/common
index 0f7afd10..8c4f0ae7 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0f7afd1042769b31344a67436b281ce76a0c0bc2
+Subproject commit 8c4f0ae7a3614569dc72754af5cf3e13c5c00548
diff --git a/test/run_test b/test/run_test
index e7205a02..9dc6929b 100755
--- a/test/run_test
+++ b/test/run_test
@@ -20,7 +20,6 @@ run_container_creation_tests
 run_general_tests
 run_change_password_test
 run_replication_test
-run_master_restart_test
 run_doc_test
 run_s2i_test
 run_test_cfg_hook
@@ -520,6 +519,9 @@ function setup_replication_cluster() {
 
 }
 
+# This test is removed from the test suite
+# In our CI is failing sporadically and solution is not available yet.
+# Let's remove it from test but the test function remains.
 function run_master_restart_test() {
   local DB=postgres
   local PGUSER=master

From 1ecd67b770e4dd7372f630a470f7b60c1d5b9dd1 Mon Sep 17 00:00:00 2001
From: Modassar Rana <modassar.rana@ibm.com>
Date: Mon, 22 May 2023 16:16:55 +0530
Subject: [PATCH 379/509] Multi arch image for postgres c9s based (#511)

---
 .github/workflows/build-and-push.yml | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 6c397c97..4b6928f1 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -107,7 +107,22 @@ jobs:
             docker_context: 15
 
     steps:
-      - name: Build and push to quay.io registry
+      - name: check if Dockerfile is c9s, then Build multi arch image and push to quay.io registry
+        if: matrix.dockerfile == '13/Dockerfile.c9s' || matrix.dockerfile == '15/Dockerfile.c9s'
+        uses: sclorg/build-and-push-action@v4
+        with:
+          registry: "quay.io"
+          registry_namespace: ${{ matrix.registry_namespace }}
+          registry_username: ${{ secrets[matrix.quayio_username] }}
+          registry_token: ${{ secrets[matrix.quayio_token] }}
+          dockerfile: ${{ matrix.dockerfile }}
+          docker_context: ${{ matrix.docker_context }}
+          tag: ${{ matrix.tag }}
+          image_name: ${{ matrix.image_name }}
+          archs: amd64, s390x, ppc64le
+          
+      - name: Check if Dockerfile is not c9s, then Build and push to quay.io registry
+        if: matrix.dockerfile != '13/Dockerfile.c9s' && matrix.dockerfile != '15/Dockerfile.c9s'
         uses: sclorg/build-and-push-action@v4
         with:
           registry: "quay.io"

From 07eccd73025bcf0a9097a5f09da7fc0c71bb19d5 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 12 Jun 2023 08:20:10 +0200
Subject: [PATCH 380/509] add dependabot config

Dependabot will periodially, once a week, create a PR with updated
common/ submodule if that is needed.
Once a month PRs with bumps of used github actions are to be created
if needed.
---
 .github/dependabot.yml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 .github/dependabot.yml

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..39459aba
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,16 @@
+---
+
+version: 2
+updates:
+  - package-ecosystem: gitsubmodule
+    directory: /
+    schedule:
+      interval: weekly
+    labels:
+      - 'ready for review'
+  - package-ecosystem: github-actions
+    directory: /
+    schedule:
+      interval: monthly
+    labels:
+      - 'ready for review'

From fcce2cb6fc90b6a6cdd5258743d164a5617adde1 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 12 Jun 2023 11:15:27 +0000
Subject: [PATCH 381/509] Bump common from `8c4f0ae` to `e746a70`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `8c4f0ae` to `e746a70`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/8c4f0ae7a3614569dc72754af5cf3e13c5c00548...e746a701ef8f428b2775ebbc56101554539afca9)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 8c4f0ae7..e746a701 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 8c4f0ae7a3614569dc72754af5cf3e13c5c00548
+Subproject commit e746a701ef8f428b2775ebbc56101554539afca9

From 8e636f2fde2fa547928a43a5f2362158fe904604 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 13 Jun 2023 09:31:14 +0200
Subject: [PATCH 382/509] Bump actions/checkout from 2 to 3 (#515)

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)
---
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 0100e89f..59055f99 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -12,7 +12,7 @@ jobs:
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - name: Checkout repo
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
           submodules: true
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index c3ec4082..fe5b376b 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -12,7 +12,7 @@ jobs:
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - name: Checkout repo
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
           submodules: true

From b11714fb758f6bde31e36bfc5c3be4c8eda0ebab Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 13 Jun 2023 14:06:56 +0200
Subject: [PATCH 383/509] Bump myrotvorets/set-commit-status-action from 1.1.5
 to 1.1.7 (#514)

Bumps [myrotvorets/set-commit-status-action](https://github.com/myrotvorets/set-commit-status-action) from 1.1.5 to 1.1.7.
- [Release notes](https://github.com/myrotvorets/set-commit-status-action/releases)
- [Commits](https://github.com/myrotvorets/set-commit-status-action/compare/1.1.5...v1.1.7)

---
updated-dependencies:
- dependency-name: myrotvorets/set-commit-status-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 .github/workflows/container-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 59055f99..c57d7ae2 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -30,7 +30,7 @@ jobs:
           echo "sha=$sha" >> "$GITHUB_OUTPUT"
 
       - name: Set final commit status
-        uses: myrotvorets/set-commit-status-action@1.1.5
+        uses: myrotvorets/set-commit-status-action@v1.1.7
         with:
           status: ${{ steps.check.outputs.result }}
           context: "Distgen check"

From a0e3b5c2873146c5f9aa158f98980794f5a12d2e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 13 Jun 2023 09:55:54 +0200
Subject: [PATCH 384/509] Add support for the latest postgresql-15
 imagestreams.

Allow also testing them as they reached GA.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/postgresql-rhel.json | 35 ++++++++++++++++++++++++++++++-
 test/test-lib-postgresql.sh       |  8 +------
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 19dd45b9..4e698ced 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -20,7 +20,40 @@
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "13-el8"
+          "name": "15-el8"
+        }
+      },
+      {
+        "name": "15-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "15"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "15-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "15"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index de943a0b..6242ff3a 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -37,13 +37,7 @@ function test_postgresql_imagestream() {
   elif [ "${OS}" == "rhel9" ]; then
     tag="-el9"
   fi
-  # TODO
-  # Delete this as soon as postgresql image reached GA
-  if [ "${VERSION}" == "15" ]; then
-    echo "WARNING: Version ${VERSION} does not reach GA."
-    echo "WARNING: Remove this condition as soon as it will be available."
-    return 0
-  fi
+
   ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
 }
 

From b7063b07669c3ed8ed0e69aaf91c802168cfb1e6 Mon Sep 17 00:00:00 2001
From: Jonathan King <jonathankingfc@gmail.com>
Date: Wed, 12 Jul 2023 08:08:33 -0400
Subject: [PATCH 385/509] add pipefail to migrate_db function

---
 10/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 12/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 13/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 14/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 15/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 src/root/usr/share/container-scripts/postgresql/common.sh | 1 +
 6 files changed, 6 insertions(+)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index d5e6d579..445dee0a 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -250,6 +250,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index 0d0d8ab5..a78fabc0 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -250,6 +250,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index cfa6997f..f16e0a91 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -250,6 +250,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 97508b19..9dd4444e 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -250,6 +250,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 6963e78a..6e1eca10 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -250,6 +250,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 592b01d8..10a8388c 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -251,6 +251,7 @@ migrate_db ()
 
     # Migration path.
     (
+        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi

From ab0259819a8381166f9a20eb957721d118f2e916 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 26 Jun 2023 14:07:21 +0000
Subject: [PATCH 386/509] Bump common from `e746a70` to `6f1b33a`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `e746a70` to `6f1b33a`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/e746a701ef8f428b2775ebbc56101554539afca9...6f1b33a34c353520f4a8fd1906b4f24b13d10d86)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index e746a701..6f1b33a3 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit e746a701ef8f428b2775ebbc56101554539afca9
+Subproject commit 6f1b33a34c353520f4a8fd1906b4f24b13d10d86

From 9f07503f21be0063e60d60f9f87ac3e8881875c2 Mon Sep 17 00:00:00 2001
From: Jonathan King <jonathankingfc@gmail.com>
Date: Mon, 17 Jul 2023 13:43:24 -0400
Subject: [PATCH 387/509] move pipefail outside of migration block

---
 10/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 12/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 13/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 14/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 15/root/usr/share/container-scripts/postgresql/common.sh  | 2 +-
 src/root/usr/share/container-scripts/postgresql/common.sh | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 445dee0a..ec5ed235 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -248,9 +248,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index a78fabc0..34483b6e 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -248,9 +248,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index f16e0a91..c75d823f 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -248,9 +248,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 9dd4444e..e3c4d28f 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -248,9 +248,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 6e1eca10..e2ff4c4f 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -248,9 +248,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 10a8388c..3ba756ed 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -249,9 +249,9 @@ migrate_db ()
 {
     test "$postinitdb_actions" = ",migration" || return 0
 
+    set -o pipefail
     # Migration path.
     (
-        set -o pipefail
         if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
             echo '\set ON_ERROR_STOP on'
         fi

From ce36d6353818fda144e86e1ab2128fc30ecc79df Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Wed, 19 Jul 2023 21:17:19 +0200
Subject: [PATCH 388/509] Turn pipefail option off to not change behaviour
 beyond the function scope

---
 10/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 12/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 13/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 14/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 15/root/usr/share/container-scripts/postgresql/common.sh  | 1 +
 src/root/usr/share/container-scripts/postgresql/common.sh | 1 +
 6 files changed, 6 insertions(+)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index ec5ed235..29e91dd8 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -260,6 +260,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index 34483b6e..e917c39d 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -260,6 +260,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index c75d823f..5b166305 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -260,6 +260,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index e3c4d28f..53ed955f 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -260,6 +260,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index e2ff4c4f..0428cd0e 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -260,6 +260,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 3ba756ed..f725ba21 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -261,6 +261,7 @@ migrate_db ()
         pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
             | grep -v '^CREATE ROLE postgres;'
     ) | psql
+    set +o pipefail
 }
 
 function set_pgdata ()

From 3cc5f71cf4a8c34ffa1a557988606947fc6c5b16 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 20 Jul 2023 17:16:00 +0200
Subject: [PATCH 389/509] Add a test suggested in PR where we added pipefail

https://github.com/sclorg/postgresql-container/pull/521
---
 test/run_migration_test | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/run_migration_test b/test/run_migration_test
index 654e56e4..7a5e2245 100755
--- a/test/run_migration_test
+++ b/test/run_migration_test
@@ -53,4 +53,17 @@ assert_migration_succeeds ()
     container_from= container_to=
 }
 
+# test case suggested in https://github.com/sclorg/postgresql-container/pull/521
+assert_migration_fails()
+{
+    docker run --rm -e POSTGRESQL_MIGRATION_REMOTE_HOST=invalid-host-name -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=password "$image_to" run-postgresql --version
+    if [ $? -eq 0 ] ; then
+      info "The image existed with 0 despite migration obviously did not work, that's a problem."
+      return 1
+    else
+      info "The image existed with non-zero exit code when migration obviously did not work, which is correct"
+    fi
+}
+
 assert_migration_succeeds pagila
+assert_migration_fails

From b3baf100aa4e8a32c076cd81a794c096ff2c0950 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 21 Jul 2023 10:02:41 +0200
Subject: [PATCH 390/509] Update test/run_migration_test

Co-authored-by: Petr Kubat <pkubat@redhat.com>
---
 test/run_migration_test | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/run_migration_test b/test/run_migration_test
index 7a5e2245..294ebde3 100755
--- a/test/run_migration_test
+++ b/test/run_migration_test
@@ -58,10 +58,10 @@ assert_migration_fails()
 {
     docker run --rm -e POSTGRESQL_MIGRATION_REMOTE_HOST=invalid-host-name -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=password "$image_to" run-postgresql --version
     if [ $? -eq 0 ] ; then
-      info "The image existed with 0 despite migration obviously did not work, that's a problem."
+      info "The image exited with 0 despite migration obviously did not work, that's a problem."
       return 1
     else
-      info "The image existed with non-zero exit code when migration obviously did not work, which is correct"
+      info "The image exited with non-zero exit code when migration obviously did not work, which is correct"
     fi
 }
 

From 6c2f02e66fe42bccf61182a22d303cf59deee0cb Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 21 Jul 2023 15:06:06 +0200
Subject: [PATCH 391/509] Run the migration command directly in the
 if-statement

Since there is set -e set, it would fail too early even if the container
worked as expected.
---
 test/run_migration_test | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/run_migration_test b/test/run_migration_test
index 294ebde3..db1af9b3 100755
--- a/test/run_migration_test
+++ b/test/run_migration_test
@@ -56,8 +56,7 @@ assert_migration_succeeds ()
 # test case suggested in https://github.com/sclorg/postgresql-container/pull/521
 assert_migration_fails()
 {
-    docker run --rm -e POSTGRESQL_MIGRATION_REMOTE_HOST=invalid-host-name -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=password "$image_to" run-postgresql --version
-    if [ $? -eq 0 ] ; then
+    if docker run --rm -e POSTGRESQL_MIGRATION_REMOTE_HOST=invalid-host-name -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=password "$image_to" run-postgresql --version ; then
       info "The image exited with 0 despite migration obviously did not work, that's a problem."
       return 1
     else

From 31e29a0c45b07f7a6e3a5e5bff35af300ee3aa56 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Tue, 25 Jul 2023 13:57:56 +0200
Subject: [PATCH 392/509] update imagestreams for CentOS Stream

---
 imagestreams/postgresql-centos.json | 82 +++++++++++------------------
 1 file changed, 32 insertions(+), 50 deletions(-)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 9c71e598..39a57885 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -14,139 +14,121 @@
         "annotations": {
           "openshift.io/display-name": "PostgreSQL (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL database on CentOS Stream. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "12-el8"
+          "name": "15-el9"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el7",
+        "name": "15-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (CentOS 7)",
+          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-13-centos7:latest"
+          "name": "quay.io/sclorg/postgresql-15-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el8",
+        "name": "13-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (CentOS 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-12-centos8:latest"
+          "name": "docker.io/sclorg/postgresql-13-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el7",
+        "name": "15-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (CentOS 7)",
+          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-12-centos7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "12"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-12-centos7:latest"
+          "name": "quay.io/sclorg/postgresql-15-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el8",
+        "name": "13-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (CentOS 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/centos/postgresql-10-centos8:latest"
+          "name": "quay.io/sclorg/postgresql-13-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el7",
+        "name": "12-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (CentOS 7)",
+          "openshift.io/display-name": "PostgreSQL 12 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-10-centos7:latest"
+          "name": "quay.io/sclorg/postgresql-12-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10",
+        "name": "10-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10",
+          "openshift.io/display-name": "PostgreSQL 10 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 10 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
+          "tags": "database,postgresql",
           "version": "10"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/centos7/postgresql-10-centos7:latest"
+          "name": "quay.io/sclorg/postgresql-10-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"

From bc3e3443637db579a1cfd25cf71960db9c5ff24e Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 31 Jul 2023 09:41:20 +0200
Subject: [PATCH 393/509] fix: community imagestreams - add correct repository
 URL

---
 imagestreams/postgresql-centos.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 39a57885..ce9a2990 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -56,7 +56,7 @@
         },
         "from": {
           "kind": "DockerImage",
-          "name": "docker.io/sclorg/postgresql-13-c9s:latest"
+          "name": "quay.io/sclorg/postgresql-13-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"

From 69623db6c74ac2437a2f11c0733e38c4b8dbb6b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Muzik=C3=A1=C5=99?= <vaclav@muzikari.cz>
Date: Fri, 4 Aug 2023 09:16:18 +0200
Subject: [PATCH 394/509] Add ARM64 support to c9s images (#527)

---
 .github/workflows/build-and-push.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 4b6928f1..dd025719 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -119,7 +119,7 @@ jobs:
           docker_context: ${{ matrix.docker_context }}
           tag: ${{ matrix.tag }}
           image_name: ${{ matrix.image_name }}
-          archs: amd64, s390x, ppc64le
+          archs: amd64, s390x, ppc64le, arm64
           
       - name: Check if Dockerfile is not c9s, then Build and push to quay.io registry
         if: matrix.dockerfile != '13/Dockerfile.c9s' && matrix.dockerfile != '15/Dockerfile.c9s'

From 9ebea2b8b44d71d14add8f94ed072f1b13dc4809 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 17 Jul 2023 15:28:43 +0200
Subject: [PATCH 395/509] disable testing and pushing to quay.io for CentOS7
 image

The CentOS registry has been decommissioned[1]. Alternative registries
provide only old versions of CentOS base image. Because there is no
known possibility currently to obtain fresh CentOS7 base container image
(we do not want to update old images with yum -y update) we are stopping
rebuilds of the SCLorg's s2i-images too.  Already built images will be
still available on quay.io.

[1] https://lists.centos.org/pipermail/centos-devel/2023-May/142956.html
---
 .github/workflows/build-and-push.yml  | 23 +----------------------
 .github/workflows/container-tests.yml |  2 +-
 .github/workflows/openshift-tests.yml |  4 +---
 specs/multispec.yml                   |  5 +++++
 4 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index dd025719..d4073d47 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -1,4 +1,4 @@
-name: Build and push CentOS7 images to Quay.io registry
+name: Build and push images to Quay.io registry
 on:
   push:
     branches:
@@ -14,27 +14,6 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - dockerfile: "10/Dockerfile"
-            registry_namespace: "centos7"
-            tag: "centos7"
-            image_name: "postgresql-10-centos7"
-            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-            docker_context: 10
-          - dockerfile: "12/Dockerfile"
-            registry_namespace: "centos7"
-            tag: "centos7"
-            image_name: "postgresql-12-centos7"
-            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-            docker_context: 12
-          - dockerfile: "13/Dockerfile"
-            registry_namespace: "centos7"
-            tag: "centos7"
-            image_name: "postgresql-13-centos7"
-            quayio_username: "QUAY_IMAGE_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_BUILDER_TOKEN"
-            docker_context: 13
           - dockerfile: "13/Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index c57d7ae2..d3f35d48 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -55,7 +55,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "14", "15" ]
-        os_test: [ "fedora", "centos7", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
+        os_test: [ "fedora", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
         test_case: [ "container" ]
 
     if: |
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index fe5b376b..a576033f 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -35,11 +35,9 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "15" ]
-        os_test: [ "centos7", "rhel7", "rhel8", "rhel9"]
+        os_test: [ "rhel7", "rhel8", "rhel9"]
         test_case: [ "openshift-3", "openshift-4" ]
         exclude:
-          - test_case: "openshift-4"
-            os_test: "centos7"
           - test_case: "openshift-3"
             os_test: "rhel8"
           - test_case: "openshift-3"
diff --git a/specs/multispec.yml b/specs/multispec.yml
index a62c9c91..5b1561b9 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -161,13 +161,18 @@ matrix:
   exclude:
     - distros:
         - rhel-9-x86_64
+        - centos-7-x86_64
         - centos-stream-9-x86_64
         - fedora-35-x86_64
       version: "10"
     - distros:
         - rhel-9-x86_64
+        - centos-7-x86_64
         - centos-stream-9-x86_64
       version: "12"
+    - distros:
+        - centos-7-x86_64
+      version: "13"
     - distros:
         - centos-7-x86_64
         - rhel-7-x86_64

From 0c51be3f20b12508777fab7f327cd3bf4376a065 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Mon, 17 Jul 2023 16:58:24 +0200
Subject: [PATCH 396/509] migrate all fedora images to f38 base image

---
 specs/multispec.yml   | 12 ++++++------
 src/Dockerfile.fedora |  6 +-----
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 5b1561b9..ac8e6e0a 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -4,7 +4,7 @@ specs:
   distroinfo:
     fedora:
       distros:
-        - fedora-35-x86_64
+        - fedora-38-x86_64
       s2i_base: quay.io/fedora/s2i-core
       org: "fedora"
       prod: "fedora"
@@ -123,7 +123,7 @@ specs:
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
-      latest_fedora: "f35"
+      latest_fedora: "f38"
 
     "13":
       version: "13"
@@ -134,7 +134,7 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f35"
+      latest_fedora: "f38"
 
     "14":
       version: "14"
@@ -145,7 +145,7 @@ specs:
       rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
       centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f37"
+      latest_fedora: "f38"
 
     "15":
       version: "15"
@@ -154,7 +154,7 @@ specs:
       prev_short: "13"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f37"
+      latest_fedora: "f38"
 
 
 matrix:
@@ -163,7 +163,7 @@ matrix:
         - rhel-9-x86_64
         - centos-7-x86_64
         - centos-stream-9-x86_64
-        - fedora-35-x86_64
+        - fedora-38-x86_64
       version: "10"
     - distros:
         - rhel-9-x86_64
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index f279329c..932ede86 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,8 +1,4 @@
-{% if spec.version == "14" or spec.version == "15" %}
-FROM quay.io/fedora/s2i-core:37
-{% else %}
-FROM quay.io/fedora/s2i-core:35
-{% endif %}
+FROM quay.io/fedora/s2i-core:38
 
 # PostgreSQL image for OpenShift.
 # Volumes:

From f3820e5091725b65850abb65dc6f2315a8053d60 Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 26 Jul 2023 09:22:19 +0200
Subject: [PATCH 397/509] add distgen generated content

---
 10/Dockerfile         |  1 -
 10/Dockerfile.centos7 | 90 ------------------------------------------
 12/Dockerfile         |  1 -
 12/Dockerfile.centos7 | 91 -------------------------------------------
 12/Dockerfile.fedora  |  2 +-
 13/Dockerfile         |  1 -
 13/Dockerfile.centos7 | 91 -------------------------------------------
 13/Dockerfile.fedora  |  2 +-
 14/Dockerfile.fedora  |  2 +-
 15/Dockerfile.fedora  |  2 +-
 10 files changed, 4 insertions(+), 279 deletions(-)
 delete mode 120000 10/Dockerfile
 delete mode 100644 10/Dockerfile.centos7
 delete mode 120000 12/Dockerfile
 delete mode 100644 12/Dockerfile.centos7
 delete mode 120000 13/Dockerfile
 delete mode 100644 13/Dockerfile.centos7

diff --git a/10/Dockerfile b/10/Dockerfile
deleted file mode 120000
index 002d0b93..00000000
--- a/10/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-./Dockerfile.centos7
\ No newline at end of file
diff --git a/10/Dockerfile.centos7 b/10/Dockerfile.centos7
deleted file mode 100644
index 2cf2e3f3..00000000
--- a/10/Dockerfile.centos7
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM quay.io/centos7/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=10 \
-    POSTGRESQL_PREV_VERSION=9.6 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 10" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql10,rh-postgresql10" \
-      io.openshift.s2i.assemble-user="26" \
-      name="centos7/postgresql-10-centos7" \
-      com.redhat.component="rh-postgresql10-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-10-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql10
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/12/Dockerfile b/12/Dockerfile
deleted file mode 120000
index 002d0b93..00000000
--- a/12/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-./Dockerfile.centos7
\ No newline at end of file
diff --git a/12/Dockerfile.centos7 b/12/Dockerfile.centos7
deleted file mode 100644
index 0d8102e1..00000000
--- a/12/Dockerfile.centos7
+++ /dev/null
@@ -1,91 +0,0 @@
-FROM quay.io/centos7/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=12 \
-    POSTGRESQL_PREV_VERSION=10 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 12" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql12,rh-postgresql12" \
-      io.openshift.s2i.assemble-user="26" \
-      name="centos7/postgresql-12-centos7" \
-      com.redhat.component="rh-postgresql12-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-12-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
-    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql12
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index 2915ad69..f596e65f 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:35
+FROM quay.io/fedora/s2i-core:38
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/13/Dockerfile b/13/Dockerfile
deleted file mode 120000
index 002d0b93..00000000
--- a/13/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-./Dockerfile.centos7
\ No newline at end of file
diff --git a/13/Dockerfile.centos7 b/13/Dockerfile.centos7
deleted file mode 100644
index 70c67bdf..00000000
--- a/13/Dockerfile.centos7
+++ /dev/null
@@ -1,91 +0,0 @@
-FROM quay.io/centos7/s2i-core-centos7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=13 \
-    POSTGRESQL_PREV_VERSION=12 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 13" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql13,rh-postgresql13" \
-      io.openshift.s2i.assemble-user="26" \
-      name="centos7/postgresql-13-centos7" \
-      com.redhat.component="rh-postgresql13-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 centos7/postgresql-13-centos7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum install -y centos-release-scl-rh && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
-    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql13
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index c9178e84..7031f394 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:35
+FROM quay.io/fedora/s2i-core:38
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora
index 586b11bf..6cc888ee 100644
--- a/14/Dockerfile.fedora
+++ b/14/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:37
+FROM quay.io/fedora/s2i-core:38
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index 9681e82c..762cfbb1 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:37
+FROM quay.io/fedora/s2i-core:38
 
 # PostgreSQL image for OpenShift.
 # Volumes:

From bdead8a26298cb817c5f3e7a1ad832fb01314dba Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 21 Aug 2023 13:35:11 +0000
Subject: [PATCH 398/509] Bump common from `6f1b33a` to `646af72`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `6f1b33a` to `646af72`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/6f1b33a34c353520f4a8fd1906b4f24b13d10d86...646af729971641b5f6ec9de977ec13a563b75bbc)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 6f1b33a3..646af729 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 6f1b33a34c353520f4a8fd1906b4f24b13d10d86
+Subproject commit 646af729971641b5f6ec9de977ec13a563b75bbc

From bc424fc0ad92183babf1d0f26d59a4123f746065 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 28 Aug 2023 13:21:02 +0000
Subject: [PATCH 399/509] Bump common from `646af72` to `7e222b8`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `646af72` to `7e222b8`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/646af729971641b5f6ec9de977ec13a563b75bbc...7e222b8f9f5ac5c4dff6aa1248ddc20a18385a6e)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 646af729..7e222b8f 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 646af729971641b5f6ec9de977ec13a563b75bbc
+Subproject commit 7e222b8f9f5ac5c4dff6aa1248ddc20a18385a6e

From bd27064166a0c6fbd6da74bb92cac66a8bdf41be Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 18 Sep 2023 13:06:46 +0000
Subject: [PATCH 400/509] Bump common from `7e222b8` to `250ae7c`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `7e222b8` to `250ae7c`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/7e222b8f9f5ac5c4dff6aa1248ddc20a18385a6e...250ae7c6b9312e2389b08d349a1a95c59ed1dde9)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 7e222b8f..250ae7c6 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 7e222b8f9f5ac5c4dff6aa1248ddc20a18385a6e
+Subproject commit 250ae7c6b9312e2389b08d349a1a95c59ed1dde9

From 0ff98ddca20f5e8254b38d009ef77b24ab5079b0 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:45:48 +0000
Subject: [PATCH 401/509] Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index d3f35d48..f7bad804 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -12,7 +12,7 @@ jobs:
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - name: Checkout repo
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
           submodules: true
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index a576033f..cbd9c2d7 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -12,7 +12,7 @@ jobs:
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - name: Checkout repo
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           ref: "refs/pull/${{ github.event.issue.number }}/head"
           submodules: true

From b99f5fbeabda444a0a6ecead59cb3ed5300f7809 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:45:52 +0000
Subject: [PATCH 402/509] Bump myrotvorets/set-commit-status-action from 1.1.7
 to 2.0.0

Bumps [myrotvorets/set-commit-status-action](https://github.com/myrotvorets/set-commit-status-action) from 1.1.7 to 2.0.0.
- [Release notes](https://github.com/myrotvorets/set-commit-status-action/releases)
- [Commits](https://github.com/myrotvorets/set-commit-status-action/compare/v1.1.7...v2.0.0)

---
updated-dependencies:
- dependency-name: myrotvorets/set-commit-status-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 .github/workflows/container-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index d3f35d48..19a7e54e 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -30,7 +30,7 @@ jobs:
           echo "sha=$sha" >> "$GITHUB_OUTPUT"
 
       - name: Set final commit status
-        uses: myrotvorets/set-commit-status-action@v1.1.7
+        uses: myrotvorets/set-commit-status-action@v2.0.0
         with:
           status: ${{ steps.check.outputs.result }}
           context: "Distgen check"

From ebc071a086e00a710935472432a92a7e0afa2ccd Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Fri, 18 Dec 2020 17:59:47 +0100
Subject: [PATCH 403/509] Add example how to enable extension

---
 examples/enable-extension/Dockerfile          |  3 ++
 examples/enable-extension/README.md           | 31 +++++++++++++++++++
 .../postgresql-cfg/s2i-extending.conf         |  1 +
 .../postgresql-init/set_passwords.sh          |  3 ++
 4 files changed, 38 insertions(+)
 create mode 100644 examples/enable-extension/Dockerfile
 create mode 100644 examples/enable-extension/README.md
 create mode 100644 examples/enable-extension/postgresql-cfg/s2i-extending.conf
 create mode 100644 examples/enable-extension/postgresql-init/set_passwords.sh

diff --git a/examples/enable-extension/Dockerfile b/examples/enable-extension/Dockerfile
new file mode 100644
index 00000000..3f46cf47
--- /dev/null
+++ b/examples/enable-extension/Dockerfile
@@ -0,0 +1,3 @@
+FROM registry.redhat.io/rhel8/postgresql-12
+
+ADD . $APP_ROOT/src/
diff --git a/examples/enable-extension/README.md b/examples/enable-extension/README.md
new file mode 100644
index 00000000..dd990fca
--- /dev/null
+++ b/examples/enable-extension/README.md
@@ -0,0 +1,31 @@
+Extending PostgreSQL image by enabling extension
+================================================
+
+This is an example how to use the feature of extending the image (see more at https://github.com/sclorg/postgresql-container/tree/generated/12#extending-image) to enable extension `pg_stat_statements`.
+
+To use this in a Dockerfile, run:
+
+```
+podman build . -t my_postgresql:12
+```
+
+Then, run the resulting image as usually:
+
+```
+podman run -d -e POSTGRESQL_ADMIN_PASSWORD=password my_postgresql:12
+```
+
+And see the extension is enabled:
+```
+podman exec -ti -l bash
+bash-4.4$ psql
+psql (12.1)
+Type "help" for help.
+
+postgres=# \dx
+                 List of installed extensions
+  Name   | Version |   Schema   |         Description          
+---------+---------+------------+------------------------------
+ plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
+(1 row)
+```
diff --git a/examples/enable-extension/postgresql-cfg/s2i-extending.conf b/examples/enable-extension/postgresql-cfg/s2i-extending.conf
new file mode 100644
index 00000000..b638d261
--- /dev/null
+++ b/examples/enable-extension/postgresql-cfg/s2i-extending.conf
@@ -0,0 +1 @@
+shared_preload_libraries='pg_stat_statements'
diff --git a/examples/enable-extension/postgresql-init/set_passwords.sh b/examples/enable-extension/postgresql-init/set_passwords.sh
new file mode 100644
index 00000000..05e210e7
--- /dev/null
+++ b/examples/enable-extension/postgresql-init/set_passwords.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "CREATE EXTENSION pg_stat_statements;" | psql

From b36dfdb27aed6797febac944f959d5a2db1e4748 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 22 Nov 2023 14:47:55 +0100
Subject: [PATCH 404/509] Bump common from `250ae7c` to `909ab16` (#535)

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 250ae7c6..909ab162 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 250ae7c6b9312e2389b08d349a1a95c59ed1dde9
+Subproject commit 909ab16214bdfb3e1428cea51c7032533977a501

From 6a37e25ee398b95ae4c2afe0e58974d194a09d2e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 30 Nov 2023 14:11:31 +0100
Subject: [PATCH 405/509] Migration from DeploymentConfig to Deployment

For more information see
https://docs.openshift.com/container-platform/4.12/applications/deployments/what-deployments-are.html

Since OpenShift 4.14 DeploymentConfigs are deprecated. https://access.redhat.com/articles/7041372

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 examples/postgresql-ephemeral-template.json  | 31 +++++---------------
 examples/postgresql-persistent-template.json | 31 +++++---------------
 2 files changed, 14 insertions(+), 48 deletions(-)

diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index bf5bf57a..31674d1e 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -66,41 +66,24 @@
       }
     },
     {
-      "kind": "DeploymentConfig",
-      "apiVersion": "apps.openshift.io/v1",
+      "kind": "Deployment",
+      "apiVersion": "apps/v1",
       "metadata": {
         "name": "${DATABASE_SERVICE_NAME}",
         "annotations": {
-          "template.alpha.openshift.io/wait-for-ready": "true"
+          "template.alpha.openshift.io/wait-for-ready": "true",
+          "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"postgresql:${POSTGRESQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
         }
       },
       "spec": {
         "strategy": {
           "type": "Recreate"
         },
-        "triggers": [
-          {
-            "type": "ImageChange",
-            "imageChangeParams": {
-              "automatic": true,
-              "containerNames": [
-                "postgresql"
-              ],
-              "from": {
-                "kind": "ImageStreamTag",
-                "name": "postgresql:${POSTGRESQL_VERSION}",
-                "namespace": "${NAMESPACE}"
-              },
-              "lastTriggeredImage": ""
-            }
-          },
-          {
-            "type": "ConfigChange"
-          }
-        ],
         "replicas": 1,
         "selector": {
-          "name": "${DATABASE_SERVICE_NAME}"
+          "matchLabels": {
+            "name": "${DATABASE_SERVICE_NAME}"
+          }
         },
         "template": {
           "metadata": {
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index 312ecd91..fa131ed8 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -83,41 +83,24 @@
       }
     },
     {
-      "kind": "DeploymentConfig",
-      "apiVersion": "apps.openshift.io/v1",
+      "kind": "Deployment",
+      "apiVersion": "apps/v1",
       "metadata": {
         "name": "${DATABASE_SERVICE_NAME}",
         "annotations": {
-          "template.alpha.openshift.io/wait-for-ready": "true"
+          "template.alpha.openshift.io/wait-for-ready": "true",
+          "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"postgresql:${POSTGRESQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
         }
       },
       "spec": {
         "strategy": {
           "type": "Recreate"
         },
-        "triggers": [
-          {
-            "type": "ImageChange",
-            "imageChangeParams": {
-              "automatic": true,
-              "containerNames": [
-                "postgresql"
-              ],
-              "from": {
-                "kind": "ImageStreamTag",
-                "name": "postgresql:${POSTGRESQL_VERSION}",
-                "namespace": "${NAMESPACE}"
-              },
-              "lastTriggeredImage": ""
-            }
-          },
-          {
-            "type": "ConfigChange"
-          }
-        ],
         "replicas": 1,
         "selector": {
-          "name": "${DATABASE_SERVICE_NAME}"
+          "matchLabels": {
+            "name": "${DATABASE_SERVICE_NAME}"
+          }
         },
         "template": {
           "metadata": {

From 77ac4971eb4efc1b1de08894dc86c5e706aeb56a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 30 Nov 2023 14:11:53 +0100
Subject: [PATCH 406/509] Use officially released image for testing

Test both templates in postgresql_imagestream test

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 6242ff3a..6292ef6f 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -20,7 +20,7 @@ function test_postgresql_integration() {
     ct_os_test_template_app_func "${IMAGE_NAME}" \
                                  "${THISDIR}/examples/${template}" \
                                  "${service_name}" \
-                                 "ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
+                                 "ct_os_check_cmd_internal 'registry.redhat.io/${OS}/postgresql-${VERSION}' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
                                  "-p POSTGRESQL_VERSION=${VERSION} \
                                   -p DATABASE_SERVICE_NAME="${service_name}-testing" \
                                   -p POSTGRESQL_USER=testu \
@@ -37,8 +37,11 @@ function test_postgresql_imagestream() {
   elif [ "${OS}" == "rhel9" ]; then
     tag="-el9"
   fi
-
-  ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
+  TEMPLATES="postgresql-ephemeral-template.json
+  postgresql-persistent-template.json"
+  for template in $TEMPLATES; do
+    ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/${template}" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
+  done
 }
 
 

From e7579c9de20767ed0a173c5970d1991fa74b1fba Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 4 Dec 2023 12:54:44 +0100
Subject: [PATCH 407/509] Use proper image for RHEL7

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test-lib-postgresql.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 6292ef6f..998c6814 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -14,13 +14,18 @@ source "${THISDIR}"/test-lib-remote-openshift.sh
 
 function test_postgresql_integration() {
   local service_name=postgresql
+  if [ "${OS}" == "rhel7" ]; then
+    namespace_image="rhscl/postgresql-${VERSION}-rhel7"
+  else
+    namespace_image="${OS}/postgresql-${VERSION}"
+  fi
   TEMPLATES="postgresql-ephemeral-template.json
   postgresql-persistent-template.json"
   for template in $TEMPLATES; do
     ct_os_test_template_app_func "${IMAGE_NAME}" \
                                  "${THISDIR}/examples/${template}" \
                                  "${service_name}" \
-                                 "ct_os_check_cmd_internal 'registry.redhat.io/${OS}/postgresql-${VERSION}' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
+                                 "ct_os_check_cmd_internal 'registry.redhat.io/${namespace_image}' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
                                  "-p POSTGRESQL_VERSION=${VERSION} \
                                   -p DATABASE_SERVICE_NAME="${service_name}-testing" \
                                   -p POSTGRESQL_USER=testu \

From 44724a4865b32d9ff08e381b87c252c485a3db41 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 5 Dec 2023 09:06:10 +0100
Subject: [PATCH 408/509] Bump common from `909ab16` to `c5d8cea` (#539)

---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 909ab162..c5d8cea9 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 909ab16214bdfb3e1428cea51c7032533977a501
+Subproject commit c5d8cea9e87098e4966d101cb7033aa5ae8a318e

From 62a0e88ae0e5f19c3dad1cb6fea3778dfa2dbf2f Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Tue, 21 Nov 2023 16:47:46 +0100
Subject: [PATCH 409/509] each container in run_change_password_test mounts its
 own volume

selinux does not allow two containers accesing one mounting directory if
mounted with Z option
---
 test/run_test | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/run_test b/test/run_test
index 9dc6929b..c560434c 100755
--- a/test/run_test
+++ b/test/run_test
@@ -634,6 +634,11 @@ $volume_options
 
   echo "  Changing passwords"
 
+  # create separate mounting directory for second container, as selinux does
+  # not allow two containers accesing one mounting directory if mounted with
+  # Z option
+  create_volume_dir || ret=1
+
   DOCKER_ARGS="
 -e POSTGRESQL_DATABASE=${database}
 -e POSTGRESQL_USER=${user}

From d596dbcdf69b6b75fc2b7559f450e826010a9a8a Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 4 Jan 2024 15:02:16 +0100
Subject: [PATCH 410/509] Do not ignore SQL failures and check that we still
 work with previous data when changing password

Fix also postgresql_cmd function that should not ignore SQL errors
(thus using ON_ERROR_STOP option now) and was often called with an
interactive input using <<< but podman run is run in non-interactive
mode, resulting in the SQL commands to not be printed, so checking
them later did not work and errors are not visible.
Using -c option solves this.

Function test_postgresql was called with a parameter that was not
used anywhere. This function used CREATE EXTENSION to test proper
PostgreSQL functionality, that only admin have permissions for.
So, the parameter of test_postgresql function was changed to have
a useful meaning. The meaning is that only if the parameter is
"admin", the CREATE EXTENSION statement is run to not see
"Not enough permissions" error when the contianer is run as a
normal user.
---
 test/run_test | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/test/run_test b/test/run_test
index c560434c..71771439 100755
--- a/test/run_test
+++ b/test/run_test
@@ -107,7 +107,7 @@ function get_ip_from_cid() {
 }
 
 function postgresql_cmd() {
-  docker run --rm -e PGPASSWORD="$PASS" "$IMAGE_NAME" psql "postgresql://$PGUSER@$CONTAINER_IP:5432/${DB-db}" "$@"
+  docker run --rm -e PGPASSWORD="$PASS" "$IMAGE_NAME" psql -v ON_ERROR_STOP=1 "postgresql://$PGUSER@$CONTAINER_IP:5432/${DB-db}" "$@"
 }
 
 function test_connection() {
@@ -121,9 +121,9 @@ function test_connection() {
     # Don't let the code come here if neither user nor admin is able to
     # connect.
     if [ -v PGUSER ] && [ -v PASS ]; then
-      CONTAINER_IP=$ip postgresql_cmd <<< "SELECT 1;"
+      CONTAINER_IP=$ip postgresql_cmd -At -c "SELECT 1;"
     else
-      PGUSER=postgres PASS=$ADMIN_PASS CONTAINER_IP=$ip DB=postgres postgresql_cmd <<< "SELECT 1;"
+      PGUSER=postgres PASS=$ADMIN_PASS CONTAINER_IP=$ip DB=postgres postgresql_cmd -At -c "SELECT 1;"
     fi
     status=$?
     if [ $status -eq 0 ]; then
@@ -137,14 +137,19 @@ function test_connection() {
 
 function test_postgresql() {
   local ret=0
+  local user=${1:-user}
   echo "  Testing PostgreSQL"
-  postgresql_cmd <<< "CREATE EXTENSION 'uuid-ossp';" || ret=1 # to test contrib package
-  postgresql_cmd <<< "CREATE TABLE tbl (col1 VARCHAR(20), col2 VARCHAR(20));" || ret=2
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo1', 'bar1');" || ret=3
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo2', 'bar2');" || ret=4
-  postgresql_cmd <<< "INSERT INTO tbl VALUES ('foo3', 'bar3');" || ret=5
-  postgresql_cmd <<< "SELECT * FROM tbl;" || ret=6
-  #postgresql_cmd <<< "DROP TABLE tbl;"
+  # test contrib only when having admin privileges
+  if [ "$user" == "admin" ] ; then
+    postgresql_cmd -At -c "CREATE EXTENSION \"uuid-ossp\";" || ret=1 # to test contrib package
+  fi
+  postgresql_cmd -At -c "CREATE TABLE tbl (col1 VARCHAR(20), col2 VARCHAR(20));" || ret=2
+  postgresql_cmd -At -c "INSERT INTO tbl VALUES ('foo1', 'bar1');" || ret=3
+  postgresql_cmd -At -c "INSERT INTO tbl VALUES ('foo2', 'bar2');" || ret=4
+  postgresql_cmd -At -c "INSERT INTO tbl VALUES ('foo3', 'bar3');" || ret=5
+  postgresql_cmd -At -c "SELECT * FROM tbl;" || ret=6
+  # not droping table, other tests depend on having it created after this function is run
+  #postgresql_cmd -At -c "DROP TABLE tbl;"
   if [ $ret -eq 0 ]; then
     echo "  Success!"
   fi
@@ -195,7 +200,7 @@ function assert_login_access() {
 
   echo "testing login as $PGUSER:$PASS; should_success=$success"
 
-  if postgresql_cmd <<<'SELECT 1;' ; then
+  if postgresql_cmd -At -c 'SELECT 1;' ; then
     if $success ; then
       echo "    $PGUSER($PASS) access granted as expected"
       return
@@ -422,11 +427,11 @@ function run_tests() {
   run_configuration_tests $name || ret=8
 
   if $user_login; then
-    test_postgresql $name || ret=9
+    test_postgresql || ret=9
   fi
 
   if $admin_login; then
-    DB=postgres PGUSER=postgres PASS=$ADMIN_PASS test_postgresql $name || ret=10
+    DB=postgres PGUSER=postgres PASS=$ADMIN_PASS test_postgresql admin || ret=10
   fi
   if [ $ret -eq 0 ]; then
     echo "  Success!"
@@ -631,6 +636,7 @@ $volume_options
 
   assert_login_access ${user} ${password} true || ret=4
   assert_login_access 'postgres' ${admin_password} true || ret=5
+  test_postgresql || ret 5
 
   echo "  Changing passwords"
 
@@ -662,6 +668,9 @@ $volume_options
   assert_login_access 'postgres' "NEW_${admin_password}" true || ret=10
   assert_login_access 'postgres' ${admin_password} false || ret=11
 
+  # check that we still work with the original volume
+  postgresql_cmd -At -c  "SELECT * FROM tbl;" | grep bar3 || ret=12
+
   if [ $ret -eq 0 ]; then
     echo "  Success!"
   fi

From 1567d0e5ed37ca064a0238f22676add0ea2df7aa Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 4 Jan 2024 17:06:38 +0100
Subject: [PATCH 411/509] Revert "each container in run_change_password_test
 mounts its own volume"

This reverts commit 62a0e88ae0e5f19c3dad1cb6fea3778dfa2dbf2f.

Creating a new volume directory was actually NOOP, because the variable
volume_options was not updated. What we need to get rid of SELinux
messages that this fix tried to address is to properly shut down
previous container. That will be done in the following commit.

Background:
podman's :Z modificator for volumes works the way that the latest
container run with the same volume directory mounted with :Z modificator
has access, the previous containers are kept running, but access to the
shared directory is suddenly removed. That caused the first instance of
PostgreSQL server to crash with SIGSEGV actually, while triggering some
SELinux error message during that.
---
 test/run_test | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/test/run_test b/test/run_test
index c560434c..9dc6929b 100755
--- a/test/run_test
+++ b/test/run_test
@@ -634,11 +634,6 @@ $volume_options
 
   echo "  Changing passwords"
 
-  # create separate mounting directory for second container, as selinux does
-  # not allow two containers accesing one mounting directory if mounted with
-  # Z option
-  create_volume_dir || ret=1
-
   DOCKER_ARGS="
 -e POSTGRESQL_DATABASE=${database}
 -e POSTGRESQL_USER=${user}

From 5a9f55d3d534a7e7936f61d6b3f75f971869b5ac Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Thu, 4 Jan 2024 17:12:00 +0100
Subject: [PATCH 412/509] Gracefully shut down the original container

With keeping the container running, we see SELinux error messages and
sudden crash of the PostgreSQL container. Let's properly shut down the
container before using its volume privately mounted into a different
container.

Background:
podman's :Z modificator for volumes works the way that the latest
container run with the same volume directory mounted with :Z modificator
has access, the previous containers are kept running, but access to the
shared directory is suddenly removed. That caused the first instance of
PostgreSQL server to crash with SIGSEGV actually, while triggering some
SELinux error message during that.
---
 test/run_test | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/run_test b/test/run_test
index 9dc6929b..a3269624 100755
--- a/test/run_test
+++ b/test/run_test
@@ -634,6 +634,13 @@ $volume_options
 
   echo "  Changing passwords"
 
+  echo "Kill the previous container and create a new one"
+  local cidfile=$CID_FILE_DIR/"${name}"
+  docker kill $(cat $cidfile)
+  docker rm -f $(cat $cidfile)
+  # Don't forget to remove its .cid file
+  rm $cidfile
+
   DOCKER_ARGS="
 -e POSTGRESQL_DATABASE=${database}
 -e POSTGRESQL_USER=${user}

From fd204c847af57672ce0da3ece876d71cb69865ea Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 8 Jan 2024 13:13:50 +0000
Subject: [PATCH 413/509] Bump common from `c5d8cea` to `1e82b93`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `c5d8cea` to `1e82b93`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/c5d8cea9e87098e4966d101cb7033aa5ae8a318e...1e82b93382d056dd17b90b8e0e637e5bfb9cbb88)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index c5d8cea9..1e82b933 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit c5d8cea9e87098e4966d101cb7033aa5ae8a318e
+Subproject commit 1e82b93382d056dd17b90b8e0e637e5bfb9cbb88

From 4439d3cc9b21454573813b0f9b52005e8b77b1e7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 10:57:10 +0100
Subject: [PATCH 414/509] Add support for postgresql-16

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile            |  2 +-
 specs/multispec.yml | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6cd33a76..c1fc54ab 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 12 13 14 15
+VERSIONS = 10 12 13 14 15 16
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index ac8e6e0a..7638ca1d 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -156,6 +156,15 @@ specs:
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       latest_fedora: "f38"
 
+    "16":
+      version: "16"
+      prev_version: "13"
+      short: "16"
+      prev_short: "13"
+      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
+      latest_fedora: "f39"
+
 
 matrix:
   exclude:
@@ -185,3 +194,7 @@ matrix:
         - rhel-7-x86_64
         - centos-7-x86_64
       version: "15"
+    - distros:
+        - rhel-7-x86_64
+        - centos-7-x86_64
+      version: "16"

From a847e424e51e303c3119c65827d4a0c05f7f2ed1 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 10:57:29 +0100
Subject: [PATCH 415/509] Add generated sources for Postgresql-16

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c8s                             |  85 +++
 16/Dockerfile.c9s                             |  84 +++
 16/Dockerfile.fedora                          |  84 +++
 16/Dockerfile.rhel8                           |  86 +++
 16/Dockerfile.rhel9                           |  86 +++
 16/README.md                                  |   1 +
 16/root/usr/bin/container-entrypoint          |   3 +
 16/root/usr/bin/run-postgresql                |  58 ++
 16/root/usr/bin/run-postgresql-master         |   5 +
 16/root/usr/bin/run-postgresql-slave          |  39 ++
 16/root/usr/bin/usage                         |   4 +
 16/root/usr/libexec/check-container           |  27 +
 16/root/usr/libexec/fix-permissions           |  39 ++
 .../container-scripts/postgresql/README.md    | 195 +++++++
 .../container-scripts/postgresql/common.sh    | 504 ++++++++++++++++++
 ...ustom-postgresql-replication.conf.template |   7 +
 .../openshift-custom-postgresql.conf.template |  21 +
 .../openshift-custom-recovery.conf.template   |   8 +
 .../container-scripts/postgresql/scl_enable   |   3 +
 .../postgresql/start/set_passwords.sh         |  23 +
 16/s2i/bin/assemble                           |  14 +
 16/s2i/bin/run                                |   1 +
 16/s2i/bin/usage                              |   1 +
 16/test                                       |   1 +
 24 files changed, 1379 insertions(+)
 create mode 100644 16/Dockerfile.c8s
 create mode 100644 16/Dockerfile.c9s
 create mode 100644 16/Dockerfile.fedora
 create mode 100644 16/Dockerfile.rhel8
 create mode 100644 16/Dockerfile.rhel9
 create mode 120000 16/README.md
 create mode 100755 16/root/usr/bin/container-entrypoint
 create mode 100755 16/root/usr/bin/run-postgresql
 create mode 100755 16/root/usr/bin/run-postgresql-master
 create mode 100755 16/root/usr/bin/run-postgresql-slave
 create mode 100755 16/root/usr/bin/usage
 create mode 100755 16/root/usr/libexec/check-container
 create mode 100755 16/root/usr/libexec/fix-permissions
 create mode 100644 16/root/usr/share/container-scripts/postgresql/README.md
 create mode 100644 16/root/usr/share/container-scripts/postgresql/common.sh
 create mode 100644 16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 create mode 100644 16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 create mode 100644 16/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 create mode 100644 16/root/usr/share/container-scripts/postgresql/scl_enable
 create mode 100644 16/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 create mode 100755 16/s2i/bin/assemble
 create mode 120000 16/s2i/bin/run
 create mode 100755 16/s2i/bin/usage
 create mode 120000 16/test

diff --git a/16/Dockerfile.c8s b/16/Dockerfile.c8s
new file mode 100644
index 00000000..62366632
--- /dev/null
+++ b/16/Dockerfile.c8s
@@ -0,0 +1,85 @@
+FROM quay.io/sclorg/s2i-core-c8s:c8s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-16-c8s" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-16-c8s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:16 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    yum -y reinstall tzdata && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
new file mode 100644
index 00000000..9a8d35d0
--- /dev/null
+++ b/16/Dockerfile.c9s
@@ -0,0 +1,84 @@
+FROM quay.io/sclorg/s2i-core-c9s:c9s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-16-c9s" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-16-c9s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN  { yum -y module enable postgresql:16 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
new file mode 100644
index 00000000..d1b193ca
--- /dev/null
+++ b/16/Dockerfile.fedora
@@ -0,0 +1,84 @@
+FROM quay.io/fedora/s2i-core:38
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/psql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV NAME=postgresql \
+    VERSION=0 \
+    ARCH=x86_64 \
+    \
+    POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16" \
+      com.redhat.component="$NAME" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
+      name="fedora/$NAME-16" \
+      version="0" \
+      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-16"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" pgaudit" && \
+    dnf -y module enable postgresql:16 && \
+    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    dnf clean all && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
new file mode 100644
index 00000000..27e748ea
--- /dev/null
+++ b/16/Dockerfile.rhel8
@@ -0,0 +1,86 @@
+FROM ubi8/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel8/postgresql-16" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-16" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN yum -y module enable postgresql:16 && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
new file mode 100644
index 00000000..a6d8d927
--- /dev/null
+++ b/16/Dockerfile.rhel9
@@ -0,0 +1,86 @@
+FROM ubi9/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=13 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel9/postgresql-16" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel9/postgresql-16" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN { yum -y module enable postgresql:16 || :; } && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    (yum -y reinstall tzdata || yum -y update tzdata ) && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/README.md b/16/README.md
new file mode 120000
index 00000000..d359f030
--- /dev/null
+++ b/16/README.md
@@ -0,0 +1 @@
+root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/16/root/usr/bin/container-entrypoint b/16/root/usr/bin/container-entrypoint
new file mode 100755
index 00000000..5fc44481
--- /dev/null
+++ b/16/root/usr/bin/container-entrypoint
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$@"
diff --git a/16/root/usr/bin/run-postgresql b/16/root/usr/bin/run-postgresql
new file mode 100755
index 00000000..2367e57e
--- /dev/null
+++ b/16/root/usr/bin/run-postgresql
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "${CONTAINER_SCRIPTS_PATH}/common.sh"
+
+set_pgdata
+
+process_extending_files \
+        "${APP_DATA}/src/postgresql-pre-start" \
+        "${CONTAINER_SCRIPTS_PATH}/pre-start"
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+# Is this brand new data volume?
+PG_INITIALIZED=false
+
+if [ ! -f "$PGDATA/postgresql.conf" ]; then
+  initialize_database
+  PG_INITIALIZED=:
+else
+  try_pgupgrade
+fi
+
+# Use insanely large timeout (24h) to ensure that the potential recovery has
+# enough time here to happen (unless liveness probe kills us).  Note that in
+# case of server failure this command still exists immediately.
+pg_ctl start -w --timeout 86400 -o "-h ''"
+
+# This is just a pedantic safety measure (the timeout above is unlikely to
+# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
+# returns exit_status=0 even if the server is still starting.  For more info
+# see the issue#297 and
+# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
+pg_isready
+
+if $PG_INITIALIZED ; then
+    process_extending_files \
+        "${APP_DATA}/src/postgresql-init" \
+        "${CONTAINER_SCRIPTS_PATH}/init"
+    migrate_db
+    create_users
+fi
+
+process_extending_files \
+    "${APP_DATA}/src/postgresql-start" \
+    "${CONTAINER_SCRIPTS_PATH}/start"
+
+pg_ctl stop
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/16/root/usr/bin/run-postgresql-master b/16/root/usr/bin/run-postgresql-master
new file mode 100755
index 00000000..79e7cc24
--- /dev/null
+++ b/16/root/usr/bin/run-postgresql-master
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+exec run-postgresql "$@"
diff --git a/16/root/usr/bin/run-postgresql-slave b/16/root/usr/bin/run-postgresql-slave
new file mode 100755
index 00000000..586bf5d7
--- /dev/null
+++ b/16/root/usr/bin/run-postgresql-slave
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+export ENABLE_REPLICATION=true
+
+set -eu
+export_vars=$(cgroup-limits) ; export $export_vars
+
+source "$CONTAINER_SCRIPTS_PATH"/common.sh
+
+set_pgdata
+
+function initialize_replica() {
+  echo "Initializing PostgreSQL slave ..."
+  # TODO: Validate and reuse existing data?
+  rm -rf $PGDATA
+  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
+
+  # PostgreSQL recovery configuration.
+  generate_postgresql_recovery_config
+  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
+
+# Custom OpenShift recovery configuration:
+include '${POSTGRESQL_RECOVERY_FILE}'
+EOF
+  # activate standby mode
+  touch "$PGDATA/standby.signal"
+}
+
+check_env_vars
+generate_passwd_file
+generate_postgresql_config
+
+wait_for_postgresql_master
+export MASTER_FQDN=$(postgresql_master_addr)
+initialize_replica
+
+unset_env_vars
+echo "Starting server..."
+exec postgres "$@"
diff --git a/16/root/usr/bin/usage b/16/root/usr/bin/usage
new file mode 100755
index 00000000..fa9228b5
--- /dev/null
+++ b/16/root/usr/bin/usage
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /usr/share/container-scripts/postgresql/README.md
+
diff --git a/16/root/usr/libexec/check-container b/16/root/usr/libexec/check-container
new file mode 100755
index 00000000..04a5b625
--- /dev/null
+++ b/16/root/usr/libexec/check-container
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Try whether the PostgreSQL in container accepts connections.
+#
+# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
+# has not been executed yet (the shell script is initializing the container),
+# wait for it (this script might run forever, we expect that the timeout is
+# maintained externally).
+
+test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
+
+if test x"$1" = "x--live"; then
+    # Since livenessProbe is about to detect container deadlocks, and we
+    # so far don't know about real deadlocks to be detected -- we keep
+    # liveness probe to report that container is always ready (as long as
+    # we are able to execute shell, enable collections, etc., which is
+    # good for container sanity testing anyways).
+    exit 0
+fi
+
+# Readiness check follows, the --timeout is set to "infinite" because it
+# is handled externally (readinessProbe.timeoutSeconds).
+pg_isready -q \
+    -h 127.0.0.1 \
+    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
+    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
+    --timeout 0
diff --git a/16/root/usr/libexec/fix-permissions b/16/root/usr/libexec/fix-permissions
new file mode 100755
index 00000000..f4b2f86d
--- /dev/null
+++ b/16/root/usr/libexec/fix-permissions
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+documentation="\
+Recursively fix permissions on the given directories to allow GID=0
+read/write regular files and read/write/execute directories.
+
+To run this command, you have to be in the group root=0!"
+
+uid=26
+write=w
+
+usage ()
+{
+    cat >&2 <<EOF
+$0: Error: ${1-usage error}
+
+Usage: $0 [--read-only] DIR [DIR ..]
+
+$documentation
+EOF
+    exit 1
+}
+
+while test $# -gt 0; do
+    case $1 in
+    --read-only) write= ; shift ;;
+    *) break ;;
+    esac
+done
+
+test $# -eq 0 && usage "no DIR specified"
+
+for dir; do
+    test -d "$dir" || usage "no such directory '$dir'"
+    echo >&2 "fixing permissions on '$dir' directory"
+    find "$dir" -exec chown "$uid:0" {} \;
+    find "$dir" -exec chmod "g+r$write" {} \;
+    find "$dir" -type d -exec chmod g+x {} +
+done
diff --git a/16/root/usr/share/container-scripts/postgresql/README.md b/16/root/usr/share/container-scripts/postgresql/README.md
new file mode 100644
index 00000000..3e0df720
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/README.md
@@ -0,0 +1,195 @@
+# PostgreSQL 16 SQL Database Server Container Image
+
+This container image features the PostgreSQL 16 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+
+Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
+
+## Overview
+
+This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
+
+## Usage
+
+Assuming you are utilizing the `` image, which is accessible via the `postgresql:16` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+
+```bash
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
+```
+
+This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
+
+> Note: The user `postgres` is reserved for internal usage
+
+Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
+
+In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
+
+```bash
+$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=16 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
+```
+
+If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/16/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/16/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
+
+## Environment Variables and Volumes
+
+The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
+
+**`POSTGRESQL_USER`**  
+ User name for PostgreSQL account to be created
+
+**`POSTGRESQL_PASSWORD`**  
+ Password for the user account
+
+**`POSTGRESQL_DATABASE`**  
+ Database name
+
+**`POSTGRESQL_ADMIN_PASSWORD`**  
+ Password for the `postgres` admin account (optional)
+
+Alternatively, the following options are related to migration scenario:
+
+**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
+ Hostname/IP to migrate from
+
+**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
+ Password for the remote 'postgres' admin user
+
+**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
+ Set to 'yes' to ignore sql import errors
+
+The following environment variables influence the PostgreSQL configuration file. They are all optional.
+
+**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
+ The maximum number of client connections allowed
+
+**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
+ Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
+
+**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
+Sets how much memory is dedicated to PostgreSQL to use for caching data
+
+**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
+Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
+
+**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
+ Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
+
+You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
+
+**`/var/lib/pgsql/data`**  
+ PostgreSQL database cluster directory
+
+**Notice: When mouting a directory from the host into the container, ensure that the mounted
+directory has the appropriate permissions and that the owner and group of the directory
+matches the user UID or name which is running inside the container.**
+
+Typically (unless you use `podman run -u` option) processes in container
+run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
+for example by:
+
+```bash
+$ setfacl -m u:26:-wx /your/data/dir
+$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
+```
+
+## Data Migration
+
+The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
+
+```bash
+$ podman run -d --name postgresql_database \
+    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
+    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
+    [ OPTIONAL_CONFIGURATION_VARIABLES ]
+    rhel8/postgresql-13
+```
+
+The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
+
+If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
+Migration from a different type of PostgreSQL container may likely fail.
+
+If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
+
+Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
+
+Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
+
+**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
+
+## PostgreSQL Auto-Tuning
+
+When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
+`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
+
+The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
+
+## PostgreSQL Admin Account
+
+By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
+
+## Changing Passwords
+
+As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
+admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
+
+Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
+
+
+## Extending Image
+
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `` image, available via `postgresql:16` imagestream tag in Openshift.
+
+To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
+
+```bash
+$ oc new-app postgresql:16~https://github.com/sclorg/postgresql-container.git \
+  --name new-postgresql \
+  --context-dir examples/extending-image/ \
+  -e POSTGRESQL_USER=user \
+  -e POSTGRESQL_DATABASE=db \
+  -e POSTGRESQL_PASSWORD=password
+```
+
+or via `s2i`:
+
+```
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
+```
+
+The directory passed to Openshift should contain one or more of the following directories:
+
+##### `postgresql-pre-start/`
+
+This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
+
+##### `postgresql-cfg/`
+
+Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
+
+##### `postgresql-init/`
+
+This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
+
+##### `postgresql-start/`
+
+This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
+
+---
+
+During the s2i build, all provided files are copied into the `/opt/app-root/src`
+directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
+
+## Troubleshooting
+
+Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
+
+```bash
+podman logs <container>
+```
+
+Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
+
+## Additional Resources
+
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh
new file mode 100644
index 00000000..10991b1e
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/common.sh
@@ -0,0 +1,504 @@
+# Configuration settings.
+export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
+export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
+
+# Perform auto-tuning based on the container cgroups limits (only when the
+# limits are set).
+# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
+# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
+if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
+else
+    # Use 1/4 of given memory for shared buffers
+    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
+    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
+    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
+    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
+    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
+fi
+
+export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
+
+export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
+export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
+
+postinitdb_actions=
+
+# match . files when moving userdata below
+shopt -s dotglob
+# extglob enables the !(userdata) glob pattern below.
+shopt -s extglob
+
+function usage() {
+  if [ $# == 1 ]; then
+    echo >&2 "error: $1"
+  fi
+
+  cat >&2 <<EOF
+For general container run, you must either specify the following environment
+variables:
+  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
+Or the following environment variable:
+  POSTGRESQL_ADMIN_PASSWORD
+Or both.
+
+To migrate data from different PostgreSQL container:
+  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
+  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
+And optionally:
+  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
+
+Optional settings:
+  POSTGRESQL_MAX_CONNECTIONS (default: 100)
+  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
+  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
+
+For more information see /usr/share/container-scripts/postgresql/README.md
+within the container or visit https://github.com/sclorg/postgresql-container.
+EOF
+  exit 1
+}
+
+function check_env_vars() {
+  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
+    # one var means all three must be specified
+    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
+
+    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
+    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
+    postinitdb_actions+=",simple_db"
+  fi
+
+  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",admin_pass"
+  fi
+
+  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
+       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
+    postinitdb_actions+=",migration"
+  fi
+
+  case "$postinitdb_actions" in
+    ,simple_db,admin_pass) ;;
+    ,migration|,simple_db|,admin_pass) ;;
+    *) usage ;;
+  esac
+}
+
+# Make sure env variables don't propagate to PostgreSQL process.
+function unset_env_vars() {
+  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
+}
+
+# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
+# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
+function postgresql_master_addr() {
+  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
+  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
+  # FIXME: This is for debugging (docker run)
+  if [ -v POSTGRESQL_MASTER_IP ]; then
+    endpoints=${POSTGRESQL_MASTER_IP:-}
+  fi
+  if [ -z "$endpoints" ]; then
+    >&2 echo "Failed to resolve PostgreSQL master IP address"
+    exit 3
+  fi
+  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
+}
+
+# Converts the version in format x.y or x.y.z to a number.
+version2number ()
+{
+    local old_IFS=$IFS
+    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
+    IFS='.'
+    set -- $1
+    while test $depth -ge 1; do
+        depth=$(( depth - 1 ))
+        part=${1-0} ; shift || :
+        printf "%0${width}d" "$part"
+    done
+    IFS=$old_IFS
+}
+
+# On non-intel arches, data_sync_retry = off does not work
+# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
+# Upstream changes that caused this issue:
+# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
+# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
+# Special handle of data_sync_retry should handle only in some cases.
+# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
+# Return value 0 means the hack is needed.
+function should_hack_data_sync_retry() {
+  [ "$(uname -m)" == 'x86_64' ] && return 1
+  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
+  # this matches all 12.x and versions of 10.x where we need the hack
+  [ "$version_number" -ge 100700 ] && return 0
+  # this matches all 10.x that were not matched above
+  [ "$version_number" -ge 100000 ] && return 1
+  # this matches all 9.x where need the hack
+  [ "$version_number" -ge 090612 ] && return 0
+  # all rest should be older 9.x releases
+  return 1
+}
+
+# New config is generated every time a container is created. It only contains
+# additional custom settings and is included from $PGDATA/postgresql.conf.
+function generate_postgresql_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
+      > "${POSTGRESQL_CONFIG_FILE}"
+
+  if [ "${ENABLE_REPLICATION}" == "true" ]; then
+    envsubst \
+        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
+        >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  if should_hack_data_sync_retry ; then
+    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  # For easier debugging, allow users to log to stderr (will be visible
+  # in the pod logs) using a single variable
+  # https://github.com/sclorg/postgresql-container/issues/353
+  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
+    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
+  fi
+
+  (
+  shopt -s nullglob
+  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
+    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
+  done
+  )
+}
+
+function generate_postgresql_recovery_config() {
+  envsubst \
+      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
+      > "${POSTGRESQL_RECOVERY_FILE}"
+}
+
+# Generate passwd file based on current uid
+function generate_passwd_file() {
+  export USER_ID=$(id -u)
+  export GROUP_ID=$(id -g)
+  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
+  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
+  export LD_PRELOAD=libnss_wrapper.so
+  export NSS_WRAPPER_PASSWD=${HOME}/passwd
+  export NSS_WRAPPER_GROUP=/etc/group
+}
+
+initdb_wrapper ()
+{
+  # Initialize the database cluster with utf8 support enabled by default.
+  # This might affect performance, see:
+  # http://www.postgresql.org/docs/16/static/locale.html
+  LANG=${LANG:-en_US.utf8} "$@"
+}
+
+function initialize_database() {
+  initdb_wrapper initdb
+
+  # PostgreSQL configuration.
+  cat >> "$PGDATA/postgresql.conf" <<EOF
+
+# Custom OpenShift configuration:
+include '${POSTGRESQL_CONFIG_FILE}'
+EOF
+
+  # Access control configuration.
+  # FIXME: would be nice-to-have if we could allow connections only from
+  #        specific hosts / subnet
+  cat >> "$PGDATA/pg_hba.conf" <<EOF
+
+#
+# Custom OpenShift configuration starting at this point.
+#
+
+# Allow connections from all hosts.
+host all all all md5
+
+# Allow replication connections from all hosts.
+host replication all all md5
+EOF
+}
+
+function create_users() {
+  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+    createuser "$POSTGRESQL_USER"
+    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
+  fi
+
+  if [ -v POSTGRESQL_MASTER_USER ]; then
+    createuser "$POSTGRESQL_MASTER_USER"
+    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
+    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
+  fi
+}
+
+migrate_db ()
+{
+    test "$postinitdb_actions" = ",migration" || return 0
+
+    set -o pipefail
+    # Migration path.
+    (
+        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
+            echo '\set ON_ERROR_STOP on'
+        fi
+        # initdb automatically creates 'postgres' role;  creating it again would
+        # fail the whole migration so we drop it here
+        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
+        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
+            | grep -v '^CREATE ROLE postgres;'
+    ) | psql
+    set +o pipefail
+}
+
+function set_pgdata ()
+{
+  export PGDATA=$HOME/data/userdata
+  # create a subdirectory that the user owns
+  mkdir -p "$PGDATA"
+  # backwards compatibility case, we used to put the data here,
+  # move it into our new expected location (userdata)
+  if [ -e ${HOME}/data/PG_VERSION ]; then
+    pushd "${HOME}/data"
+    # move everything except the userdata directory itself, into the userdata directory.
+    mv !(userdata) "userdata"
+    popd
+  fi
+  # ensure sane perms for postgresql startup
+  chmod 700 "$PGDATA"
+}
+
+function wait_for_postgresql_master() {
+  while true; do
+    master_fqdn=$(postgresql_master_addr)
+    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
+    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
+    else
+      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
+    fi
+    sleep 1
+  done
+}
+
+
+run_pgupgrade ()
+(
+  optimized=false
+  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
+  new_raw_version=${POSTGRESQL_VERSION//\./}
+
+  if test "$old_raw_version" = 92; then
+    old_collection=postgresql92
+  else
+    old_collection=rh-postgresql$old_raw_version
+  fi
+
+  old_pgengine=/opt/rh/$old_collection/root/usr/bin
+  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  PGDATA_new="${PGDATA}-new"
+
+  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
+             "$POSTGRESQL_PREV_VERSION" \
+             "$POSTGRESQL_VERSION"
+
+  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
+
+  # pg_upgrade writes logs to cwd, so go to the persistent storage first
+  cd "$HOME"/data
+
+  # disable this because of scl_source, 'set +u' just makes the code ugly
+  # anyways
+  set +u
+
+  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
+  # working.  The scl_source script doesn't pay attention to non-zero exit
+  # statuses, so use 'set +e'.
+  set +e
+  source scl_source enable $old_collection
+  set -e
+
+  case $POSTGRESQL_UPGRADE in
+    copy) # we accept this
+      ;;
+    hardlink)
+      optimized=:
+      ;;
+    *)
+      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
+      false
+      ;;
+  esac
+
+  # boot up data directory with old postgres once again to make sure
+  # it was shut down properly, otherwise the upgrade process fails
+  info_msg "Starting old postgresql once again for a clean shutdown..."
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  info_msg "Waiting for postgresql to be ready for shutdown again..."
+  "${old_pgengine}/pg_isready"
+  info_msg "Shutting down old postgresql cleanly..."
+  "${old_pgengine}/pg_ctl" stop
+
+  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
+  # there's some problem.
+  test ! -e "$PGDATA_new"
+
+  # initialize the database
+  info_msg "Initialize new data directory; we will migrate to that."
+  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
+  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
+    { rm -rf "$PGDATA_new" ; false ; }
+
+  upgrade_cmd=(
+      "$new_pgengine"/pg_upgrade
+      "--old-bindir=$old_pgengine"
+      "--new-bindir=$new_pgengine"
+      "--old-datadir=$PGDATA"
+      "--new-datadir=$PGDATA_new"
+  )
+
+  # Dangerous --link option, we loose $DATADIR if something goes wrong.
+  ! $optimized || upgrade_cmd+=(--link)
+
+  # User-specififed options for pg_upgrade.
+  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
+
+  # On non-intel arches the data_sync_retry set to on
+  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  # the upgrade
+  info_msg "Starting the pg_upgrade process."
+
+  # Once we stop support for PostgreSQL 9.4, we don't need
+  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
+  # that we don't need to fiddle with unix_socket_director{y,ies} option.
+  REDHAT_PGUPGRADE_FROM_RHEL=1 \
+  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
+
+  # Move the important configuration and remove old data.  This is highly
+  # careless, but we can't do more for this over-automatized process.
+  info_msg "Swap the old and new PGDATA and cleanup."
+  mv "$PGDATA"/*.conf "$PGDATA_new"
+  rm -rf "$PGDATA"
+  mv "$PGDATA_new" "$PGDATA"
+
+  # Get back the option we changed above
+  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
+
+  info_msg "Upgrade DONE."
+)
+
+
+# Run right after container startup, when the data volume is already initialized
+# (not initialized by this container run) and thus there exists a chance that
+# the data was generated by incompatible PostgreSQL major version.
+try_pgupgrade ()
+{
+  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
+
+  # This file always exists.
+  test -f "$versionfile"
+  version=$(cat "$versionfile")
+
+  # If we don't support pg_upgrade, skip.
+  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
+
+  if test "$POSTGRESQL_VERSION" = "$version"; then
+      # No need to call pg_upgrade.
+
+      # Mistakenly requests upgrade?  If not, just start the DB.
+      test -z "${POSTGRESQL_UPGRADE-}" && return 0
+
+      # Make _sure_ we have this safety-belt here, otherwise our users would
+      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
+      # re-deployment cases when upgrade is not needed.  Setting such
+      # unfortunate default could mean that pg_upgrade might (after some user
+      # mistake) migrate (or even destruct, especially with --link) the old data
+      # directory with limited rollback options, if any.
+      echo >&2
+      echo >&2 "== WARNING!! =="
+      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
+      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
+      echo >&2 "made some mistake, keeping the variable set you might"
+      echo >&2 "risk a data loss in future!"
+      echo >&2 "==============="
+      echo >&2
+
+      # Exit here, but allow _really explicit_ foot-shot.
+      ${POSTGRESQL_UPGRADE_FORCE-false}
+      return 0
+  fi
+
+  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
+  # server major version;  this might mean that user either (a) mistakenly
+  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
+  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
+
+  if test -z "${POSTGRESQL_UPGRADE-}"; then
+    echo >&2 "Incompatible data directory.  This container image provides"
+    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
+    echo >&2 "version '$version'."
+    echo >&2
+    echo >&2 "This image supports automatic data directory upgrade from"
+    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
+    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
+    # We could wait for postgresql startup failure (there's no risk of data dir
+    # corruption), but fail rather early.
+    false
+  fi
+
+  # We support pg_upgrade process only from previous version of this container
+  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
+  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
+    echo >&2 "With this container image you can only upgrade from data directory"
+    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
+    false
+  fi
+
+  run_pgupgrade
+}
+
+# get_matched_files PATTERN DIR [DIR ...]
+# ---------------------------------------
+# Print all basenames for files matching PATTERN in DIRs.
+get_matched_files ()
+{
+  local pattern=$1 dir
+  shift
+  for dir; do
+    test -d "$dir" || continue
+    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
+  done
+}
+
+# process_extending_files DIR [DIR ...]
+# -------------------------------------
+# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
+# more then one DIR, source only the first occurrence (first found wins).
+process_extending_files()
+{
+  local filename dir
+  while read filename ; do
+    for dir in "$@"; do
+      local file="$dir/$filename"
+      if test -f "$file"; then
+        echo "=> sourcing $file ..."
+        source "$file"
+        set -e # ensure that users don't mistakenly change this
+        break
+      fi
+    done
+  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
+}
diff --git a/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
new file mode 100644
index 00000000..d133e511
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
@@ -0,0 +1,7 @@
+# required on master for replication
+wal_level = hot_standby         # minimal, archive, hot_standby, or logical
+max_wal_senders = 6             # max number of walsender processes
+wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
+
+# required on replicas for replication
+hot_standby = on
diff --git a/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
new file mode 100644
index 00000000..3c2bc7f3
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
@@ -0,0 +1,21 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+# Listen on all interfaces.
+listen_addresses = '*'
+
+# Determines the maximum number of concurrent connections to the database server. Default: 100
+max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
+
+# Allow each connection to use a prepared transaction
+max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
+
+# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
+shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
+
+# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
+effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/16/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/16/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
new file mode 100644
index 00000000..58d8e336
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
@@ -0,0 +1,8 @@
+#
+# Custom OpenShift configuration.
+#
+# NOTE: This file is rewritten every time the container is started!
+#       Changes to this file will be overwritten.
+#
+
+primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/16/root/usr/share/container-scripts/postgresql/scl_enable b/16/root/usr/share/container-scripts/postgresql/scl_enable
new file mode 100644
index 00000000..1d967f9b
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/scl_enable
@@ -0,0 +1,3 @@
+# This will make scl collection binaries work out of box.
+unset BASH_ENV PROMPT_COMMAND ENV
+source scl_source enable $ENABLED_COLLECTIONS
diff --git a/16/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/16/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
new file mode 100644
index 00000000..60d70e36
--- /dev/null
+++ b/16/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
+
+if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
+_psql --set=username="$POSTGRESQL_USER" \
+      --set=password="$POSTGRESQL_PASSWORD" \
+<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
+fi
+
+if [ -v POSTGRESQL_MASTER_USER ]; then
+_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
+      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
+<<'EOF'
+ALTER USER :"masteruser" WITH REPLICATION;
+ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
+EOF
+fi
+
+if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
+_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
+<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
+fi
diff --git a/16/s2i/bin/assemble b/16/s2i/bin/assemble
new file mode 100755
index 00000000..6ed8f7aa
--- /dev/null
+++ b/16/s2i/bin/assemble
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+shopt -s dotglob
+echo "---> Installing application source ..."
+
+
+mv /tmp/src/* ./
+
+# Fix source directory permissions
+/usr/libexec/fix-permissions --read-only ./
diff --git a/16/s2i/bin/run b/16/s2i/bin/run
new file mode 120000
index 00000000..a7f4076b
--- /dev/null
+++ b/16/s2i/bin/run
@@ -0,0 +1 @@
+/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/16/s2i/bin/usage b/16/s2i/bin/usage
new file mode 100755
index 00000000..9f413123
--- /dev/null
+++ b/16/s2i/bin/usage
@@ -0,0 +1 @@
+groff -t -man -ETascii /help.1
diff --git a/16/test b/16/test
new file mode 120000
index 00000000..419df4f9
--- /dev/null
+++ b/16/test
@@ -0,0 +1 @@
+../test
\ No newline at end of file

From dd3096733b0920e448e32afec1e1ffc24030eedc Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 11:10:42 +0100
Subject: [PATCH 416/509] Add support for pushing PSQL-16 images to quay.io

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index d4073d47..21da1781 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -28,6 +28,20 @@ jobs:
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 15
+          - dockerfile: "16/Dockerfile.c9s"
+            registry_namespace: "sclorg"
+            tag: "c9s"
+            image_name: "postgresql-16-c9s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            docker_context: 16
+          - dockerfile: "16/Dockerfile.c8s"
+            registry_namespace: "sclorg"
+            tag: "c8s"
+            image_name: "postgresql-16-c8s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            docker_context: 16
           - dockerfile: "10/Dockerfile.c8s"
             registry_namespace: "sclorg"
             tag: "c8s"
@@ -84,10 +98,16 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-15"
             docker_context: 15
-
+          - dockerfile: "16/Dockerfile.fedora"
+            registry_namespace: "fedora"
+            tag: "16"
+            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
+            image_name: "postgresql-16"
+            docker_context: 16
     steps:
       - name: check if Dockerfile is c9s, then Build multi arch image and push to quay.io registry
-        if: matrix.dockerfile == '13/Dockerfile.c9s' || matrix.dockerfile == '15/Dockerfile.c9s'
+        if: matrix.dockerfile == '13/Dockerfile.c9s' || matrix.dockerfile == '15/Dockerfile.c9s' || matrix.dockerfile == '16/Dockerfile.c9s'
         uses: sclorg/build-and-push-action@v4
         with:
           registry: "quay.io"
@@ -101,7 +121,7 @@ jobs:
           archs: amd64, s390x, ppc64le, arm64
           
       - name: Check if Dockerfile is not c9s, then Build and push to quay.io registry
-        if: matrix.dockerfile != '13/Dockerfile.c9s' && matrix.dockerfile != '15/Dockerfile.c9s'
+        if: matrix.dockerfile != '13/Dockerfile.c9s' && matrix.dockerfile != '15/Dockerfile.c9s' && matrix.dockerfile != '16/Dockerfile.c9s'
         uses: sclorg/build-and-push-action@v4
         with:
           registry: "quay.io"

From a391ec4ed61014c250b4d94e8079145299c57563 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 10:56:06 +0100
Subject: [PATCH 417/509] Enable testing postgresql-16 in GitHub Action
 container-tests and openshift-test pipeline

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 2 +-
 .github/workflows/openshift-tests.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 6124bab6..701feb53 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -54,7 +54,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13", "14", "15" ]
+        version: [ "10", "11", "12", "13", "14", "15", "16" ]
         os_test: [ "fedora", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
         test_case: [ "container" ]
 
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index cbd9c2d7..32e4a841 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -34,7 +34,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13", "15" ]
+        version: [ "10", "11", "12", "13", "15", "16" ]
         os_test: [ "rhel7", "rhel8", "rhel9"]
         test_case: [ "openshift-3", "openshift-4" ]
         exclude:

From d855c5622ee5379d4d95f3d1477a1aa54b3d50de Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 14:37:17 +0100
Subject: [PATCH 418/509] Fix Dockerfile.fedora for support Fedora 39.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile.fedora | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 932ede86..806621e1 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,4 +1,8 @@
+{% if spec.version == "16" %}
+FROM quay.io/fedora/s2i-core:39
+{% else %}
 FROM quay.io/fedora/s2i-core:38
+{% endif %}
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -44,12 +48,18 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
+{% if spec.version == "16" %}
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
+{% else %}
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+{% endif %}
     INSTALL_PKGS+="findutils xz" && \
 {% if spec.version not in ["9.6", "10", "11"] %}
     INSTALL_PKGS+=" pgaudit" && \
 {% endif %}
+{% if spec.version not in ["16"] %}
     dnf -y module enable postgresql:{{ spec.version }} && \
+{% endif %}
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \

From 1fb430addca722f17a99c3074f66ca0718eac14c Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 9 Jan 2024 14:41:27 +0100
Subject: [PATCH 419/509] Add 16/Dockerfile.fedora generated from source

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.fedora | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index d1b193ca..8fbde42a 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:38
+FROM quay.io/fedora/s2i-core:39
 
 # PostgreSQL image for OpenShift.
 # Volumes:
@@ -44,10 +44,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
     INSTALL_PKGS+="findutils xz" && \
     INSTALL_PKGS+=" pgaudit" && \
-    dnf -y module enable postgresql:16 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \

From 5fa4da9c64afffa0d29b3e4e4ca5a6cad541d5c7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 19 Jan 2024 10:12:48 +0100
Subject: [PATCH 420/509] Use prev_version for PgSQL 16 as 15

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 specs/multispec.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 7638ca1d..2631a700 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -158,9 +158,9 @@ specs:
 
     "16":
       version: "16"
-      prev_version: "13"
+      prev_version: "15"
       short: "16"
-      prev_short: "13"
+      prev_short: "15"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       latest_fedora: "f39"

From d271a00a8b48234a4b343f193f838d0b01af160d Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 19 Jan 2024 10:13:54 +0100
Subject: [PATCH 421/509] Add dist-gen generated content

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c8s    | 2 +-
 16/Dockerfile.c9s    | 2 +-
 16/Dockerfile.fedora | 2 +-
 16/Dockerfile.rhel8  | 2 +-
 16/Dockerfile.rhel9  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/16/Dockerfile.c8s b/16/Dockerfile.c8s
index 62366632..8322aa49 100644
--- a/16/Dockerfile.c8s
+++ b/16/Dockerfile.c8s
@@ -11,7 +11,7 @@ FROM quay.io/sclorg/s2i-core-c8s:c8s
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=15 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
index 9a8d35d0..21e159cb 100644
--- a/16/Dockerfile.c9s
+++ b/16/Dockerfile.c9s
@@ -11,7 +11,7 @@ FROM quay.io/sclorg/s2i-core-c9s:c9s
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=15 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index 8fbde42a..74baba19 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -15,7 +15,7 @@ ENV NAME=postgresql \
     ARCH=x86_64 \
     \
     POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=15 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
index 27e748ea..eb806267 100644
--- a/16/Dockerfile.rhel8
+++ b/16/Dockerfile.rhel8
@@ -11,7 +11,7 @@ FROM ubi8/s2i-core
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=15 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index a6d8d927..c1dddd52 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -11,7 +11,7 @@ FROM ubi9/s2i-core
 #                           PostgreSQL administrative account
 
 ENV POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=13 \
+    POSTGRESQL_PREV_VERSION=15 \
     HOME=/var/lib/pgsql \
     PGUSER=postgres \
     APP_DATA=/opt/app-root

From 141b474fad19f25b74569d935f4f825baf9928dd Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 12 Feb 2024 09:29:44 +0100
Subject: [PATCH 422/509] Modify Fedora Dockerfile to install proper pgaudit
 package

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile.fedora | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 806621e1..ad8e03ef 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -54,9 +54,12 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
 {% endif %}
     INSTALL_PKGS+="findutils xz" && \
-{% if spec.version not in ["9.6", "10", "11"] %}
+{% if spec.version not in ["9.6", "10", "11", "16"] %}
     INSTALL_PKGS+=" pgaudit" && \
 {% endif %}
+{% if spec.version == "16" %}
+    INSTALL_PKGS+=" postgresql16-pgaudit" && \
+{% endif %}
 {% if spec.version not in ["16"] %}
     dnf -y module enable postgresql:{{ spec.version }} && \
 {% endif %}

From d32d825fa8a228a739986792d1f5ffa38b238fc6 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 12 Feb 2024 09:30:10 +0100
Subject: [PATCH 423/509] Add generated sources for Fedora

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.fedora | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index 74baba19..0a17e06b 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -46,7 +46,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
     INSTALL_PKGS+="findutils xz" && \
-    INSTALL_PKGS+=" pgaudit" && \
+    INSTALL_PKGS+=" postgresql16-pgaudit" && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \

From 1a91d2fd3842a166fff398ce732de7790d55881e Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Wed, 13 Mar 2024 12:57:35 +0100
Subject: [PATCH 424/509] Remove dead link from this repo (#552)

* Do not use dead symlink in repository.
Instead of them create symlink in Dockerfile's directly.
* Add generated files
---
 10/Dockerfile.c8s     | 5 +++++
 10/Dockerfile.rhel7   | 5 +++++
 10/Dockerfile.rhel8   | 5 +++++
 10/s2i/bin/run        | 1 -
 12/Dockerfile.c8s     | 5 +++++
 12/Dockerfile.fedora  | 5 +++++
 12/Dockerfile.rhel7   | 5 +++++
 12/Dockerfile.rhel8   | 5 +++++
 12/s2i/bin/run        | 1 -
 13/Dockerfile.c8s     | 5 +++++
 13/Dockerfile.c9s     | 5 +++++
 13/Dockerfile.fedora  | 5 +++++
 13/Dockerfile.rhel7   | 5 +++++
 13/Dockerfile.rhel8   | 5 +++++
 13/Dockerfile.rhel9   | 5 +++++
 13/s2i/bin/run        | 1 -
 14/Dockerfile.fedora  | 5 +++++
 14/s2i/bin/run        | 1 -
 15/Dockerfile.c8s     | 5 +++++
 15/Dockerfile.c9s     | 5 +++++
 15/Dockerfile.fedora  | 5 +++++
 15/Dockerfile.rhel8   | 5 +++++
 15/Dockerfile.rhel9   | 5 +++++
 15/s2i/bin/run        | 1 -
 16/Dockerfile.c8s     | 5 +++++
 16/Dockerfile.c9s     | 5 +++++
 16/Dockerfile.fedora  | 5 +++++
 16/Dockerfile.rhel8   | 5 +++++
 16/Dockerfile.rhel9   | 5 +++++
 16/s2i/bin/run        | 1 -
 manifest.yml          | 4 ----
 src/Dockerfile        | 5 +++++
 src/Dockerfile.fedora | 5 +++++
 src/s2i/bin/run       | 1 -
 34 files changed, 130 insertions(+), 11 deletions(-)
 delete mode 120000 10/s2i/bin/run
 delete mode 120000 12/s2i/bin/run
 delete mode 120000 13/s2i/bin/run
 delete mode 120000 14/s2i/bin/run
 delete mode 120000 15/s2i/bin/run
 delete mode 120000 16/s2i/bin/run
 delete mode 120000 src/s2i/bin/run

diff --git a/10/Dockerfile.c8s b/10/Dockerfile.c8s
index 9aff4d3e..9692cd70 100644
--- a/10/Dockerfile.c8s
+++ b/10/Dockerfile.c8s
@@ -60,6 +60,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
index acb94437..02d8cd1a 100644
--- a/10/Dockerfile.rhel7
+++ b/10/Dockerfile.rhel7
@@ -63,6 +63,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8
index e188c7e5..236e488b 100644
--- a/10/Dockerfile.rhel8
+++ b/10/Dockerfile.rhel8
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/10/s2i/bin/run b/10/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/10/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/12/Dockerfile.c8s b/12/Dockerfile.c8s
index 946cd278..08da9e1b 100644
--- a/12/Dockerfile.c8s
+++ b/12/Dockerfile.c8s
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index f596e65f..f5ce3586 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
index 75e7b688..8d62190b 100644
--- a/12/Dockerfile.rhel7
+++ b/12/Dockerfile.rhel7
@@ -64,6 +64,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index e83fd4fe..9c8aa1e5 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/12/s2i/bin/run b/12/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/12/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/13/Dockerfile.c8s b/13/Dockerfile.c8s
index 60130b92..49a2f789 100644
--- a/13/Dockerfile.c8s
+++ b/13/Dockerfile.c8s
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
index 65bdb635..a868fb13 100644
--- a/13/Dockerfile.c9s
+++ b/13/Dockerfile.c9s
@@ -60,6 +60,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index 7031f394..aa7f63a6 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
index 93939459..03d27cc0 100644
--- a/13/Dockerfile.rhel7
+++ b/13/Dockerfile.rhel7
@@ -64,6 +64,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index 986c1e67..38e3b951 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index 50b91331..063ec1f4 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/13/s2i/bin/run b/13/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/13/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora
index 6cc888ee..a1ece9c2 100644
--- a/14/Dockerfile.fedora
+++ b/14/Dockerfile.fedora
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/14/s2i/bin/run b/14/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/14/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/15/Dockerfile.c8s b/15/Dockerfile.c8s
index 9dbb7809..8579ca0c 100644
--- a/15/Dockerfile.c8s
+++ b/15/Dockerfile.c8s
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
index 7d8fcba8..378ea8f3 100644
--- a/15/Dockerfile.c9s
+++ b/15/Dockerfile.c9s
@@ -60,6 +60,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index 762cfbb1..560e3bd6 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index b68f9781..76a568c0 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 51d003e1..c464d0b5 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/15/s2i/bin/run b/15/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/15/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/16/Dockerfile.c8s b/16/Dockerfile.c8s
index 8322aa49..0498931d 100644
--- a/16/Dockerfile.c8s
+++ b/16/Dockerfile.c8s
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
index 21e159cb..91b16096 100644
--- a/16/Dockerfile.c9s
+++ b/16/Dockerfile.c9s
@@ -60,6 +60,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index 0a17e06b..9c0bb6f0 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -61,6 +61,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
index eb806267..70be99fe 100644
--- a/16/Dockerfile.rhel8
+++ b/16/Dockerfile.rhel8
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index c1dddd52..bc1009b5 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -62,6 +62,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/16/s2i/bin/run b/16/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/16/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file
diff --git a/manifest.yml b/manifest.yml
index 44fb951f..fbbe1996 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -101,7 +101,3 @@ SYMLINK_RULES:
 
   - src: ../test
     dest: test
-
-  - src: /usr/bin/run-postgresql
-    dest: s2i/bin/run
-    check_symlink: false  # Disable check of dead symlinks
diff --git a/src/Dockerfile b/src/Dockerfile
index a63d00ea..7f84f3b6 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -96,6 +96,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 {% if spec.prod != "rhel8" and spec.prod != "rhel9" and config.os.id != "fedora" and spec.prod != "c8s" and spec.prod != "c9s" %}
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index ad8e03ef..48accf6f 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -77,6 +77,11 @@ ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
 COPY root /
 COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
 VOLUME ["/var/lib/pgsql/data"]
 
 # S2I permission fixes
diff --git a/src/s2i/bin/run b/src/s2i/bin/run
deleted file mode 120000
index a7f4076b..00000000
--- a/src/s2i/bin/run
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/run-postgresql
\ No newline at end of file

From eb4a90264d9c489c5e2da8b2a5202db11afa6028 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 18 Mar 2024 15:35:53 +0100
Subject: [PATCH 425/509] Bump common from `1e82b93` to `ddaeff0` (#555)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `1e82b93` to `ddaeff0`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/1e82b93382d056dd17b90b8e0e637e5bfb9cbb88...ddaeff0dcfa4ddc2799df32d4a74fd8422328339)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 1e82b933..ddaeff0d 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1e82b93382d056dd17b90b8e0e637e5bfb9cbb88
+Subproject commit ddaeff0dcfa4ddc2799df32d4a74fd8422328339

From 41da4dbb1f6450c882d458cfba006d3c6f7fb4cd Mon Sep 17 00:00:00 2001
From: Zuzana Miklankova <zmiklank@redhat.com>
Date: Wed, 20 Mar 2024 09:54:39 +0100
Subject: [PATCH 426/509] github actions: add concurrency, stop in progress
 actions

---
 .github/workflows/container-tests.yml | 3 +++
 .github/workflows/openshift-tests.yml | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 701feb53..29018d2f 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -6,6 +6,9 @@ jobs:
   distgen-check:
     name: "Check distgen generated files"
     runs-on: ubuntu-20.04
+    concurrency:
+      group: container-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
+      cancel-in-progress: true
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]'))
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 32e4a841..537ba035 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -6,6 +6,9 @@ jobs:
   distgen-check:
     name: "Check distgen generated files"
     runs-on: ubuntu-20.04
+    concurrency:
+      group: ocp-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
+      cancel-in-progress: true
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))

From af7b6274b8fad547d1e48fdb229a63a0d11c431f Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 21 Mar 2024 08:39:18 +0100
Subject: [PATCH 427/509] Remove testing postgresql-container on OpenShift 3
 (#556)

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/openshift-tests.yml |   7 +-
 test/run-openshift                    |   1 -
 test/run-openshift-local-cluster      | 468 --------------------------
 3 files changed, 1 insertion(+), 475 deletions(-)
 delete mode 120000 test/run-openshift
 delete mode 100755 test/run-openshift-local-cluster

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 537ba035..1f6560ff 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -39,12 +39,7 @@ jobs:
       matrix:
         version: [ "10", "11", "12", "13", "15", "16" ]
         os_test: [ "rhel7", "rhel8", "rhel9"]
-        test_case: [ "openshift-3", "openshift-4" ]
-        exclude:
-          - test_case: "openshift-3"
-            os_test: "rhel8"
-          - test_case: "openshift-3"
-            os_test: "rhel9"
+        test_case: [ "openshift-4" ]
 
     if: |
       github.event.issue.pull_request
diff --git a/test/run-openshift b/test/run-openshift
deleted file mode 120000
index d84575f7..00000000
--- a/test/run-openshift
+++ /dev/null
@@ -1 +0,0 @@
-run-openshift-local-cluster
\ No newline at end of file
diff --git a/test/run-openshift-local-cluster b/test/run-openshift-local-cluster
deleted file mode 100755
index 35a0f09e..00000000
--- a/test/run-openshift-local-cluster
+++ /dev/null
@@ -1,468 +0,0 @@
-#!/bin/bash
-#
-# Test the Postgresql image in OpenShift.
-#
-# IMAGE_NAME specifies a name of the candidate image used for testing.
-# The image has to be available before this script is executed.
-#
-
-THISDIR=$(dirname ${BASH_SOURCE[0]})
-TEMPLATES="$THISDIR/examples"
-REMOTE_TEMPLATES="https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates"
-
-source "$THISDIR"/pg-test-lib.sh
-source "$THISDIR"/test-lib-openshift.sh
-source "$THISDIR"/test-lib-postgresql.sh
-
-set -exo nounset
-
-trap ct_os_cleanup EXIT SIGINT
-
-ct_os_check_compulsory_vars
-
-# Populate template variables if not set already
-if [ -z "${EPHEMERAL_TEMPLATES:-}" ]; then
-  EPHEMERAL_TEMPLATES="
-$REMOTE_TEMPLATES/postgresql-ephemeral-template.json
-$TEMPLATES/postgresql-ephemeral-template.json"
-fi
-
-if [ -z "${PERSISTENT_TEMPLATES:-}" ]; then
-  PERSISTENT_TEMPLATES="
-$REMOTE_TEMPLATES/postgresql-persistent-template.json
-$TEMPLATES/postgresql-persistent-template.json"
-fi
-
-function assert_cmd_fails() {
-  if eval "$@" &>/dev/null; then
-    echo " FAIL"
-    return 1
-  fi
-  echo " PASS"
-  return 0
-}
-
-function insert_postgresql_data() {
-  local image_name=$1 ; shift
-  local user=$1 ; shift
-  local pass=$1 ; shift
-  local database=$1 ; shift
-  local pod_ip=$1; shift
-
-  : "Inserting data into the database"
-  local cmd="PGPASSWORD=$pass psql -c \"CREATE TABLE testing (a integer); INSERT INTO testing VALUES (42);\""
-  local cmd_args="-h $pod_ip -U $user -d $database"
-  docker run --rm "$image_name" bash -c "$cmd $cmd_args"
-}
-
-function check_postgresql_data() {
-  local image_name=$1 ; shift
-  local user=$1 ; shift
-  local pass=$1 ; shift
-  local database=$1 ; shift
-  local pod_ip=$1; shift
-  local timeout=${1:-60}
-  SECONDS=0
-
-  : "Checking whether the data can be accessed"
-  local cmd="PGPASSWORD=$pass psql -c \"select * from testing;\""
-  local cmd_args="-h $pod_ip -U $user -d $database"
-  while true ; do
-    result=$(docker run --rm "$image_name" bash -c "$cmd -At $cmd_args")
-    if [ "$result" = "42" ]; then
-      echo " PASS"
-      return 0
-    fi
-    echo -n "."
-    [ $SECONDS -gt $timeout ] && break
-    sleep 3
-  done
-  echo " FAIL"
-  return 1
-}
-
-
-function check_postgresql_os_service_connection() {
-  local util_image_name=$1 ; shift
-  local service_name=$1 ; shift
-  local user=$1 ; shift
-  local pass=$1 ; shift
-  local database=$1 ; shift
-  local timeout=${1:-60} ; shift || :
-  local pod_ip=$(ct_os_get_service_ip ${service_name})
-
-  : "  Service ${service_name} check ..."
-
-  local cmd="PGPASSWORD=${pass} pg_isready -t 15 -h ${pod_ip} -U ${user} -d ${database}"
-  local expected_value='accepting connections'
-  local output
-  local ret
-  SECONDS=0
-
-  echo -n "Waiting for ${service_name} service becoming ready ..."
-  while true ; do
-    output=$(docker run --rm ${util_image_name} bash -c "${cmd}" || :)
-    echo "${output}" | grep -qe "${expected_value}" && ret=0 || ret=1
-    if [ ${ret} -eq 0 ] ; then
-      echo " PASS"
-      return 0
-    fi
-    echo -n "."
-    [ ${SECONDS} -gt ${timeout} ] && break
-    sleep 3
-  done
-  echo " FAIL"
-  return 1
-}
-
-function test_postgresql_pure_image() {
-  local image_name=$1
-  local image_name_no_namespace=${image_name##*/}
-  local service_name="${image_name_no_namespace%%:*}-testing"
-
-  ct_os_new_project
-  # Create a specific imagestream tag for the image so that oc cannot use anything else
-  ct_os_upload_image "v3" "${image_name}" "$image_name_no_namespace"
-
-  ct_os_deploy_pure_image "$image_name_no_namespace" \
-                          --name "${service_name}" \
-                          --env POSTGRESQL_ADMIN_PASSWORD=test
-
-  ct_os_wait_pod_ready "${service_name}" 60
-  check_postgresql_os_service_connection "${image_name}" "${service_name}" postgres test postgres
-
-  ct_os_delete_project
-}
-
-function test_postgresql_template() {
-  local image_name=$1; shift
-  local template=$1
-  local image_name_no_namespace=${image_name##*/}
-  local service_name="${image_name_no_namespace%%:*}-testing"
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "${image_name}" "postgresql:$VERSION"
-
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="${service_name}" \
-                              POSTGRESQL_USER=testu \
-                              POSTGRESQL_PASSWORD=testp \
-                              POSTGRESQL_DATABASE=testdb
-
-  ct_os_wait_pod_ready "${service_name}" 60
-  check_postgresql_os_service_connection "${image_name}" "${service_name}" testu testp testdb
-
-  ct_os_delete_project
-}
-
-function test_postgresql_update() {
-  local image_name=$1; shift
-  local template=$1
-  local image_name_no_registry=${image_name##*/}
-  local service_name="${image_name_no_registry%%:*}-testing"
-  local user="testu" pass="testp" db="testdb"
-  local registry="" old_image="" pod_ip=""
-  local version released=:
-
-  old_image=$(get_image_id "$VERSION:remote")
-
-  for version in $NOT_RELEASED_VERSIONS; do
-    case $image_name in
-      *$version*)
-        released=false
-        break
-        ;;
-    esac
-  done
-
-  if docker pull "$old_image" 2>/dev/null; then
-    # Check if we do not have a stale unreleased versions list
-    # Fail only on rhel, on centos the image is likely already released
-    $released || [ "$OS" = "centos7" ]
-  elif $released; then
-    false "image '$old_image' should already be available"
-  else
-    return # not yet released image, skip
-  fi
-
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "$old_image" "postgresql:$VERSION"
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="$service_name" \
-                              POSTGRESQL_USER="$user" \
-                              POSTGRESQL_PASSWORD="$pass" \
-                              POSTGRESQL_DATABASE="$db"
-
-  ct_os_wait_pod_ready "${service_name}" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  pod_ip=$(ct_os_get_service_ip "$service_name")
-  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-
-  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
-  : "Waiting for a few seconds while the pods get restarted"
-  sleep 5
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-  ct_os_delete_project
-}
-
-function test_postgresql_replication() {
-  local image_name=$1
-  local image_name_no_namespace=${image_name##*/}
-  local master_service_name="${image_name_no_namespace%%:*}-master"
-  local slave_service_name="${image_name_no_namespace%%:*}-slave"
-  local istag="postgresql:$VERSION"
-  local user="testu" pass="testp" db="testdb"
-  local master_name="" master_ip="" slave_name="" slave_ip=""
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "${image_name}" "$istag"
-
-  ct_os_deploy_template_image "$TEMPLATES/replica/postgresql_replica.json" \
-                              NAMESPACE="$(oc project -q)" \
-                              IMAGESTREAMTAG="$istag" \
-                              POSTGRESQL_MASTER_SERVICE_NAME="$master_service_name" \
-                              POSTGRESQL_SLAVE_SERVICE_NAME="$slave_service_name" \
-                              POSTGRESQL_USER=testu \
-                              POSTGRESQL_PASSWORD=testp \
-                              POSTGRESQL_DATABASE=testdb
-
-  ct_os_wait_pod_ready "$master_service_name" 60
-  ct_os_wait_pod_ready "$slave_service_name" 60
-
-  # Force unused rc removal as we do not need rollbacks during testing
-  oc patch "dc/$master_service_name" -p '{"spec":{"revisionHistoryLimit":0}}'
-  oc patch "dc/$slave_service_name" -p '{"spec":{"revisionHistoryLimit":0}}'
-
-  master_name=$(ct_os_get_pod_name "$master_service_name")
-  slave_name=$(ct_os_get_pod_name "$slave_service_name")
-  master_ip=$(ct_os_get_pod_ip "$master_name")
-  slave_ip=$(ct_os_get_pod_ip "$slave_name")
-  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$master_ip"
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
-
-  : "Changing POSTGRESQL_PASSWORD for master and slave"
-  pass=redhat
-  oc set env "dc/$master_service_name" -e POSTGRESQL_PASSWORD="$pass"
-  oc set env "dc/$slave_service_name" -e POSTGRESQL_PASSWORD="$pass"
-  ct_os_wait_pod_ready "$master_service_name-2" 60
-  ct_os_wait_pod_ready "$slave_service_name-2" 60
-  # We need to get new pod names and IPs
-  master_name=$(ct_os_get_pod_name "$master_service_name")
-  slave_name=$(ct_os_get_pod_name "$slave_service_name")
-  master_ip=$(ct_os_get_pod_ip "$master_name")
-  slave_ip=$(ct_os_get_pod_ip "$slave_name")
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$master_ip"
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
-
-  : "Redeploying slave node"
-  oc rollout latest "$slave_service_name"
-  ct_os_wait_pod_ready "$slave_service_name-3" 60
-  slave_name=$(ct_os_get_pod_name "$slave_service_name")
-  slave_ip=$(ct_os_get_pod_ip "$slave_name")
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
-
-  : "Scaling slaves to 2"
-  oc scale --replicas 2 "dc/$slave_service_name"
-  ct_os_wait_rc_ready "$slave_service_name" 60
-  slave_name=$(ct_os_get_pod_name "$slave_service_name")
-  for slave in $slave_name; do
-    ct_os_wait_pod_ready "$slave" 60
-    slave_ip=$(ct_os_get_pod_ip "$slave")
-    check_postgresql_data "$image_name" "$user" "$pass" "$db" "$slave_ip"
-  done
-
-  ct_os_delete_project
-}
-
-function test_postgresql_persistent_redeploy() {
-  local image_name=$1; shift
-  local template=$1
-  local image_name_no_namespace=${image_name##*/}
-  local service_name="${image_name_no_namespace%%:*}-testing"
-  local user="testu" pass="testp" db="testdb"
-  local registry="" old_image="" pod_ip=""
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
-
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="$service_name" \
-                              POSTGRESQL_USER="$user" \
-                              POSTGRESQL_PASSWORD="$pass" \
-                              POSTGRESQL_DATABASE="$db"
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
-
-  pod_ip=$(ct_os_get_service_ip "$service_name")
-  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-
-  : "Redeploying pod"
-  oc rollout latest "$service_name"
-  : "Waiting for a few seconds while the pod gets restarted"
-  sleep 5
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  : "This should succeed"
-  check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip" 0
-  ct_os_delete_project
-}
-
-function test_postgresql_ephemeral_redeploy() {
-  local image_name=$1; shift
-  local template=$1
-  local image_name_no_namespace=${image_name##*/}
-  local service_name="${image_name_no_namespace%%:*}-testing"
-  local user="testu" pass="testp" db="testdb"
-  local registry="" old_image="" pod_ip=""
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
-
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="$service_name" \
-                              POSTGRESQL_USER="$user" \
-                              POSTGRESQL_PASSWORD="$pass" \
-                              POSTGRESQL_DATABASE="$db"
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
-
-  pod_ip=$(ct_os_get_service_ip "$service_name")
-  insert_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip"
-
-  : "Redeploying pod"
-  oc rollout latest "$service_name"
-  : "Waiting for a few seconds while the pod gets restarted"
-  sleep 5
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" "$user" "$pass" "$db"
-
-  : "This should fail"
-  assert_cmd_fails check_postgresql_data "$image_name" "$user" "$pass" "$db" "$pod_ip" 0
-  ct_os_delete_project
-}
-
-function test_postgresql_configmap_start() {
-  local image_name=$1; shift
-  local template="$TEMPLATES/postgresql-ephemeral-template.json"
-  local image_name_no_namespace=${image_name##*/}
-  local service_name="${image_name_no_namespace%%:*}-testing"
-  local user="testu" pass="testp" db="testdb"
-  local registry="" old_image="" pod_ip="" tmpdir=""
-  local test_string=""
-
-  ct_os_new_project
-  ct_os_upload_image "v3" "$image_name" "postgresql:$VERSION"
-
-  ct_os_deploy_template_image "$template" \
-                              NAMESPACE="$(oc project -q)" \
-                              POSTGRESQL_VERSION="$VERSION" \
-                              DATABASE_SERVICE_NAME="$service_name" \
-                              POSTGRESQL_USER="$user" \
-                              POSTGRESQL_PASSWORD="$pass" \
-                              POSTGRESQL_DATABASE="$db"
-
-  ct_os_wait_pod_ready "$service_name" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
-
-  # Create a simple configMap with a start.sh script
-  tmpdir=$(mktemp -d)
-  test_string="Start is working"
-  echo "echo $test_string" >> "$tmpdir/start.sh"
-  oc create configmap postgresql-start --from-file="$tmpdir/start.sh"
-  oc set volume "dc/$service_name" --add -t configmap --configmap-name=postgresql-start -m /opt/app-root/src/postgresql-start --name postgresql-start
-
-  # Wait for redeploy
-  ct_os_wait_pod_ready "$service_name-2" 60
-  check_postgresql_os_service_connection "$image_name" "$service_name" testu testp testdb
-
-  # Check logs for the test string
-  oc logs "$(ct_os_get_pod_name "$service_name")" | grep "$test_string"
-
-  ct_os_delete_project
-}
-
-function run_ephemeral_tests() {
-  local image_name=$1
-  for template in $EPHEMERAL_TEMPLATES; do
-    test_postgresql_ephemeral_redeploy "$image_name" "$template"
-    test_postgresql_template "$image_name" "$template"
-  done
-}
-
-function run_persistent_tests() {
-  local image_name=$1
-  for template in $PERSISTENT_TEMPLATES; do
-    test_postgresql_persistent_redeploy "$image_name" "$template"
-    test_postgresql_update "$image_name" "$template"
-  done
-}
-
-ct_os_cluster_up
-# Print oc logs on failure
-ct_os_enable_print_logs
-
-test_postgresql_pure_image "$IMAGE_NAME"
-test_postgresql_replication "$IMAGE_NAME"
-run_ephemeral_tests "$IMAGE_NAME"
-run_persistent_tests "$IMAGE_NAME"
-test_postgresql_configmap_start "$IMAGE_NAME"
-
-# test with the just built image and an integrated template
-echo "Running test_postgresql_integration with ${IMAGE_NAME}"
-test_postgresql_integration "${IMAGE_NAME}"
-
-# test with a released image and an integrated template
-PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-$(ct_get_public_image_name "${OS}" "${BASE_IMAGE_NAME}" "${VERSION}")}
-
-# Try pulling the image first to see if it is accessible
-if docker pull "${PUBLIC_IMAGE_NAME}"; then
-  echo "Running test_postgresql_integration with ${PUBLIC_IMAGE_NAME}"
-  test_postgresql_integration "${PUBLIC_IMAGE_NAME}"
-else
-  echo "Warning: ${PUBLIC_IMAGE_NAME} could not be downloaded via 'docker'"
-  # ignore possible failure of this test for centos images
-  [ "${OS}" == "rhel7" ] && false "ERROR: Failed to pull image"
-fi
-
-# Check the imagestream
-echo "Running test_mariadb_imagestream"
-test_postgresql_imagestream
-
-function run_latest_imagestreams_test() {
-  local result=1
-  # Switch to root directory of a container
-  echo "Testing the latest version in imagestreams"
-  pushd "${THISDIR}/.." >/dev/null || return 1
-  ct_check_latest_imagestreams
-  result=$?
-  popd >/dev/null || return 1
-  return $result
-}
-
-run_latest_imagestreams_test
-
-OS_TESTSUITE_RESULT=0
-
-ct_os_cluster_down
-
-# vim: set tabstop=2:shiftwidth=2:expandtab:
-

From ac721aef18e4a99bb4f82a8704fe42a0a89fa8dc Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 21 Mar 2024 12:46:46 +0100
Subject: [PATCH 428/509] Add missing imagestreams for Postgresql 16 (#553)

* Add missing imagestreams for Postgresql 16
* Add workaround for postgresql-16 that is not released yet.
Let's test integration with postgresql-15 that is already released
* Skipping tests because imagestreams does not exist yet
* Fix container name in devel_images file

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/postgresql-centos.json       | 36 ++++++++++++
 imagestreams/postgresql-rhel-aarch64.json | 72 +++++++++++++++++++++++
 imagestreams/postgresql-rhel.json         | 36 ++++++++++++
 test/test-lib-postgresql.sh               | 18 ++++++
 4 files changed, 162 insertions(+)

diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index ce9a2990..db1ea9d9 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -26,6 +26,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/sclorg/postgresql-16-c9s:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "15-el9",
         "annotations": {
@@ -62,6 +80,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/sclorg/postgresql-16-c8s:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "15-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index db5121c2..6c8821a3 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -26,6 +26,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "15-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "15"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el9",
         "annotations": {
@@ -44,6 +80,42 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
+      {
+        "name": "15-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "15"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 4e698ced..45d44452 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -23,6 +23,24 @@
           "name": "15-el8"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "15-el9",
         "annotations": {
@@ -41,6 +59,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "15-el8",
         "annotations": {
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 998c6814..d8e4089e 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -18,6 +18,15 @@ function test_postgresql_integration() {
     namespace_image="rhscl/postgresql-${VERSION}-rhel7"
   else
     namespace_image="${OS}/postgresql-${VERSION}"
+    # Check if the current version is already GA
+    # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
+    local devel_file="/root/sclorg-tmt-plans/devel_images"
+    if [ -f "${devel_file}" ]; then
+      if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
+        echo "This version is currently developed, so skipping this test."
+        return
+      fi
+    fi
   fi
   TEMPLATES="postgresql-ephemeral-template.json
   postgresql-persistent-template.json"
@@ -42,6 +51,15 @@ function test_postgresql_imagestream() {
   elif [ "${OS}" == "rhel9" ]; then
     tag="-el9"
   fi
+  # Check if the current version is already GA
+  # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
+  local devel_file="/root/sclorg-tmt-plans/devel_images"
+  if [ -f "${devel_file}" ]; then
+    if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
+      echo "This version is currently developed, so skipping this test."
+      return
+    fi
+  fi
   TEMPLATES="postgresql-ephemeral-template.json
   postgresql-persistent-template.json"
   for template in $TEMPLATES; do

From f2162a07f49d0a8f38c2271eb0ee43a08d8acb73 Mon Sep 17 00:00:00 2001
From: Filip Janus <fjanus@redhat.com>
Date: Wed, 13 Mar 2024 14:42:08 +0100
Subject: [PATCH 429/509] .pid is present during postgresql-server run. It
 should be removed with server stop. in some circumstances, it persists after
 the container shuts down. If it happens, this check should ensure the state
 is correct before the upgrade. It should remove the redundant file.

---
 10/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 12/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 13/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 14/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 15/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 16/root/usr/share/container-scripts/postgresql/common.sh  | 5 +++++
 src/root/usr/share/container-scripts/postgresql/common.sh | 5 +++++
 7 files changed, 35 insertions(+)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 29e91dd8..1e23f839 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index e917c39d..6a3c6f2b 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 5b166305..9da493a2 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 53ed955f..4a81bf4f 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 0428cd0e..35d7cc37 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh
index 10991b1e..cd80bbd5 100644
--- a/16/root/usr/share/container-scripts/postgresql/common.sh
+++ b/16/root/usr/share/container-scripts/postgresql/common.sh
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index f725ba21..df39caed 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,6 +297,11 @@ function wait_for_postgresql_master() {
 
 run_pgupgrade ()
 (
+  # Remove .pid file if the file persists after ugly shut down
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+    rm -rf "$PGDATA/postmaster.pid"
+  fi
+
   optimized=false
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}

From 1f953fdcabfa5929abd6aaa01b5a9d98c5de377d Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 26 Mar 2024 07:58:51 +0100
Subject: [PATCH 430/509] Bump common from `ddaeff0` to `0a46964` (#557)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `ddaeff0` to `0a46964`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/ddaeff0dcfa4ddc2799df32d4a74fd8422328339...0a469648af07ea2d9926ceab7cf8b766dde3a13f)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index ddaeff0d..0a469648 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit ddaeff0dcfa4ddc2799df32d4a74fd8422328339
+Subproject commit 0a469648af07ea2d9926ceab7cf8b766dde3a13f

From 3836b381f8f91c1897b9cb12bccfa74e4d283fdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zuzana=20Mikl=C3=A1nkov=C3=A1?= <zmiklank@redhat.com>
Date: Wed, 27 Mar 2024 15:34:09 +0100
Subject: [PATCH 431/509] add YAML config for imagestreams generator (#549)

* add github action for checking if imagestreams are properly regenerated
* add YAML config for imagestreams generator
* add imagestrem files generated by imagestream generator
* imagestreams.yaml, use >- for description in yaml Previously used '>' was appending newline at the end of string.
* make imagestream check as part of openshift tests
---
 .github/workflows/openshift-tests.yml     |  31 +++--
 imagestreams/imagestreams.yaml            |  40 ++++++
 imagestreams/postgresql-centos.json       |  85 ++++++-------
 imagestreams/postgresql-rhel-aarch64.json |  85 ++++++-------
 imagestreams/postgresql-rhel.json         | 146 +++++++++-------------
 5 files changed, 201 insertions(+), 186 deletions(-)
 create mode 100644 imagestreams/imagestreams.yaml

diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 1f6560ff..e63daf1b 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -3,16 +3,24 @@ on:
     types:
       - created
 jobs:
-  distgen-check:
-    name: "Check distgen generated files"
-    runs-on: ubuntu-20.04
-    concurrency:
-      group: ocp-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
-      cancel-in-progress: true
+  check-imagestreams:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      statuses: write
     if: |
       github.event.issue.pull_request
       && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    steps:
+      - uses: sclorg/ci-scripts/ocp-stream-generator@master
+        with:
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
+
+  distgen-check:
+    name: "Check distgen generated files"
+    runs-on: ubuntu-latest
+    needs: check-imagestreams
     steps:
       - name: Checkout repo
         uses: actions/checkout@v4
@@ -31,20 +39,17 @@ jobs:
 
   openshift-tests:
     needs: distgen-check
-    # This job only runs for '[test-all]' or '[test-openshift] pull request comments by owner, member
     name: "${{ matrix.test_case }} tests: ${{ matrix.version }} - ${{ matrix.os_test }}"
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
+    concurrency:
+      group: ocp-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
+      cancel-in-progress: true
     strategy:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "15", "16" ]
         os_test: [ "rhel7", "rhel8", "rhel9"]
         test_case: [ "openshift-4" ]
-
-    if: |
-      github.event.issue.pull_request
-      && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]'))
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     steps:
       - uses: sclorg/tfaga-wrapper@main
         with:
diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
new file mode 100644
index 00000000..60d9c120
--- /dev/null
+++ b/imagestreams/imagestreams.yaml
@@ -0,0 +1,40 @@
+---
+- name: postgresql
+  pretty_name: PostgreSQL
+  sample_repo: ""
+  category: database
+  description: >-
+    Provides a PostgreSQL APP_VERSION database on DISTRO_NAME.
+    For more information about using this database image,
+    including OpenShift considerations,
+    see https://github.com/sclorg/postgresql-container/blob/master/README.md.
+  imagestream_files:
+  - filename: postgresql-centos.json
+    latest: "15-el9"
+    distros:
+      - name: CentOS Stream 8
+        app_versions: [10, 12, 13, 15, 16]
+
+      - name: CentOS Stream 9
+        app_versions: [13, 15, 16]
+
+  - filename: postgresql-rhel.json
+    latest: "15-el8"
+    distros:
+      - name: RHEL 7
+        app_versions: [10, 12, 13]
+
+      - name: RHEL 8
+        app_versions: [10, 12, 13, 15, 16]
+
+      - name: RHEL 9
+        app_versions: [13, 15, 16]
+
+  - filename: postgresql-rhel-aarch64.json
+    latest: "13-el8"
+    distros:
+      - name: RHEL 8
+        app_versions: [10, 12, 13, 15, 16]
+
+      - name: RHEL 9
+        app_versions: [13, 15, 16]
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index db1ea9d9..6ced4653 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -10,71 +10,72 @@
   "spec": {
     "tags": [
       {
-        "name": "latest",
+        "name": "10-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/display-name": "PostgreSQL 10 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on CentOS Stream. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL 10 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql"
+          "tags": "database,postgresql",
+          "version": "10"
         },
         "from": {
-          "kind": "ImageStreamTag",
-          "name": "15-el9"
+          "kind": "DockerImage",
+          "name": "quay.io/sclorg/postgresql-10-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "16-el9",
+        "name": "12-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 9)",
+          "openshift.io/display-name": "PostgreSQL 12 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "16"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-16-c9s:latest"
+          "name": "quay.io/sclorg/postgresql-12-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "15-el9",
+        "name": "13-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 9)",
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-15-c9s:latest"
+          "name": "quay.io/sclorg/postgresql-13-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el9",
+        "name": "15-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 9)",
+          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-13-c9s:latest"
+          "name": "quay.io/sclorg/postgresql-15-c8s:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -99,72 +100,72 @@
         }
       },
       {
-        "name": "15-el8",
+        "name": "13-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-15-c8s:latest"
+          "name": "quay.io/sclorg/postgresql-13-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el8",
+        "name": "15-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 8)",
+          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-13-c8s:latest"
+          "name": "quay.io/sclorg/postgresql-15-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el8",
+        "name": "16-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (CentOS Stream 8)",
+          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "16"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-12-c8s:latest"
+          "name": "quay.io/sclorg/postgresql-16-c9s:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el8",
+        "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (CentOS Stream 8)",
+          "openshift.io/display-name": "PostgreSQL 15 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "15"
         },
         "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-10-c8s:latest"
+          "kind": "ImageStreamTag",
+          "name": "15-el9"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 6c8821a3..b6859cf9 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -10,71 +10,72 @@
   "spec": {
     "tags": [
       {
-        "name": "latest",
+        "name": "10-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql"
+          "tags": "database,postgresql",
+          "version": "10"
         },
         "from": {
-          "kind": "ImageStreamTag",
-          "name": "13-el8"
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "16-el9",
+        "name": "12-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "16"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "15-el9",
+        "name": "13-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-13:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el9",
+        "name": "15-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -99,72 +100,72 @@
         }
       },
       {
-        "name": "15-el8",
+        "name": "13-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el8",
+        "name": "15-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-13:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el8",
+        "name": "16-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "16"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el8",
+        "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "13"
         },
         "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+          "kind": "ImageStreamTag",
+          "name": "13-el8"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 45d44452..a7df5856 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -10,104 +10,90 @@
   "spec": {
     "tags": [
       {
-        "name": "latest",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Latest)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL database on RHEL. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of PostgreSQL available on OpenShift, including major version updates.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql"
-        },
-        "from": {
-          "kind": "ImageStreamTag",
-          "name": "15-el8"
-        }
-      },
-      {
-        "name": "16-el9",
+        "name": "10-el7",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "16"
+          "version": "10"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "15-el9",
+        "name": "12-el7",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "16-el8",
+        "name": "13-el7",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "16"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
+          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "15-el8",
+        "name": "10-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "10"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "13-el9",
+        "name": "12-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
+          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "12"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
         },
         "referencePolicy": {
           "type": "Local"
@@ -132,126 +118,108 @@
         }
       },
       {
-        "name": "13-el7",
+        "name": "15-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-15:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el8",
+        "name": "16-el8",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
+          "version": "16"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-12:latest"
+          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "12-el7",
+        "name": "13-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
+          "openshift.io/display-name": "PostgreSQL 13 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 13 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 12",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "12"
+          "version": "13"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-13:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el8",
+        "name": "15-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
+          "openshift.io/display-name": "PostgreSQL 15 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "15"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-15:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10-el7",
+        "name": "16-el9",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "10"
+          "version": "16"
         },
         "from": {
           "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
         },
         "referencePolicy": {
           "type": "Local"
         }
       },
       {
-        "name": "10",
+        "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL (Ephemeral) 10",
+          "openshift.io/display-name": "PostgreSQL 15 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
-          "tags": "database,postgresql,hidden",
-          "version": "10"
+          "tags": "database,postgresql",
+          "version": "15"
         },
         "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
+          "kind": "ImageStreamTag",
+          "name": "15-el8"
         },
         "referencePolicy": {
           "type": "Local"

From 4ab79fef02a8d95f95aee21970a5ed11bf572454 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 2 Apr 2024 12:06:56 +0200
Subject: [PATCH 432/509] Bump common from `0a46964` to `1f774c8` (#559)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `0a46964` to `1f774c8`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/0a469648af07ea2d9926ceab7cf8b766dde3a13f...1f774c89d3015d857cd683342a18e7f2117a75b5)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 0a469648..1f774c89 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0a469648af07ea2d9926ceab7cf8b766dde3a13f
+Subproject commit 1f774c89d3015d857cd683342a18e7f2117a75b5

From 1894a6ce064452b3999523e0080e969990e2d889 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 4 Apr 2024 09:41:43 +0200
Subject: [PATCH 433/509] remove imagestreams which are not GA (#560)

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/imagestreams.yaml            | 12 ++++----
 imagestreams/postgresql-centos.json       | 36 -----------------------
 imagestreams/postgresql-rhel-aarch64.json | 36 -----------------------
 imagestreams/postgresql-rhel.json         | 36 -----------------------
 test/test-lib-postgresql.sh               |  9 ++++++
 5 files changed, 15 insertions(+), 114 deletions(-)

diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index 60d9c120..c3d89d7a 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -13,10 +13,10 @@
     latest: "15-el9"
     distros:
       - name: CentOS Stream 8
-        app_versions: [10, 12, 13, 15, 16]
+        app_versions: [10, 12, 13, 15]
 
       - name: CentOS Stream 9
-        app_versions: [13, 15, 16]
+        app_versions: [13, 15]
 
   - filename: postgresql-rhel.json
     latest: "15-el8"
@@ -25,16 +25,16 @@
         app_versions: [10, 12, 13]
 
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15, 16]
+        app_versions: [10, 12, 13, 15]
 
       - name: RHEL 9
-        app_versions: [13, 15, 16]
+        app_versions: [13, 15]
 
   - filename: postgresql-rhel-aarch64.json
     latest: "13-el8"
     distros:
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15, 16]
+        app_versions: [10, 12, 13, 15]
 
       - name: RHEL 9
-        app_versions: [13, 15, 16]
+        app_versions: [13, 15]
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 6ced4653..1ce1bde2 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -81,24 +81,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-16-c8s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "13-el9",
         "annotations": {
@@ -135,24 +117,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el9",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 9)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-16-c9s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "latest",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index b6859cf9..874df97c 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -81,24 +81,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "13-el9",
         "annotations": {
@@ -135,24 +117,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el9",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "latest",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index a7df5856..b890a851 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -135,24 +135,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "13-el9",
         "annotations": {
@@ -189,24 +171,6 @@
           "type": "Local"
         }
       },
-      {
-        "name": "16-el9",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "16"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "latest",
         "annotations": {
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index d8e4089e..dfb79a1a 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -69,6 +69,15 @@ function test_postgresql_imagestream() {
 
 
 function run_latest_imagestreams_test() {
+  # Check if the current version is already GA
+  # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
+  local devel_file="/root/sclorg-tmt-plans/devel_images"
+  if [ -f "${devel_file}" ]; then
+    if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
+      echo "This version is currently developed, so skipping this test."
+      return
+    fi
+  fi
   local result=1
   # Switch to root directory of a container
   echo "Testing the latest version in imagestreams"

From d0cecca7766a6150489228dc2670143bf73a3997 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 9 Apr 2024 12:29:11 +0200
Subject: [PATCH 434/509] Bump common from `1f774c8` to `a957816` (#561)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `1f774c8` to `a957816`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/1f774c89d3015d857cd683342a18e7f2117a75b5...a9578162cd92ed8047e1936130813ed907470546)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 1f774c89..a9578162 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1f774c89d3015d857cd683342a18e7f2117a75b5
+Subproject commit a9578162cd92ed8047e1936130813ed907470546

From 566e2481b21be42d924da528902fa4cc831e22fe Mon Sep 17 00:00:00 2001
From: Mauricio Magnani <msmagnanijr@gmail.com>
Date: Thu, 9 May 2024 18:48:32 -0300
Subject: [PATCH 435/509] chore: fix readme typo

---
 examples/enable-ssl/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/enable-ssl/README.md b/examples/enable-ssl/README.md
index fdbd0077..4d9e6204 100644
--- a/examples/enable-ssl/README.md
+++ b/examples/enable-ssl/README.md
@@ -23,8 +23,8 @@ oc new-app --name psql-ssl postgresql:13-el7~https://github.com/sclorg/postgresq
 
 ```bash
 openssl genrsa -out tls.key 2048
-openssl req -new -x509 -key tls.key -out tls.cert
-oc create secret tls db-ssl-keys --key tls.key --cert tls.cert
+openssl req -new -x509 -key tls.key -out tls.crt
+oc create secret tls db-ssl-keys --key tls.key --cert tls.crt
 ```
 
 3. Bind your secrets into postgres deploymentConfig:

From 8fc800980f8882fba75639a98f7ba46be2959a31 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 14 May 2024 08:19:13 +0200
Subject: [PATCH 436/509] Add imagestream 16 for RHEL9 (#565)

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/imagestreams.yaml            | 12 +++++------
 imagestreams/postgresql-centos.json       | 26 +++++++++++++++++++----
 imagestreams/postgresql-rhel-aarch64.json | 26 +++++++++++++++++++----
 imagestreams/postgresql-rhel.json         | 26 +++++++++++++++++++----
 4 files changed, 72 insertions(+), 18 deletions(-)

diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index c3d89d7a..230c3739 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -10,16 +10,16 @@
     see https://github.com/sclorg/postgresql-container/blob/master/README.md.
   imagestream_files:
   - filename: postgresql-centos.json
-    latest: "15-el9"
+    latest: "16-el9"
     distros:
       - name: CentOS Stream 8
         app_versions: [10, 12, 13, 15]
 
       - name: CentOS Stream 9
-        app_versions: [13, 15]
+        app_versions: [13, 15, 16]
 
   - filename: postgresql-rhel.json
-    latest: "15-el8"
+    latest: "16-el9"
     distros:
       - name: RHEL 7
         app_versions: [10, 12, 13]
@@ -28,13 +28,13 @@
         app_versions: [10, 12, 13, 15]
 
       - name: RHEL 9
-        app_versions: [13, 15]
+        app_versions: [13, 15, 16]
 
   - filename: postgresql-rhel-aarch64.json
-    latest: "13-el8"
+    latest: "16-el9"
     distros:
       - name: RHEL 8
         app_versions: [10, 12, 13, 15]
 
       - name: RHEL 9
-        app_versions: [13, 15]
+        app_versions: [13, 15, 16]
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 1ce1bde2..35eaeed7 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -117,19 +117,37 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/sclorg/postgresql-16-c9s:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (Latest)",
+          "openshift.io/display-name": "PostgreSQL 16 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "16"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "15-el9"
+          "name": "16-el9"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 874df97c..27792266 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -117,19 +117,37 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (Latest)",
+          "openshift.io/display-name": "PostgreSQL 16 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "13"
+          "version": "16"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "13-el8"
+          "name": "16-el9"
         },
         "referencePolicy": {
           "type": "Local"
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index b890a851..72c249ed 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -171,19 +171,37 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el9",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 9)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel9/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (Latest)",
+          "openshift.io/display-name": "PostgreSQL 16 (Latest)",
           "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
+          "description": "Provides a PostgreSQL 16 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n",
           "iconClass": "icon-postgresql",
           "tags": "database,postgresql",
-          "version": "15"
+          "version": "16"
         },
         "from": {
           "kind": "ImageStreamTag",
-          "name": "15-el8"
+          "name": "16-el9"
         },
         "referencePolicy": {
           "type": "Local"

From 214bfdbad539c3583384f5fa7d90bfbbb020d372 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 4 Jun 2024 12:49:21 +0200
Subject: [PATCH 437/509] Bump common from `a957816` to `8c310e1` (#569)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `a957816` to `8c310e1`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/a9578162cd92ed8047e1936130813ed907470546...8c310e11d4fd5b942a2dd722e7dca5748ed80393)


Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index a9578162..8c310e11 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a9578162cd92ed8047e1936130813ed907470546
+Subproject commit 8c310e11d4fd5b942a2dd722e7dca5748ed80393

From d4dd9a02865cb05ffae95b1a8842b87606118ca5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zuzana=20Mikl=C3=A1nkov=C3=A1?= <zmiklank@redhat.com>
Date: Tue, 4 Jun 2024 12:49:50 +0200
Subject: [PATCH 438/509] deprecate c8s images, as EOL for c8s is 31th of May
 2024 (#567)

---
 .github/workflows/build-and-push.yml  | 42 +++----------
 .github/workflows/container-tests.yml |  6 +-
 10/Dockerfile.c8s                     | 89 --------------------------
 12/Dockerfile.c8s                     | 90 ---------------------------
 13/Dockerfile.c8s                     | 90 ---------------------------
 15/Dockerfile.c8s                     | 90 ---------------------------
 16/Dockerfile.c8s                     | 90 ---------------------------
 imagestreams/imagestreams.yaml        |  3 -
 imagestreams/postgresql-centos.json   | 72 ---------------------
 manifest.yml                          |  3 -
 specs/multispec.yml                   | 63 ++++++++-----------
 src/Dockerfile                        |  4 +-
 12 files changed, 37 insertions(+), 605 deletions(-)
 delete mode 100644 10/Dockerfile.c8s
 delete mode 100644 12/Dockerfile.c8s
 delete mode 100644 13/Dockerfile.c8s
 delete mode 100644 15/Dockerfile.c8s
 delete mode 100644 16/Dockerfile.c8s

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 21da1781..37cf19f3 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -21,6 +21,7 @@ jobs:
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 13
+
           - dockerfile: "15/Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
@@ -28,6 +29,7 @@ jobs:
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 15
+
           - dockerfile: "16/Dockerfile.c9s"
             registry_namespace: "sclorg"
             tag: "c9s"
@@ -35,41 +37,7 @@ jobs:
             quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 16
-          - dockerfile: "16/Dockerfile.c8s"
-            registry_namespace: "sclorg"
-            tag: "c8s"
-            image_name: "postgresql-16-c8s"
-            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-            docker_context: 16
-          - dockerfile: "10/Dockerfile.c8s"
-            registry_namespace: "sclorg"
-            tag: "c8s"
-            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-            image_name: "postgresql-10-c8s"
-            docker_context: 10
-          - dockerfile: "12/Dockerfile.c8s"
-            registry_namespace: "sclorg"
-            tag: "c8s"
-            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-            image_name: "postgresql-12-c8s"
-            docker_context: 12
-          - dockerfile: "13/Dockerfile.c8s"
-            registry_namespace: "sclorg"
-            tag: "c8s"
-            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-            image_name: "postgresql-13-c8s"
-            docker_context: 13
-          - dockerfile: "15/Dockerfile.c8s"
-            registry_namespace: "sclorg"
-            tag: "c8s"
-            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
-            image_name: "postgresql-15-c8s"
-            docker_context: 15
+
           - dockerfile: "12/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "12"
@@ -77,6 +45,7 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-12"
             docker_context: 12
+
           - dockerfile: "13/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "13"
@@ -84,6 +53,7 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-13"
             docker_context: 13
+
           - dockerfile: "14/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "14"
@@ -91,6 +61,7 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-14"
             docker_context: 14
+
           - dockerfile: "15/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "15"
@@ -98,6 +69,7 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-15"
             docker_context: 15
+
           - dockerfile: "16/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "16"
diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 29018d2f..791d6712 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -5,7 +5,7 @@ on:
 jobs:
   distgen-check:
     name: "Check distgen generated files"
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
     concurrency:
       group: container-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
       cancel-in-progress: true
@@ -52,13 +52,13 @@ jobs:
           fi
   container-tests:
     needs: distgen-check
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
     name: "Container tests: ${{ matrix.version }} - ${{ matrix.os_test }}"
     strategy:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "14", "15", "16" ]
-        os_test: [ "fedora", "rhel7", "rhel8", "rhel9", "c9s", "c8s"]
+        os_test: [ "fedora", "rhel7", "rhel8", "rhel9", "c9s" ]
         test_case: [ "container" ]
 
     if: |
diff --git a/10/Dockerfile.c8s b/10/Dockerfile.c8s
deleted file mode 100644
index 9692cd70..00000000
--- a/10/Dockerfile.c8s
+++ /dev/null
@@ -1,89 +0,0 @@
-FROM quay.io/sclorg/s2i-core-c8s:c8s
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=10 \
-    POSTGRESQL_PREV_VERSION=9.6 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 10" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql10,postgresql-10" \
-      io.openshift.s2i.assemble-user="26" \
-      name="sclorg/postgresql-10-c8s" \
-      com.redhat.component="postgresql-10-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-10-c8s" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:10 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/12/Dockerfile.c8s b/12/Dockerfile.c8s
deleted file mode 100644
index 08da9e1b..00000000
--- a/12/Dockerfile.c8s
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM quay.io/sclorg/s2i-core-c8s:c8s
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=12 \
-    POSTGRESQL_PREV_VERSION=10 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 12" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql12,postgresql-12" \
-      io.openshift.s2i.assemble-user="26" \
-      name="sclorg/postgresql-12-c8s" \
-      com.redhat.component="postgresql-12-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-12-c8s" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:12 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/13/Dockerfile.c8s b/13/Dockerfile.c8s
deleted file mode 100644
index 49a2f789..00000000
--- a/13/Dockerfile.c8s
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM quay.io/sclorg/s2i-core-c8s:c8s
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=13 \
-    POSTGRESQL_PREV_VERSION=12 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 13" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql13,postgresql-13" \
-      io.openshift.s2i.assemble-user="26" \
-      name="sclorg/postgresql-13-c8s" \
-      com.redhat.component="postgresql-13-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-13-c8s" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:13 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/15/Dockerfile.c8s b/15/Dockerfile.c8s
deleted file mode 100644
index 8579ca0c..00000000
--- a/15/Dockerfile.c8s
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM quay.io/sclorg/s2i-core-c8s:c8s
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=15 \
-    POSTGRESQL_PREV_VERSION=13 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 15" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql15,postgresql-15" \
-      io.openshift.s2i.assemble-user="26" \
-      name="sclorg/postgresql-15-c8s" \
-      com.redhat.component="postgresql-15-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-15-c8s" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:15 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/16/Dockerfile.c8s b/16/Dockerfile.c8s
deleted file mode 100644
index 0498931d..00000000
--- a/16/Dockerfile.c8s
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM quay.io/sclorg/s2i-core-c8s:c8s
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=16 \
-    POSTGRESQL_PREV_VERSION=15 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 16" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
-      io.openshift.s2i.assemble-user="26" \
-      name="sclorg/postgresql-16-c8s" \
-      com.redhat.component="postgresql-16-container" \
-      version="1" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-16-c8s" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:16 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y reinstall tzdata && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index 230c3739..cdb71108 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -12,9 +12,6 @@
   - filename: postgresql-centos.json
     latest: "16-el9"
     distros:
-      - name: CentOS Stream 8
-        app_versions: [10, 12, 13, 15]
-
       - name: CentOS Stream 9
         app_versions: [13, 15, 16]
 
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index 35eaeed7..bc139daf 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -9,78 +9,6 @@
   },
   "spec": {
     "tags": [
-      {
-        "name": "10-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (CentOS Stream 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-10-c8s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (CentOS Stream 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-12-c8s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "13-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (CentOS Stream 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "13"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-13-c8s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "15-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 15 (CentOS Stream 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 15 database on CentOS Stream 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "15"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "quay.io/sclorg/postgresql-15-c8s:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "13-el9",
         "annotations": {
diff --git a/manifest.yml b/manifest.yml
index fbbe1996..e038f2b2 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -38,9 +38,6 @@ DISTGEN_MULTI_RULES:
   - src: src/Dockerfile
     dest: Dockerfile.c9s
 
-  - src: src/Dockerfile
-    dest: Dockerfile.c8s
-
   - src: src/Dockerfile.fedora
     dest: Dockerfile.fedora
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 2631a700..b08de54b 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -89,20 +89,6 @@ specs:
       pkgs: "postgresql-server postgresql-contrib"
       environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
-    c8s:
-      distros:
-        - centos-stream-8-x86_64
-      s2i_base: quay.io/sclorg/s2i-core-c8s:c8s
-      org: "sclorg"
-      prod: "c8s"
-      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
-      redhat_component: "postgresql-{{ spec.short }}-container"
-      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "postgresql-server postgresql-contrib"
-      environment_setup: >-4
-          yum -y module enable postgresql:{{ spec.version }} && \
-      post_install: >-4
-          yum -y reinstall tzdata && \
 
   version:
     "10":
@@ -167,34 +153,35 @@ specs:
 
 
 matrix:
-  exclude:
-    - distros:
+  include:
+    - version: "10"
+      distros:
+        - rhel-7-x86_64
+        - rhel-8-x86_64
+    - version: "12"
+      distros:
+        - rhel-7-x86_64
+        - rhel-8-x86_64
+        - fedora-38-x86_64
+    - version: "13"
+      distros:
+        - rhel-7-x86_64
+        - rhel-8-x86_64
         - rhel-9-x86_64
-        - centos-7-x86_64
         - centos-stream-9-x86_64
         - fedora-38-x86_64
-      version: "10"
-    - distros:
+    - version: "14"
+      distros:
+        - fedora-38-x86_64
+    - version: "15"
+      distros:
+        - rhel-8-x86_64
         - rhel-9-x86_64
-        - centos-7-x86_64
         - centos-stream-9-x86_64
-      version: "12"
-    - distros:
-        - centos-7-x86_64
-      version: "13"
-    - distros:
-        - centos-7-x86_64
-        - rhel-7-x86_64
-        - centos-stream-8-x86_64
+        - fedora-38-x86_64
+    - version: "16"
+      distros:
         - rhel-8-x86_64
-        - centos-stream-9-x86_64
         - rhel-9-x86_64
-      version: "14"
-    - distros:
-        - rhel-7-x86_64
-        - centos-7-x86_64
-      version: "15"
-    - distros:
-        - rhel-7-x86_64
-        - centos-7-x86_64
-      version: "16"
+        - centos-stream-9-x86_64
+        - fedora-38-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 7f84f3b6..dd934cd4 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -73,7 +73,7 @@ RUN {{ spec.environment_setup }}
 {% if spec.version not in ["9.6", "10", "11"] %}
     {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
-    {% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' or spec.prod == 'c8s' %}
+    {% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     {% endif %}
 {% endif %}
@@ -101,7 +101,7 @@ COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 # /usr/libexec/s2i/run no such file or directory
 RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
 
-{% if spec.prod != "rhel8" and spec.prod != "rhel9" and config.os.id != "fedora" and spec.prod != "c8s" and spec.prod != "c9s" %}
+{% if spec.prod != "rhel8" and spec.prod != "rhel9" and config.os.id != "fedora" and spec.prod != "c9s" %}
 # When bash is started non-interactively, to run a shell script, for example it
 # looks for this variable and source the content of this file. This will enable
 # the SCL for all scripts without need to do 'scl enable'.

From fbba2c47cd0698c999d9c3380f3ce38b7cd8a991 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Tue, 11 Jun 2024 13:27:50 +0200
Subject: [PATCH 439/509] Add file show_all_imagestreams.py from
 container-common-scripts (#572)

* Add file show_all_imagestreams.py from container-common-scripts
* Add Postgresql 16 imagestreams for RHEL8

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/imagestreams.yaml            |  4 ++--
 imagestreams/postgresql-rhel-aarch64.json | 18 ++++++++++++++++++
 imagestreams/postgresql-rhel.json         | 18 ++++++++++++++++++
 test/show_all_imagestreams.py             |  1 +
 4 files changed, 39 insertions(+), 2 deletions(-)
 create mode 120000 test/show_all_imagestreams.py

diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index cdb71108..d39b5c62 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -22,7 +22,7 @@
         app_versions: [10, 12, 13]
 
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15]
+        app_versions: [10, 12, 13, 15, 16]
 
       - name: RHEL 9
         app_versions: [13, 15, 16]
@@ -31,7 +31,7 @@
     latest: "16-el9"
     distros:
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15]
+        app_versions: [10, 12, 13, 15, 16]
 
       - name: RHEL 9
         app_versions: [13, 15, 16]
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 27792266..ccae28c0 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -81,6 +81,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el9",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 72c249ed..8c662d9b 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -135,6 +135,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el8",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 8)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel8/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "13-el9",
         "annotations": {
diff --git a/test/show_all_imagestreams.py b/test/show_all_imagestreams.py
new file mode 120000
index 00000000..ba8fe973
--- /dev/null
+++ b/test/show_all_imagestreams.py
@@ -0,0 +1 @@
+../common/show_all_imagestreams.py
\ No newline at end of file

From cb679f9905aa3602666cdb55ed3ff97617c3ac0e Mon Sep 17 00:00:00 2001
From: Eran Ifrach <eifrach@redhat.com>
Date: Thu, 11 Apr 2024 15:08:21 +0300
Subject: [PATCH 440/509] adding upgrade flow for postgresql in c9s, RHEL8 and
 later

Add postgresql16-upgrade package into fedora dockerfile
---
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 12/Dockerfile.fedora                          |  4 ++--
 12/Dockerfile.rhel8                           |  1 +
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 13/Dockerfile.c9s                             |  1 +
 13/Dockerfile.fedora                          |  4 ++--
 13/Dockerfile.rhel8                           |  1 +
 13/Dockerfile.rhel9                           |  1 +
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 14/Dockerfile.fedora                          |  4 ++--
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 15/Dockerfile.c9s                             |  1 +
 15/Dockerfile.fedora                          |  4 ++--
 15/Dockerfile.rhel8                           |  1 +
 15/Dockerfile.rhel9                           |  1 +
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 16/Dockerfile.c9s                             |  1 +
 16/Dockerfile.fedora                          |  3 ++-
 16/Dockerfile.rhel8                           |  1 +
 16/Dockerfile.rhel9                           |  1 +
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 src/Dockerfile                                |  1 +
 src/Dockerfile.fedora                         |  5 +++--
 .../container-scripts/postgresql/common.sh    | 19 ++++++++++++++-----
 24 files changed, 122 insertions(+), 46 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 1e23f839..0b57e599 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
index f5ce3586..afcc8bc9 100644
--- a/12/Dockerfile.fedora
+++ b/12/Dockerfile.fedora
@@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils xz" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+    INSTALL_PKGS+=" findutils xz" && \
     INSTALL_PKGS+=" pgaudit" && \
     dnf -y module enable postgresql:12 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index 9c8aa1e5..c9b76963 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum -y module enable postgresql:12 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index 6a3c6f2b..eff22d87 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
index a868fb13..075839d2 100644
--- a/13/Dockerfile.c9s
+++ b/13/Dockerfile.c9s
@@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN  { yum -y module enable postgresql:13 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
index aa7f63a6..124e1bb2 100644
--- a/13/Dockerfile.fedora
+++ b/13/Dockerfile.fedora
@@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils xz" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+    INSTALL_PKGS+=" findutils xz" && \
     INSTALL_PKGS+=" pgaudit" && \
     dnf -y module enable postgresql:13 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index 38e3b951..b6e39c72 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum -y module enable postgresql:13 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index 063ec1f4..a53a917f 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN { yum -y module enable postgresql:13 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index 9da493a2..afcfc059 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora
index a1ece9c2..888ebc88 100644
--- a/14/Dockerfile.fedora
+++ b/14/Dockerfile.fedora
@@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils xz" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+    INSTALL_PKGS+=" findutils xz" && \
     INSTALL_PKGS+=" pgaudit" && \
     dnf -y module enable postgresql:14 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 4a81bf4f..b2b7b762 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
index 378ea8f3..25ab942f 100644
--- a/15/Dockerfile.c9s
+++ b/15/Dockerfile.c9s
@@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN  { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index 560e3bd6..130f7cca 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils xz" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+    INSTALL_PKGS+=" findutils xz" && \
     INSTALL_PKGS+=" pgaudit" && \
     dnf -y module enable postgresql:15 && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 76a568c0..09304483 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum -y module enable postgresql:15 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index c464d0b5..23566a5b 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN { yum -y module enable postgresql:15 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index 35d7cc37..be2eb759 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
index 91b16096..7eafdcf5 100644
--- a/16/Dockerfile.c9s
+++ b/16/Dockerfile.c9s
@@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN  { yum -y module enable postgresql:16 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index 9c0bb6f0..a759f112 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -45,7 +45,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
-    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" procps-ng util-linux postgresql16-upgrade" && \
+    INSTALL_PKGS+=" findutils xz" && \
     INSTALL_PKGS+=" postgresql16-pgaudit" && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
index 70be99fe..510b8f10 100644
--- a/16/Dockerfile.rhel8
+++ b/16/Dockerfile.rhel8
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN yum -y module enable postgresql:16 && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index bc1009b5..a81820a1 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN { yum -y module enable postgresql:16 || :; } && \
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh
index cd80bbd5..b7482bdb 100644
--- a/16/root/usr/share/container-scripts/postgresql/common.sh
+++ b/16/root/usr/share/container-scripts/postgresql/common.sh
@@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -311,8 +311,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -350,9 +359,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 
diff --git a/src/Dockerfile b/src/Dockerfile
index dd934cd4..1a896cc7 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -75,6 +75,7 @@ RUN {{ spec.environment_setup }}
     INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
     {% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     {% endif %}
 {% endif %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 48accf6f..b5d6cd38 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -50,10 +50,11 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # to make sure of that.
 {% if spec.version == "16" %}
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
+    INSTALL_PKGS+=" procps-ng util-linux postgresql16-upgrade" && \
 {% else %}
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
 {% endif %}
-    INSTALL_PKGS+="findutils xz" && \
+    INSTALL_PKGS+=" findutils xz" && \
 {% if spec.version not in ["9.6", "10", "11", "16"] %}
     INSTALL_PKGS+=" pgaudit" && \
 {% endif %}
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index df39caed..7afc7ce3 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -298,7 +298,7 @@ function wait_for_postgresql_master() {
 run_pgupgrade ()
 (
   # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
+  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
     rm -rf "$PGDATA/postmaster.pid"
   fi
 
@@ -312,8 +312,17 @@ run_pgupgrade ()
     old_collection=rh-postgresql$old_raw_version
   fi
 
-  old_pgengine=/opt/rh/$old_collection/root/usr/bin
-  new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  # Backward compatibility for RHEL/CentOS 7
+  source /etc/os-release
+
+  if [[ $VERSION_ID -lt 8 ]]; then
+    old_pgengine=/opt/rh/$old_collection/root/usr/bin
+    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
+  else
+    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+    new_pgengine=/usr/bin
+  fi
+
   PGDATA_new="${PGDATA}-new"
 
   printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
@@ -351,9 +360,9 @@ run_pgupgrade ()
   # boot up data directory with old postgres once again to make sure
   # it was shut down properly, otherwise the upgrade process fails
   info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
+  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
   info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready"
+  "${old_pgengine}/pg_isready" -h 127.0.0.1
   info_msg "Shutting down old postgresql cleanly..."
   "${old_pgengine}/pg_ctl" stop
 

From e42cb5b813e6d7a2547f9f672557380161a57101 Mon Sep 17 00:00:00 2001
From: Filip Janus <fjanus@redhat.com>
Date: Wed, 29 May 2024 23:55:56 +0200
Subject: [PATCH 441/509] Enable upgrade test

---
 test/run_test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/test/run_test b/test/run_test
index 8c34cad5..376fc941 100755
--- a/test/run_test
+++ b/test/run_test
@@ -682,9 +682,6 @@ $volume_options
 run_upgrade_test ()
 {
   local ret=0
-    # Do not run on Fedora or RHEL8+ until the upgrade script
-    # is fixed for non-SCL use cases
-    { [ "${OS}" != "centos7" ] && [ "${OS}" != "rhel7" ]; } && return 0
 
     local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
     for act in $upgrade_path; do

From 0e4973c8537506a153b2f4b94f25e632e26af309 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Wed, 19 Jun 2024 08:41:28 +0200
Subject: [PATCH 442/509] Add GitHub Action for testing container by PyTest in
 OpenSHift 4. (#574)

The GitHub action is similar like here:
https://github.com/sclorg/httpd-container/blob/master/.github/workflows/openshift-pytests.yml or https://github.com/sclorg/mariadb-container/blob/master/.github/workflows/openshift-pytests.yml
https://github.com/sclorg/mysql-container/pull/369

And the tests are triggered properly.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/openshift-pytests.yml | 41 +++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 .github/workflows/openshift-pytests.yml

diff --git a/.github/workflows/openshift-pytests.yml b/.github/workflows/openshift-pytests.yml
new file mode 100644
index 00000000..9c22b5c6
--- /dev/null
+++ b/.github/workflows/openshift-pytests.yml
@@ -0,0 +1,41 @@
+on:
+  issue_comment:
+    types:
+      - created
+jobs:
+  check-imagestreams:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      statuses: write
+    if: |
+      github.event.issue.pull_request
+      && (contains(github.event.comment.body, '[test-openshift-pytest]') || contains(github.event.comment.body, '[test-all]'))
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+    steps:
+      - uses: sclorg/ci-scripts/ocp-stream-generator@master
+        with:
+          ref: "refs/pull/${{ github.event.issue.number }}/head"
+
+  openshift-pytests:
+    name: "${{ matrix.test_case }} PyTests: ${{ matrix.version }} - ${{ matrix.os_test }}"
+    runs-on: ubuntu-latest
+    needs: check-imagestreams
+    concurrency:
+      group: ocp-pytest-${{ github.event.issue.number }}-${{ matrix.version }}-${{ matrix.os_test }}
+      cancel-in-progress: true
+    strategy:
+      fail-fast: false
+      matrix:
+        version: [ "10", "12", "13", "14", "15", "16" ]
+        os_test: [ "rhel8", "rhel9"]
+        test_case: [ "openshift-pytest" ]
+
+    steps:
+      - uses: sclorg/tfaga-wrapper@main
+        with:
+          os_test: ${{ matrix.os_test }}
+          version: ${{ matrix.version }}
+          test_case: ${{ matrix.test_case }}
+          public_api_key: ${{ secrets.TF_PUBLIC_API_KEY }}
+          private_api_key: ${{ secrets.TF_INTERNAL_API_KEY }}

From 3edc98264778b186dfca016b4fda17a73b76f076 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 7 Jun 2024 14:33:39 +0200
Subject: [PATCH 443/509] Automatic update description on quay.io

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 37cf19f3..28dce68a 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -104,3 +104,5 @@ jobs:
           docker_context: ${{ matrix.docker_context }}
           tag: ${{ matrix.tag }}
           image_name: ${{ matrix.image_name }}
+          readme: "${{ matrix.docker_context }}/README.md"
+          quay_application_token: ${{ secrets.QUAY_IMAGE_SCLORG_UPDATE_DESC }}

From d741d4742739f9a2aae7484e15f90b34e39b040b Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 10 Jun 2024 13:13:59 +0000
Subject: [PATCH 444/509] Bump common from `8c310e1` to `f994db1`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `8c310e1` to `f994db1`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/8c310e11d4fd5b942a2dd722e7dca5748ed80393...f994db126f12c383490fee5913bbf87266011896)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 8c310e11..f994db12 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 8c310e11d4fd5b942a2dd722e7dca5748ed80393
+Subproject commit f994db126f12c383490fee5913bbf87266011896

From 8063db85575a078454e022728e03264ae32b2185 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 27 Jun 2024 15:42:21 +0200
Subject: [PATCH 445/509] REmove RHEL-7 from building and testing.

RHEL-7 reached EOL in June 2024

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml |   2 +-
 .github/workflows/openshift-tests.yml |   2 +-
 10/Dockerfile.rhel7                   |  99 -------------------------
 12/Dockerfile.rhel7                   | 100 --------------------------
 13/Dockerfile.rhel7                   | 100 --------------------------
 imagestreams/imagestreams.yaml        |   3 -
 imagestreams/postgresql-rhel.json     |  54 --------------
 manifest.yml                          |   9 ---
 specs/multispec.yml                   |  52 ++------------
 src/Dockerfile                        |  18 +----
 test/pg-test-lib.sh                   |  18 -----
 test/run-openshift-remote-cluster     |   2 +-
 test/test-lib-postgresql.sh           |  26 +++----
 13 files changed, 19 insertions(+), 466 deletions(-)
 delete mode 100644 10/Dockerfile.rhel7
 delete mode 100644 12/Dockerfile.rhel7
 delete mode 100644 13/Dockerfile.rhel7

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 791d6712..aa584d98 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -58,7 +58,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "14", "15", "16" ]
-        os_test: [ "fedora", "rhel7", "rhel8", "rhel9", "c9s" ]
+        os_test: [ "fedora", "rhel8", "rhel9", "c9s" ]
         test_case: [ "container" ]
 
     if: |
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index e63daf1b..be81147b 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -48,7 +48,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "10", "11", "12", "13", "15", "16" ]
-        os_test: [ "rhel7", "rhel8", "rhel9"]
+        os_test: [ "rhel8", "rhel9"]
         test_case: [ "openshift-4" ]
     steps:
       - uses: sclorg/tfaga-wrapper@main
diff --git a/10/Dockerfile.rhel7 b/10/Dockerfile.rhel7
deleted file mode 100644
index 02d8cd1a..00000000
--- a/10/Dockerfile.rhel7
+++ /dev/null
@@ -1,99 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=10 \
-    POSTGRESQL_PREV_VERSION=9.6 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 10" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql10,rh-postgresql10" \
-      io.openshift.s2i.assemble-user="26" \
-      name="rhscl/postgresql-10-rhel7" \
-      com.redhat.component="rh-postgresql10-container" \
-      version="1" \
-      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-10-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql10 rh-postgresql10-postgresql-contrib rh-postgresql10-syspaths rh-postgresql96-postgresql-server" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql10
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/12/Dockerfile.rhel7 b/12/Dockerfile.rhel7
deleted file mode 100644
index 8d62190b..00000000
--- a/12/Dockerfile.rhel7
+++ /dev/null
@@ -1,100 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=12 \
-    POSTGRESQL_PREV_VERSION=10 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 12" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql12,rh-postgresql12" \
-      io.openshift.s2i.assemble-user="26" \
-      name="rhscl/postgresql-12-rhel7" \
-      com.redhat.component="rh-postgresql12-container" \
-      version="1" \
-      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-12-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql12 rh-postgresql12-postgresql-contrib rh-postgresql12-syspaths rh-postgresql10-postgresql-server" && \
-    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql12-pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql12
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/13/Dockerfile.rhel7 b/13/Dockerfile.rhel7
deleted file mode 100644
index 03d27cc0..00000000
--- a/13/Dockerfile.rhel7
+++ /dev/null
@@ -1,100 +0,0 @@
-FROM rhscl/s2i-core-rhel7
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=13 \
-    POSTGRESQL_PREV_VERSION=12 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 13" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql13,rh-postgresql13" \
-      io.openshift.s2i.assemble-user="26" \
-      name="rhscl/postgresql-13-rhel7" \
-      com.redhat.component="rh-postgresql13-container" \
-      version="1" \
-      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-13-rhel7" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-# rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-# in base RHEL
-RUN yum install -y yum-utils gettext && \
-    prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper rh-postgresql13 rh-postgresql13-postgresql-contrib rh-postgresql13-syspaths rh-postgresql12-postgresql-server" && \
-    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql13-pgaudit" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=rh-postgresql13
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index d39b5c62..e520914b 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -18,9 +18,6 @@
   - filename: postgresql-rhel.json
     latest: "16-el9"
     distros:
-      - name: RHEL 7
-        app_versions: [10, 12, 13]
-
       - name: RHEL 8
         app_versions: [10, 12, 13, 15, 16]
 
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 8c662d9b..ccae28c0 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -9,60 +9,6 @@
   },
   "spec": {
     "tags": [
-      {
-        "name": "10-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-10-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "12-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 12 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 12 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "12"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-12-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
-      {
-        "name": "13-el7",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 13 (RHEL 7)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 13 database on RHEL 7. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "13"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhscl/postgresql-13-rhel7:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "10-el8",
         "annotations": {
diff --git a/manifest.yml b/manifest.yml
index e038f2b2..bcf27884 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -23,12 +23,6 @@ DISTGEN_RULES:
 # Files containing distgen directives, which are used for each
 # (distro, version) combination not excluded in multispec
 DISTGEN_MULTI_RULES:
-  - src: src/Dockerfile
-    dest: Dockerfile.centos7
-
-  - src: src/Dockerfile
-    dest: Dockerfile.rhel7
-
   - src: src/Dockerfile
     dest: Dockerfile.rhel8
 
@@ -90,9 +84,6 @@ COPY_RULES:
 # This section is the last one on purpose because the generator.py
 # does not allow dead symlinks.
 SYMLINK_RULES:
-  - src: ./Dockerfile.centos7
-    dest: Dockerfile
-
   - src: root/usr/share/container-scripts/postgresql/README.md
     dest: README.md
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index b08de54b..af8e8c5a 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -14,41 +14,6 @@ specs:
       pkgs: "postgresql-server postgresql-contrib"
       environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
-    centos:
-      distros:
-        - centos-7-x86_64
-      s2i_base: quay.io/centos7/s2i-core-centos7
-      org: "centos7"
-      prod: "centos7"
-      openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
-      redhat_component: "rh-postgresql{{ spec.short }}-container"
-      enabled_collection: "rh-postgresql{{ spec.short }}"
-      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
-      repo_enable_reason: ""
-      environment_setup: yum install -y centos-release-scl-rh && \
-      staging_repo_setup: >-4
-              yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql96-rh-candidate/x86_64/os/ && \
-              echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql96-rh-candidate_x86_64_os_.repo && \
-    rhel7:
-       distros:
-         - rhel-7-x86_64
-       s2i_base: rhscl/s2i-core-rhel7
-       org: "rhscl"
-       prod: "rhel7"
-       openshift_tags: "database,postgresql,postgresql{{ spec.short }},rh-postgresql{{ spec.short }}"
-       redhat_component: "rh-postgresql{{ spec.short }}-container"
-       enabled_collection: "rh-postgresql{{ spec.short }}"
-       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-       pkgs: "rh-postgresql{{ spec.short }} rh-postgresql{{ spec.short }}-postgresql-contrib rh-postgresql{{ spec.short }}-syspaths rh-postgresql{{ spec.prev_short }}-postgresql-server"
-       repo_enable_reason: |-
-         # rhel-7-server-ose-3.2-rpms is enabled for nss_wrapper until this pkg is
-         # in base RHEL
-       environment_setup: >-4
-           yum install -y yum-utils gettext && \
-               prepare-yum-repositories rhel-server-rhscl-7-rpms && \
-       rhscl_version:
-         development: 3.4
     rhel8:
        distros:
          - rhel-8-x86_64
@@ -97,8 +62,7 @@ specs:
       short: "10"
       prev_short: "96"
       common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-10-rhel7"
-      centos_image_name: "centos7/postgresql-10-centos7"
+      rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
       latest_fedora: "f34"
 
     "12":
@@ -107,8 +71,7 @@ specs:
       short: "12"
       prev_short: "10"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
-      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
+      rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
       latest_fedora: "f38"
 
     "13":
@@ -117,9 +80,8 @@ specs:
       short: "13"
       prev_short: "12"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
-      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
+      rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
       latest_fedora: "f38"
 
     "14":
@@ -128,8 +90,7 @@ specs:
       short: "14"
       prev_short: "13"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      rhel_image_name: "rhscl/postgresql-{{ spec.short }}-rhel7"
-      centos_image_name: "centos7/postgresql-{{ spec.short }}-centos7"
+      rhel_image_name: "fedora/postgresql-{{ spec.short }}"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
       latest_fedora: "f38"
 
@@ -139,7 +100,7 @@ specs:
       short: "15"
       prev_short: "13"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
+      rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
       latest_fedora: "f38"
 
     "16":
@@ -156,16 +117,13 @@ matrix:
   include:
     - version: "10"
       distros:
-        - rhel-7-x86_64
         - rhel-8-x86_64
     - version: "12"
       distros:
-        - rhel-7-x86_64
         - rhel-8-x86_64
         - fedora-38-x86_64
     - version: "13"
       distros:
-        - rhel-7-x86_64
         - rhel-8-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 1a896cc7..3d020c1c 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -57,10 +57,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {% endif %}
 RUN {{ spec.environment_setup }}
 {% if spec.has_devel_repo %}
-  {% if config.os.id == 'centos' and spec.has_devel_repo.centos %}
-    yum-config-manager --add-repo https://cbs.centos.org/repos/sclo7-rh-postgresql{{ spec.version }}-rh-candidate/x86_64/os/ && \
-    echo gpgcheck=0 >> /etc/yum.repos.d/cbs.centos.org_repos_sclo7-rh-postgresql{{ spec.version }}-rh-candidate_x86_64_os_.repo && \
-  {% elif config.os.id == 'rhel' %}
+  {% if config.os.id == 'rhel' %}
     {% if spec.has_devel_repo.rhel == 'brew' %}
     yum-config-manager --add-repo http://download.devel.redhat.com/brewroot/repos/rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build/latest/x86_64 && \
     echo gpgcheck=0 >> /etc/yum.repos.d/download.devel.redhat.com_brewroot_repos_rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build_latest_x86_64.repo && \
@@ -71,12 +68,8 @@ RUN {{ spec.environment_setup }}
 {% endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
 {% if spec.version not in ["9.6", "10", "11"] %}
-    {% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
-    INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
-    {% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
-    {% endif %}
 {% endif %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
@@ -102,15 +95,6 @@ COPY ./s2i/bin/ $STI_SCRIPTS_PATH
 # /usr/libexec/s2i/run no such file or directory
 RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
 
-{% if spec.prod != "rhel8" and spec.prod != "rhel9" and config.os.id != "fedora" and spec.prod != "c9s" %}
-# When bash is started non-interactively, to run a shell script, for example it
-# looks for this variable and source the content of this file. This will enable
-# the SCL for all scripts without need to do 'scl enable'.
-ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
-    PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
-
-{% endif %}
 # Not using VOLUME statement since it's not working in OpenShift Online:
 # https://github.com/sclorg/httpd-container/issues/30
 # VOLUME ["/var/lib/pgsql/data"]
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 4d6e2c58..bb240df8 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -21,20 +21,6 @@ get_image_id ()
         remote)
             local version=${1//\./}
             case $OS in
-            rhel7)
-                ns=rhscl
-                if test "$version" -eq 92; then
-                    ns=openshift3
-                fi
-                image=registry.redhat.io/$ns/postgresql-${version}-rhel7
-                ;;
-            centos7)
-                ns=centos7
-                if test "$version" -eq 92; then
-                    ns=openshift
-                fi
-                local image=quay.io/$ns/postgresql-${1//\./}-centos7
-                ;;
             rhel8)
                 ns=rhel8
                 local image=registry.redhat.io/$ns/postgresql-${version}
@@ -43,10 +29,6 @@ get_image_id ()
                 ns=rhel9
                 local image=registry.redhat.io/$ns/postgresql-${version}
                 ;;
-            c8s)
-                ns=c8s
-                local image=quay.io/sclorg/postgresql-${version}-$ns
-                ;;
             c9s)
                 ns=c9s
                 local image=quay.io/sclorg/postgresql-${version}-$ns
diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster
index 60ebf938..5b12f9ca 100755
--- a/test/run-openshift-remote-cluster
+++ b/test/run-openshift-remote-cluster
@@ -5,7 +5,7 @@
 # IMAGE_NAME specifies a name of the candidate image used for testing.
 # The image has to be available before this script is executed.
 # VERSION specifies the major version of the PostgreSQL in format of X.Y
-# OS specifies RHEL version (e.g. OS=rhel7)
+# OS specifies RHEL version (e.g. OS=rhel8)
 #
 
 THISDIR=$(dirname ${BASH_SOURCE[0]})
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index dfb79a1a..60fc7082 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -14,18 +14,14 @@ source "${THISDIR}"/test-lib-remote-openshift.sh
 
 function test_postgresql_integration() {
   local service_name=postgresql
-  if [ "${OS}" == "rhel7" ]; then
-    namespace_image="rhscl/postgresql-${VERSION}-rhel7"
-  else
-    namespace_image="${OS}/postgresql-${VERSION}"
-    # Check if the current version is already GA
-    # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
-    local devel_file="/root/sclorg-tmt-plans/devel_images"
-    if [ -f "${devel_file}" ]; then
-      if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
-        echo "This version is currently developed, so skipping this test."
-        return
-      fi
+  namespace_image="${OS}/postgresql-${VERSION}"
+  # Check if the current version is already GA
+  # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
+  local devel_file="/root/sclorg-tmt-plans/devel_images"
+  if [ -f "${devel_file}" ]; then
+    if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
+      echo "This version is currently developed, so skipping this test."
+      return
     fi
   fi
   TEMPLATES="postgresql-ephemeral-template.json
@@ -45,10 +41,8 @@ function test_postgresql_integration() {
 
 # Check the imagestream
 function test_postgresql_imagestream() {
-  local tag="-el7"
-  if [ "${OS}" == "rhel8" ]; then
-    tag="-el8"
-  elif [ "${OS}" == "rhel9" ]; then
+  tag="-el8"
+  if [ "${OS}" == "rhel9" ]; then
     tag="-el9"
   fi
   # Check if the current version is already GA

From 9c52e6c5aae6007b1a1742b948ddf19359c7268e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 27 Jun 2024 15:52:59 +0200
Subject: [PATCH 446/509] Update README's generated by dist-gen

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .../container-scripts/postgresql/README.md    | 13 +++++----
 .../container-scripts/postgresql/README.md    | 13 +++++----
 .../container-scripts/postgresql/README.md    | 13 +++++----
 .../container-scripts/postgresql/README.md    | 13 +++++----
 .../container-scripts/postgresql/README.md    | 13 +++++----
 .../container-scripts/postgresql/README.md    |  5 ++--
 README.md                                     | 11 --------
 .../container-scripts/postgresql/README.md    | 27 ++-----------------
 8 files changed, 34 insertions(+), 74 deletions(-)

diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index 8e3df377..67a23387 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 10 SQL Database Server Container Image
 
-This container image features the PostgreSQL 10 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 10 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -10,10 +10,10 @@ This container image offers a containerized version of the PostgreSQL postgres d
 
 ## Usage
 
-Assuming you are utilizing the `rhscl/postgresql-10-rhel7` image, which is accessible via the `postgresql:10` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+Assuming you are utilizing the `rhel8/postgresql-10` image, which is accessible via the `postgresql:10` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
 ```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-10-rhel7
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-10
 ```
 
 This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
@@ -135,10 +135,9 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-10-rhel7` image, available via `postgresql:10` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-10` image, available via `postgresql:10` imagestream tag in Openshift.
 
 To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
@@ -154,7 +153,7 @@ $ oc new-app postgresql:10~https://github.com/sclorg/postgresql-container.git \
 or via `s2i`:
 
 ```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-10-rhel7 new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhel8/postgresql-10 new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the following directories:
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index c7e5add9..64bd3afa 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 12 SQL Database Server Container Image
 
-This container image features the PostgreSQL 12 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 12 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -10,10 +10,10 @@ This container image offers a containerized version of the PostgreSQL postgres d
 
 ## Usage
 
-Assuming you are utilizing the `rhscl/postgresql-12-rhel7` image, which is accessible via the `postgresql:12` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+Assuming you are utilizing the `rhel8/postgresql-12` image, which is accessible via the `postgresql:12` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
 ```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-12-rhel7
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-12
 ```
 
 This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
@@ -135,10 +135,9 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-12-rhel7` image, available via `postgresql:12` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-12` image, available via `postgresql:12` imagestream tag in Openshift.
 
 To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
@@ -154,7 +153,7 @@ $ oc new-app postgresql:12~https://github.com/sclorg/postgresql-container.git \
 or via `s2i`:
 
 ```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-12-rhel7 new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhel8/postgresql-12 new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the following directories:
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index d0cf8e95..6ebb615d 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 13 SQL Database Server Container Image
 
-This container image features the PostgreSQL 13 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 13 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -10,10 +10,10 @@ This container image offers a containerized version of the PostgreSQL postgres d
 
 ## Usage
 
-Assuming you are utilizing the `rhscl/postgresql-13-rhel7` image, which is accessible via the `postgresql:13` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+Assuming you are utilizing the `rhel8/postgresql-13` image, which is accessible via the `postgresql:13` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
 ```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-13-rhel7
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-13
 ```
 
 This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
@@ -135,10 +135,9 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-13-rhel7` image, available via `postgresql:13` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-13` image, available via `postgresql:13` imagestream tag in Openshift.
 
 To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
@@ -154,7 +153,7 @@ $ oc new-app postgresql:13~https://github.com/sclorg/postgresql-container.git \
 or via `s2i`:
 
 ```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-13-rhel7 new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhel8/postgresql-13 new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the following directories:
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
index 57a53c8d..74d1ba9d 100644
--- a/14/root/usr/share/container-scripts/postgresql/README.md
+++ b/14/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 14 SQL Database Server Container Image
 
-This container image features the PostgreSQL 14 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 14 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -10,10 +10,10 @@ This container image offers a containerized version of the PostgreSQL postgres d
 
 ## Usage
 
-Assuming you are utilizing the `rhscl/postgresql-14-rhel7` image, which is accessible via the `postgresql:14` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+Assuming you are utilizing the `fedora/postgresql-14` image, which is accessible via the `postgresql:14` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
 ```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhscl/postgresql-14-rhel7
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 fedora/postgresql-14
 ```
 
 This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
@@ -135,10 +135,9 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhscl/postgresql-14-rhel7` image, available via `postgresql:14` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `fedora/postgresql-14` image, available via `postgresql:14` imagestream tag in Openshift.
 
 To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
@@ -154,7 +153,7 @@ $ oc new-app postgresql:14~https://github.com/sclorg/postgresql-container.git \
 or via `s2i`:
 
 ```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhscl/postgresql-14-rhel7 new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git fedora/postgresql-14 new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the following directories:
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index 953027fd..b05d9c7a 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 15 SQL Database Server Container Image
 
-This container image features the PostgreSQL 15 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 15 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -10,10 +10,10 @@ This container image offers a containerized version of the PostgreSQL postgres d
 
 ## Usage
 
-Assuming you are utilizing the `` image, which is accessible via the `postgresql:15` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
+Assuming you are utilizing the `rhel8/postgresql-15` image, which is accessible via the `postgresql:15` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
 
 ```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 
+$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-15
 ```
 
 This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
@@ -135,10 +135,9 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `` image, available via `postgresql:15` imagestream tag in Openshift.
+You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-15` image, available via `postgresql:15` imagestream tag in Openshift.
 
 To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
 
@@ -154,7 +153,7 @@ $ oc new-app postgresql:15~https://github.com/sclorg/postgresql-container.git \
 or via `s2i`:
 
 ```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git  new-postgresql
+$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhel8/postgresql-15 new-postgresql
 ```
 
 The directory passed to Openshift should contain one or more of the following directories:
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/16/root/usr/share/container-scripts/postgresql/README.md b/16/root/usr/share/container-scripts/postgresql/README.md
index 3e0df720..4b199357 100644
--- a/16/root/usr/share/container-scripts/postgresql/README.md
+++ b/16/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL 16 SQL Database Server Container Image
 
-This container image features the PostgreSQL 16 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL 16 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -135,7 +135,6 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `` image, available via `postgresql:16` imagestream tag in Openshift.
@@ -192,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/README.md b/README.md
index d46ec964..0b2ff603 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,6 @@
 
 Images available on Quay.io are:
 
-- CentOS 7 [postgresql-10](https://quay.io/repository/centos7/postgresql-10-centos7)
-- CentOS 7 [postgresql-12](https://quay.io/repository/centos7/postgresql-12-centos7)
-- CentOS 7 [postgresql-13](https://quay.io/repository/centos7/postgresql-13-centos7)
-- CentOS Stream 8 [postgresql-10](https://quay.io/repository/sclorg/postgresql-10-c8s)
-- CentOS Stream 8 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c8s)
-- CentOS Stream 8 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c8s)
 - CentOS Stream 9 [postgresql-13](https://quay.io/repository/sclorg/postgresql-13-c9s)
 - CentOS Stream 9 [postgresql-15](https://quay.io/repository/sclorg/postgresql-15-c9s)
 - Fedora [postgresql-11](https://quay.io/repository/fedora/postgresql-11)
@@ -36,15 +30,10 @@ PostgreSQL versions currently supported are:
 - [postgresql-15](https://github.com/sclorg/postgresql-container/tree/master/15)
 
 RHEL versions currently supported are:
-
-- RHEL7
 - RHEL8
 - RHEL9
 
 CentOS versions currently supported are:
-
-- CentOS7
-- CentOS Stream 8
 - CentOS Stream 9
 
 ## Installation
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index e5fdbac7..8f265247 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL {{ spec.version }} SQL Database Server Container Image
 
-This container image features the PostgreSQL {{ spec.version }} SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS images are available on [Quay.io](https://quay.io/organization/centos7), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
+This container image features the PostgreSQL {{ spec.version }} SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
 
 Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
 
@@ -135,29 +135,6 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
-{% if spec.prod == 'rhel7' or spec.prod == 'centos7' %}
-Upgrading database (by switching to newer PostgreSQL image version)
-
----
-
-** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
-
-This image supports automatic upgrade of data directories created by the PostgreSQL server version {{ spec.prev_version }} (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
-
-The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
-
-For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
-approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
-
-**`copy`**  
- Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
-
-**`hardlink`**  
- Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
-
-Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
-{% endif %}
-
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `{{ spec.rhel_image_name }}` image, available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.
@@ -214,4 +191,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the CentOS Dockerfile is named Dockerfile, the RHEL7 Dockerfile is named Dockerfile.rhel7, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.

From af6a373103948eb15564a0ac1a7cc8adc30b5940 Mon Sep 17 00:00:00 2001
From: Petr Hracek <phracek@redhat.com>
Date: Thu, 4 Jul 2024 11:04:10 +0200
Subject: [PATCH 447/509] Add tests written in Pytest for testing in OpenShift
 4 environment (#575)

* Add tests written in Pytest for testing in OpenShift 4 environment

Add test written in PyTest for testing
postgresql-container in OpenShift 4 environment

* Add the latest container-common-scripts

---------

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-pytest                    | 13 +++++
 test/test_postgresql_imagestream.py          | 50 ++++++++++++++++
 test/test_postgresql_imagestream_template.py | 46 +++++++++++++++
 test/test_postgresql_latest_imagestreams.py  | 26 +++++++++
 test/test_postgresql_template.py             | 61 ++++++++++++++++++++
 5 files changed, 196 insertions(+)
 create mode 100755 test/run-openshift-pytest
 create mode 100644 test/test_postgresql_imagestream.py
 create mode 100644 test/test_postgresql_imagestream_template.py
 create mode 100644 test/test_postgresql_latest_imagestreams.py
 create mode 100644 test/test_postgresql_template.py

diff --git a/test/run-openshift-pytest b/test/run-openshift-pytest
new file mode 100755
index 00000000..bd49496e
--- /dev/null
+++ b/test/run-openshift-pytest
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# IMAGE_NAME specifies a name of the candidate image used for testing.
+# The image has to be available before this script is executed.
+# VERSION specifies the major version of the MariaDB in format of X.Y
+# OS specifies RHEL version (e.g. OS=rhel7)
+#
+
+THISDIR=$(dirname ${BASH_SOURCE[0]})
+
+git show -s
+
+cd "${THISDIR}" && python3 -m pytest -s -rA --showlocals -vv test_postgresql_*.py
diff --git a/test/test_postgresql_imagestream.py b/test/test_postgresql_imagestream.py
new file mode 100644
index 00000000..b81c4d28
--- /dev/null
+++ b/test/test_postgresql_imagestream.py
@@ -0,0 +1,50 @@
+import os
+import sys
+
+import pytest
+
+from container_ci_suite.openshift import OpenShiftAPI
+from container_ci_suite.utils import check_variables
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    sys.exit(1)
+
+
+VERSION = os.getenv("SINGLE_VERSION")
+IMAGE_NAME = os.getenv("IMAGE_NAME")
+OS = os.getenv("TARGET")
+TAGS = {
+    "rhel8": "-el8",
+    "rhel9": "-el9"
+}
+TAG = TAGS.get(OS, None)
+
+
+class TestPostgreSQLImagestreamTemplate:
+
+    def setup_method(self):
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION)
+
+    def teardown_method(self):
+        self.oc_api.delete_project()
+
+    @pytest.mark.parametrize(
+        "template",
+        [
+            "postgresql-ephemeral-template.json",
+            "postgresql-persistent-template.json"
+        ]
+    )
+    def test_psql_imagestream_template(self, template):
+        os_name = ''.join(i for i in OS if not i.isdigit())
+        print(os.getcwd())
+        assert self.oc_api.deploy_image_stream_template(
+            imagestream_file=f"imagestreams/postgresql-{os_name}.json",
+            template_file=f"examples/{template}",
+            app_name=self.oc_api.pod_name_prefix,
+            openshift_args=[
+                f"POSTGRESQL_VERSION={VERSION}{TAG}"
+            ]
+        )
+        assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix)
diff --git a/test/test_postgresql_imagestream_template.py b/test/test_postgresql_imagestream_template.py
new file mode 100644
index 00000000..65323c6b
--- /dev/null
+++ b/test/test_postgresql_imagestream_template.py
@@ -0,0 +1,46 @@
+import os
+import sys
+
+import pytest
+
+from container_ci_suite.openshift import OpenShiftAPI
+from container_ci_suite.utils import check_variables
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    sys.exit(1)
+
+
+VERSION = os.getenv("SINGLE_VERSION")
+IMAGE_NAME = os.getenv("IMAGE_NAME")
+OS = os.getenv("TARGET")
+TAGS = {
+    "rhel8": "-el8",
+    "rhel9": "-el9"
+}
+TAG = TAGS.get(OS, None)
+
+
+class TestPostgreSQLImagestreamTemplate:
+
+    def setup_method(self):
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION)
+
+    def teardown_method(self):
+        self.oc_api.delete_project()
+
+    @pytest.mark.parametrize(
+        "template",
+        [
+            "postgresql-ephemeral-template.json",
+            "postgresql-persistent-template.json"
+        ]
+    )
+    def test_psql_imagestream_template(self, template):
+        os_name = ''.join(i for i in OS if not i.isdigit())
+        assert self.oc_api.deploy_image_stream_template(
+            imagestream_file=f"imagestreams/postgresql-{os_name}.json",
+            template_file=f"examples/{template}",
+            app_name=self.oc_api.pod_name_prefix
+        )
+        assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix)
diff --git a/test/test_postgresql_latest_imagestreams.py b/test/test_postgresql_latest_imagestreams.py
new file mode 100644
index 00000000..a8140cf3
--- /dev/null
+++ b/test/test_postgresql_latest_imagestreams.py
@@ -0,0 +1,26 @@
+import os
+import sys
+
+import pytest
+
+from pathlib import Path
+
+from container_ci_suite.imagestreams import ImageStreamChecker
+from container_ci_suite.utils import check_variables
+
+TEST_DIR = Path(os.path.abspath(os.path.dirname(__file__)))
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    sys.exit(1)
+
+
+class TestLatestImagestreams:
+
+    def setup_method(self):
+        self.isc = ImageStreamChecker(working_dir=TEST_DIR.parent)
+
+    def test_latest_imagestream(self):
+        self.latest_version = self.isc.get_latest_version()
+        assert self.latest_version != ""
+        self.isc.check_imagestreams(self.latest_version)
diff --git a/test/test_postgresql_template.py b/test/test_postgresql_template.py
new file mode 100644
index 00000000..516e5d00
--- /dev/null
+++ b/test/test_postgresql_template.py
@@ -0,0 +1,61 @@
+import os
+import sys
+
+import pytest
+
+from container_ci_suite.openshift import OpenShiftAPI
+from container_ci_suite.utils import check_variables
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    sys.exit(1)
+
+
+VERSION = os.getenv("SINGLE_VERSION")
+IMAGE_NAME = os.getenv("IMAGE_NAME")
+OS = os.getenv("TARGET")
+
+TAGS = {
+    "rhel8": "-el8",
+    "rhel9": "-el9"
+}
+TAG = TAGS.get(OS, None)
+
+
+class TestPostgreSQLDeployTemplate:
+
+    def setup_method(self):
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql-testing", version=VERSION)
+
+    def teardown_method(self):
+        self.oc_api.delete_project()
+
+    @pytest.mark.parametrize(
+        "template",
+        [
+            "postgresql-ephemeral-template.json",
+            "postgresql-persistent-template.json"
+        ]
+    )
+    def test_psql_template_inside_cluster(self, template):
+        short_version = VERSION.replace(".", "")
+        assert self.oc_api.deploy_template_with_image(
+            image_name=IMAGE_NAME,
+            template=f"examples/{template}",
+            name_in_template="postgresql",
+            openshift_args=[
+                f"POSTGRESQL_VERSION={VERSION}",
+                f"DATABASE_SERVICE_NAME={self.oc_api.pod_name_prefix}",
+                f"POSTGRESQL_USER=testu",
+                f"POSTGRESQL_PASSWORD=testp",
+                f"POSTGRESQL_DATABASE=testdb"
+            ]
+        )
+
+        assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix)
+        assert self.oc_api.check_command_internal(
+            image_name=f"registry.redhat.io/{OS}/postgresql-{short_version}",
+            service_name=self.oc_api.pod_name_prefix,
+            cmd="PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb",
+            expected_output="accepting connections"
+        )

From 48ccf431a33798c057813ddd697c8cf54b99f96e Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 17 Jul 2024 16:50:23 +0200
Subject: [PATCH 448/509] Bump common from `f994db1` to `1e271d8` (#578)

Bumps [common](https://github.com/sclorg/container-common-scripts) from `f994db1` to `1e271d8`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/f994db126f12c383490fee5913bbf87266011896...1e271d8d077833ceed1bc0fcb1eb9629ea5ea410)


Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index f994db12..1e271d8d 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit f994db126f12c383490fee5913bbf87266011896
+Subproject commit 1e271d8d077833ceed1bc0fcb1eb9629ea5ea410

From 8a8c43eb453feb90382ad75423e4b48a57deacd2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 17 Jul 2024 16:08:46 +0200
Subject: [PATCH 449/509] Fix calling proper python interpreter

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-pytest | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run-openshift-pytest b/test/run-openshift-pytest
index bd49496e..63eae5e3 100755
--- a/test/run-openshift-pytest
+++ b/test/run-openshift-pytest
@@ -10,4 +10,4 @@ THISDIR=$(dirname ${BASH_SOURCE[0]})
 
 git show -s
 
-cd "${THISDIR}" && python3 -m pytest -s -rA --showlocals -vv test_postgresql_*.py
+cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_postgresql_*.py

From 64e276579d09cf9d4032354216add744db9e9c84 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 19 Jul 2024 13:08:02 +0200
Subject: [PATCH 450/509] Use VERSION instead of SINGLE_VERSION, like we do in
 whole org

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test_postgresql_imagestream.py          | 4 ++--
 test/test_postgresql_imagestream_template.py | 4 ++--
 test/test_postgresql_latest_imagestreams.py  | 2 +-
 test/test_postgresql_template.py             | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/test/test_postgresql_imagestream.py b/test/test_postgresql_imagestream.py
index b81c4d28..eb1461a9 100644
--- a/test/test_postgresql_imagestream.py
+++ b/test/test_postgresql_imagestream.py
@@ -7,11 +7,11 @@
 from container_ci_suite.utils import check_variables
 
 if not check_variables():
-    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
 
 
-VERSION = os.getenv("SINGLE_VERSION")
+VERSION = os.getenv("VERSION")
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
 TAGS = {
diff --git a/test/test_postgresql_imagestream_template.py b/test/test_postgresql_imagestream_template.py
index 65323c6b..7ee986a0 100644
--- a/test/test_postgresql_imagestream_template.py
+++ b/test/test_postgresql_imagestream_template.py
@@ -7,11 +7,11 @@
 from container_ci_suite.utils import check_variables
 
 if not check_variables():
-    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
 
 
-VERSION = os.getenv("SINGLE_VERSION")
+VERSION = os.getenv("VERSION")
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
 TAGS = {
diff --git a/test/test_postgresql_latest_imagestreams.py b/test/test_postgresql_latest_imagestreams.py
index a8140cf3..f01d442e 100644
--- a/test/test_postgresql_latest_imagestreams.py
+++ b/test/test_postgresql_latest_imagestreams.py
@@ -11,7 +11,7 @@
 TEST_DIR = Path(os.path.abspath(os.path.dirname(__file__)))
 
 if not check_variables():
-    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
 
 
diff --git a/test/test_postgresql_template.py b/test/test_postgresql_template.py
index 516e5d00..cc19ad85 100644
--- a/test/test_postgresql_template.py
+++ b/test/test_postgresql_template.py
@@ -7,11 +7,11 @@
 from container_ci_suite.utils import check_variables
 
 if not check_variables():
-    print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
 
 
-VERSION = os.getenv("SINGLE_VERSION")
+VERSION = os.getenv("VERSION")
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
 

From 812524f03697148cc32adffe1ec8dbfab23ba395 Mon Sep 17 00:00:00 2001
From: Michael Scherer <misc@redhat.com>
Date: Tue, 30 Jul 2024 10:19:49 -0400
Subject: [PATCH 451/509] Add support for extensions loading and creation.

Using POSTGRESQL_LIBRARIES and POSTGRESQL_EXTENSIONS allow
users to enable extensions (some bundled in the container) without
having to do anything but adding 2 variables.
---
 src/root/usr/bin/run-postgresql                 |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 test/run_test                                   | 14 ++++++++++++--
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/root/usr/bin/run-postgresql b/src/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/src/root/usr/bin/run-postgresql
+++ b/src/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 8f265247..37c2469a 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 7afc7ce3..7ca09dce 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -145,6 +145,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -172,6 +179,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -517,3 +525,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/test/run_test b/test/run_test
index 376fc941..e198b8f4 100755
--- a/test/run_test
+++ b/test/run_test
@@ -28,6 +28,7 @@ run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 run_pgaudit_test
+run_new_pgaudit_test
 run_logging_test
 "
 
@@ -37,6 +38,8 @@ test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
 
+DOCKER_EXTRA_ARGS=
+
 volumes_to_clean=
 images_to_clean=()
 files_to_clean=
@@ -910,7 +913,7 @@ run_pgaudit_test()
   # create a dir for config
   config_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
   add_cleanup_command /bin/rm -rf "$config_dir"
-  cp -r "$test_dir"/examples/pgaudit/* "$config_dir"
+  -v DOCKER_EXTRA_ARGS || cp -r "$test_dir"/examples/pgaudit/* "$config_dir"
   setfacl -R -m u:26:rwx "$config_dir"
 
   # create a dir for data
@@ -919,6 +922,7 @@ run_pgaudit_test()
 
   DOCKER_ARGS="
 -e POSTGRESQL_ADMIN_PASSWORD=password
+$DOCKER_EXTRA_ARGS
 -v ${config_dir}:/opt/app-root/src:Z
 -v ${data_dir}:/var/lib/pgsql/data:Z
   " create_container "$name"
@@ -930,7 +934,6 @@ run_pgaudit_test()
   # Deliberately moving heredoc into the container, otherwise it does not work
   # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
   docker exec -i $(get_cid "$name") bash -c "psql <<EOSQL
-CREATE EXTENSION pgaudit;
 SET pgaudit.log = 'read, ddl';
 CREATE DATABASE pgaudittest;
 EOSQL" || ret=2
@@ -996,6 +999,13 @@ run_logging_test()
   echo "  Success!"
 }
 
+run_new_pgaudit_test() {
+    DOCKER_EXTRA_ARGS="
+-e POSTGRESQL_EXTENSIONS=pgaudit
+-e POSTGRESQL_LIBRARIES=pgaudit"
+    run_pgaudit_test
+}
+
 # configuration defaults
 POSTGRESQL_MAX_CONNECTIONS=100
 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0

From b455357a2e281bb224c547dbf948cc8745937181 Mon Sep 17 00:00:00 2001
From: Michael Scherer <misc@redhat.com>
Date: Tue, 30 Jul 2024 10:20:34 -0400
Subject: [PATCH 452/509] Regenerate scripts/doc

---
 10/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 12/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 13/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 14/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 15/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 16/root/usr/bin/run-postgresql                  |  1 +
 .../container-scripts/postgresql/README.md      |  9 +++++++++
 .../container-scripts/postgresql/common.sh      | 17 +++++++++++++++++
 18 files changed, 162 insertions(+)

diff --git a/10/root/usr/bin/run-postgresql b/10/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/10/root/usr/bin/run-postgresql
+++ b/10/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
index 67a23387..7fe07e52 100644
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ b/10/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
index 0b57e599..7a169cc5 100644
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ b/10/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/12/root/usr/bin/run-postgresql b/12/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/12/root/usr/bin/run-postgresql
+++ b/12/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 64bd3afa..3cb10149 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index eff22d87..f480fa2b 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/13/root/usr/bin/run-postgresql b/13/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/13/root/usr/bin/run-postgresql
+++ b/13/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index 6ebb615d..3ee52614 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index afcfc059..ce9a8e92 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/14/root/usr/bin/run-postgresql b/14/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/14/root/usr/bin/run-postgresql
+++ b/14/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
index 74d1ba9d..1f7cd4ba 100644
--- a/14/root/usr/share/container-scripts/postgresql/README.md
+++ b/14/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index b2b7b762..058ebfac 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/15/root/usr/bin/run-postgresql b/15/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/15/root/usr/bin/run-postgresql
+++ b/15/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index b05d9c7a..c91a0565 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index be2eb759..e15bea30 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}
diff --git a/16/root/usr/bin/run-postgresql b/16/root/usr/bin/run-postgresql
index 2367e57e..5ac3e928 100755
--- a/16/root/usr/bin/run-postgresql
+++ b/16/root/usr/bin/run-postgresql
@@ -47,6 +47,7 @@ if $PG_INITIALIZED ; then
     create_users
 fi
 
+create_extensions
 process_extending_files \
     "${APP_DATA}/src/postgresql-start" \
     "${CONTAINER_SCRIPTS_PATH}/start"
diff --git a/16/root/usr/share/container-scripts/postgresql/README.md b/16/root/usr/share/container-scripts/postgresql/README.md
index 4b199357..c79cf68e 100644
--- a/16/root/usr/share/container-scripts/postgresql/README.md
+++ b/16/root/usr/share/container-scripts/postgresql/README.md
@@ -74,6 +74,15 @@ Set to an estimate of how much memory is available for disk caching by the opera
 **`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
  Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
 
+The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
+
+**`POSTGRESQL_LIBRARIES`**
+       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
+
+**`POSTGRESQL_EXTENSIONS`**
+       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
+
+
 You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
 
 **`/var/lib/pgsql/data`**  
diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh
index b7482bdb..c7306a3b 100644
--- a/16/root/usr/share/container-scripts/postgresql/common.sh
+++ b/16/root/usr/share/container-scripts/postgresql/common.sh
@@ -144,6 +144,13 @@ function should_hack_data_sync_retry() {
   return 1
 }
 
+function generate_postgresql_libraries_config() {
+  if [ -v POSTGRESQL_LIBRARIES ]; then
+    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
+  fi
+}
+
+
 # New config is generated every time a container is created. It only contains
 # additional custom settings and is included from $PGDATA/postgresql.conf.
 function generate_postgresql_config() {
@@ -171,6 +178,7 @@ function generate_postgresql_config() {
     echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
   fi
 
+  generate_postgresql_libraries_config
   (
   shopt -s nullglob
   for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
@@ -516,3 +524,12 @@ process_extending_files()
     done
   done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
 }
+
+create_extensions()
+{
+  if [ -v POSTGRESQL_EXTENSIONS ]; then
+    for EXT in $POSTGRESQL_EXTENSIONS; do
+      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
+    done
+  fi
+}

From 6c685c3ec54be19d953bb459e40ee528bd21cf40 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 31 Jul 2024 09:35:39 +0200
Subject: [PATCH 453/509] Remove version 10 from repo

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 10/Dockerfile.rhel8                           |  90 ---
 10/README.md                                  |   1 -
 10/root/usr/bin/container-entrypoint          |   3 -
 10/root/usr/bin/run-postgresql                |  59 --
 10/root/usr/bin/run-postgresql-master         |   5 -
 10/root/usr/bin/run-postgresql-slave          |  37 --
 10/root/usr/bin/usage                         |   4 -
 10/root/usr/libexec/check-container           |  27 -
 10/root/usr/libexec/fix-permissions           |  39 --
 .../container-scripts/postgresql/README.md    | 203 -------
 .../container-scripts/postgresql/common.sh    | 535 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   9 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  23 -
 10/s2i/bin/assemble                           |  14 -
 10/s2i/bin/usage                              |   1 -
 10/test                                       |   1 -
 19 files changed, 1082 deletions(-)
 delete mode 100644 10/Dockerfile.rhel8
 delete mode 120000 10/README.md
 delete mode 100755 10/root/usr/bin/container-entrypoint
 delete mode 100755 10/root/usr/bin/run-postgresql
 delete mode 100755 10/root/usr/bin/run-postgresql-master
 delete mode 100755 10/root/usr/bin/run-postgresql-slave
 delete mode 100755 10/root/usr/bin/usage
 delete mode 100755 10/root/usr/libexec/check-container
 delete mode 100755 10/root/usr/libexec/fix-permissions
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 10/s2i/bin/assemble
 delete mode 100755 10/s2i/bin/usage
 delete mode 120000 10/test

diff --git a/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8
deleted file mode 100644
index 236e488b..00000000
--- a/10/Dockerfile.rhel8
+++ /dev/null
@@ -1,90 +0,0 @@
-FROM ubi8/s2i-core
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV POSTGRESQL_VERSION=10 \
-    POSTGRESQL_PREV_VERSION=9.6 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 10" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql10,postgresql-10" \
-      io.openshift.s2i.assemble-user="26" \
-      name="rhel8/postgresql-10" \
-      com.redhat.component="postgresql-10-container" \
-      version="1" \
-      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
-      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-10" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN yum -y module enable postgresql:10 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    (yum -y reinstall tzdata || yum -y update tzdata ) && \
-    yum -y clean all --enablerepo='*' && \
-    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
-    ENABLED_COLLECTIONS=
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-# Not using VOLUME statement since it's not working in OpenShift Online:
-# https://github.com/sclorg/httpd-container/issues/30
-# VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/10/README.md b/10/README.md
deleted file mode 120000
index d359f030..00000000
--- a/10/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/10/root/usr/bin/container-entrypoint b/10/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/10/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/10/root/usr/bin/run-postgresql b/10/root/usr/bin/run-postgresql
deleted file mode 100755
index 5ac3e928..00000000
--- a/10/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-
-process_extending_files \
-        "${APP_DATA}/src/postgresql-pre-start" \
-        "${CONTAINER_SCRIPTS_PATH}/pre-start"
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-# Use insanely large timeout (24h) to ensure that the potential recovery has
-# enough time here to happen (unless liveness probe kills us).  Note that in
-# case of server failure this command still exists immediately.
-pg_ctl start -w --timeout 86400 -o "-h ''"
-
-# This is just a pedantic safety measure (the timeout above is unlikely to
-# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
-# returns exit_status=0 even if the server is still starting.  For more info
-# see the issue#297 and
-# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
-pg_isready
-
-if $PG_INITIALIZED ; then
-    process_extending_files \
-        "${APP_DATA}/src/postgresql-init" \
-        "${CONTAINER_SCRIPTS_PATH}/init"
-    migrate_db
-    create_users
-fi
-
-create_extensions
-process_extending_files \
-    "${APP_DATA}/src/postgresql-start" \
-    "${CONTAINER_SCRIPTS_PATH}/start"
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/10/root/usr/bin/run-postgresql-master b/10/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/10/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/10/root/usr/bin/run-postgresql-slave b/10/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index 82113b76..00000000
--- a/10/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/recovery.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/10/root/usr/bin/usage b/10/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/10/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/10/root/usr/libexec/check-container b/10/root/usr/libexec/check-container
deleted file mode 100755
index 04a5b625..00000000
--- a/10/root/usr/libexec/check-container
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-if test x"$1" = "x--live"; then
-    # Since livenessProbe is about to detect container deadlocks, and we
-    # so far don't know about real deadlocks to be detected -- we keep
-    # liveness probe to report that container is always ready (as long as
-    # we are able to execute shell, enable collections, etc., which is
-    # good for container sanity testing anyways).
-    exit 0
-fi
-
-# Readiness check follows, the --timeout is set to "infinite" because it
-# is handled externally (readinessProbe.timeoutSeconds).
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
diff --git a/10/root/usr/libexec/fix-permissions b/10/root/usr/libexec/fix-permissions
deleted file mode 100755
index f4b2f86d..00000000
--- a/10/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-documentation="\
-Recursively fix permissions on the given directories to allow GID=0
-read/write regular files and read/write/execute directories.
-
-To run this command, you have to be in the group root=0!"
-
-uid=26
-write=w
-
-usage ()
-{
-    cat >&2 <<EOF
-$0: Error: ${1-usage error}
-
-Usage: $0 [--read-only] DIR [DIR ..]
-
-$documentation
-EOF
-    exit 1
-}
-
-while test $# -gt 0; do
-    case $1 in
-    --read-only) write= ; shift ;;
-    *) break ;;
-    esac
-done
-
-test $# -eq 0 && usage "no DIR specified"
-
-for dir; do
-    test -d "$dir" || usage "no such directory '$dir'"
-    echo >&2 "fixing permissions on '$dir' directory"
-    find "$dir" -exec chown "$uid:0" {} \;
-    find "$dir" -exec chmod "g+r$write" {} \;
-    find "$dir" -type d -exec chmod g+x {} +
-done
diff --git a/10/root/usr/share/container-scripts/postgresql/README.md b/10/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 7fe07e52..00000000
--- a/10/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,203 +0,0 @@
-# PostgreSQL 10 SQL Database Server Container Image
-
-This container image features the PostgreSQL 10 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
-
-Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
-
-## Overview
-
-This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
-
-## Usage
-
-Assuming you are utilizing the `rhel8/postgresql-10` image, which is accessible via the `postgresql:10` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
-
-```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel8/postgresql-10
-```
-
-This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
-
-> Note: The user `postgres` is reserved for internal usage
-
-Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
-
-In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
-
-```bash
-$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=10 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
-```
-
-If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/10/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/10/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
-
-## Environment Variables and Volumes
-
-The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
- User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
- Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
- Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
- Password for the `postgres` admin account (optional)
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
- Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
- Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
- Set to 'yes' to ignore sql import errors
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
- The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
- Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
- Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
-The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
-
-**`POSTGRESQL_LIBRARIES`**
-       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
-
-**`POSTGRESQL_EXTENSIONS`**
-       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
- PostgreSQL database cluster directory
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `podman run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```bash
-$ setfacl -m u:26:-wx /your/data/dir
-$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-## Data Migration
-
-The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
-
-```bash
-$ podman run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    rhel8/postgresql-13
-```
-
-The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
-
-If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different type of PostgreSQL container may likely fail.
-
-If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
-
-Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
-
-Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
-
-**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
-
-## PostgreSQL Auto-Tuning
-
-When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
-
-The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
-
-## PostgreSQL Admin Account
-
-By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
-
-## Changing Passwords
-
-As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
-
-## Extending Image
-
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-10` image, available via `postgresql:10` imagestream tag in Openshift.
-
-To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
-
-```bash
-$ oc new-app postgresql:10~https://github.com/sclorg/postgresql-container.git \
-  --name new-postgresql \
-  --context-dir examples/extending-image/ \
-  -e POSTGRESQL_USER=user \
-  -e POSTGRESQL_DATABASE=db \
-  -e POSTGRESQL_PASSWORD=password
-```
-
-or via `s2i`:
-
-```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git rhel8/postgresql-10 new-postgresql
-```
-
-The directory passed to Openshift should contain one or more of the following directories:
-
-##### `postgresql-pre-start/`
-
-This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
-
-##### `postgresql-cfg/`
-
-Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
-
-##### `postgresql-init/`
-
-This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
-
-##### `postgresql-start/`
-
-This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
-
----
-
-During the s2i build, all provided files are copied into the `/opt/app-root/src`
-directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
-
-## Troubleshooting
-
-Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
-
-```bash
-podman logs <container>
-```
-
-Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
-
-## Additional Resources
-
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/10/root/usr/share/container-scripts/postgresql/common.sh b/10/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 7a169cc5..00000000
--- a/10/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,535 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# Converts the version in format x.y or x.y.z to a number.
-version2number ()
-{
-    local old_IFS=$IFS
-    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
-    IFS='.'
-    set -- $1
-    while test $depth -ge 1; do
-        depth=$(( depth - 1 ))
-        part=${1-0} ; shift || :
-        printf "%0${width}d" "$part"
-    done
-    IFS=$old_IFS
-}
-
-# On non-intel arches, data_sync_retry = off does not work
-# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
-# Upstream changes that caused this issue:
-# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
-# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
-# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
-# Special handle of data_sync_retry should handle only in some cases.
-# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
-# Return value 0 means the hack is needed.
-function should_hack_data_sync_retry() {
-  [ "$(uname -m)" == 'x86_64' ] && return 1
-  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
-  # this matches all 12.x and versions of 10.x where we need the hack
-  [ "$version_number" -ge 100700 ] && return 0
-  # this matches all 10.x that were not matched above
-  [ "$version_number" -ge 100000 ] && return 1
-  # this matches all 9.x where need the hack
-  [ "$version_number" -ge 090612 ] && return 0
-  # all rest should be older 9.x releases
-  return 1
-}
-
-function generate_postgresql_libraries_config() {
-  if [ -v POSTGRESQL_LIBRARIES ]; then
-    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-}
-
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  if should_hack_data_sync_retry ; then
-    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  # For easier debugging, allow users to log to stderr (will be visible
-  # in the pod logs) using a single variable
-  # https://github.com/sclorg/postgresql-container/issues/353
-  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
-    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  generate_postgresql_libraries_config
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/10/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
-    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    set -o pipefail
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-    set +o pipefail
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
-    rm -rf "$PGDATA/postmaster.pid"
-  fi
-
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
-
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # boot up data directory with old postgres once again to make sure
-  # it was shut down properly, otherwise the upgrade process fails
-  info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
-  info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready" -h 127.0.0.1
-  info_msg "Shutting down old postgresql cleanly..."
-  "${old_pgengine}/pg_ctl" stop
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # On non-intel arches the data_sync_retry set to on
-  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  # Get back the option we changed above
-  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files PATTERN DIR [DIR ...]
-# ---------------------------------------
-# Print all basenames for files matching PATTERN in DIRs.
-get_matched_files ()
-{
-  local pattern=$1 dir
-  shift
-  for dir; do
-    test -d "$dir" || continue
-    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
-  done
-}
-
-# process_extending_files DIR [DIR ...]
-# -------------------------------------
-# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
-# more then one DIR, source only the first occurrence (first found wins).
-process_extending_files()
-{
-  local filename dir
-  while read filename ; do
-    for dir in "$@"; do
-      local file="$dir/$filename"
-      if test -f "$file"; then
-        echo "=> sourcing $file ..."
-        source "$file"
-        set -e # ensure that users don't mistakenly change this
-        break
-      fi
-    done
-  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
-}
-
-create_extensions()
-{
-  if [ -v POSTGRESQL_EXTENSIONS ]; then
-    for EXT in $POSTGRESQL_EXTENSIONS; do
-      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
-    done
-  fi
-}
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index ef04eaae..00000000
--- a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_segments = 400         # in logfile segments, 16MB each; 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/10/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 26d56693..00000000
--- a/10/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-standby_mode = on
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/10/root/usr/share/container-scripts/postgresql/scl_enable b/10/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/10/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index 60d70e36..00000000
--- a/10/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-_psql --set=username="$POSTGRESQL_USER" \
-      --set=password="$POSTGRESQL_PASSWORD" \
-<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
-      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
-<<'EOF'
-ALTER USER :"masteruser" WITH REPLICATION;
-ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
-EOF
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
-<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
-fi
diff --git a/10/s2i/bin/assemble b/10/s2i/bin/assemble
deleted file mode 100755
index 6ed8f7aa..00000000
--- a/10/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions --read-only ./
diff --git a/10/s2i/bin/usage b/10/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/10/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/10/test b/10/test
deleted file mode 120000
index 419df4f9..00000000
--- a/10/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file

From 4e09055723db315d39b05f7ded717e858c8c3803 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 31 Jul 2024 09:38:59 +0200
Subject: [PATCH 454/509] Remove version 10 from GitHub Actions, README's
 templates and imagestreams

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml        |  2 +-
 .github/workflows/openshift-pytests.yml      |  2 +-
 .github/workflows/openshift-tests.yml        |  2 +-
 Makefile                                     |  2 +-
 README.md                                    |  2 --
 examples/postgresql-ephemeral-template.json  |  4 ++--
 examples/postgresql-persistent-template.json |  4 ++--
 imagestreams/imagestreams.yaml               |  4 ++--
 imagestreams/postgresql-rhel-aarch64.json    | 18 ------------------
 imagestreams/postgresql-rhel.json            | 18 ------------------
 specs/multispec.yml                          | 12 ------------
 test/run_test                                |  9 ++-------
 test/run_upgrade_test                        |  2 ++
 13 files changed, 14 insertions(+), 67 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index aa584d98..16bd7965 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -57,7 +57,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13", "14", "15", "16" ]
+        version: [ "11", "12", "13", "14", "15", "16" ]
         os_test: [ "fedora", "rhel8", "rhel9", "c9s" ]
         test_case: [ "container" ]
 
diff --git a/.github/workflows/openshift-pytests.yml b/.github/workflows/openshift-pytests.yml
index 9c22b5c6..f41d96ae 100644
--- a/.github/workflows/openshift-pytests.yml
+++ b/.github/workflows/openshift-pytests.yml
@@ -27,7 +27,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "12", "13", "14", "15", "16" ]
+        version: [ "12", "13", "14", "15", "16" ]
         os_test: [ "rhel8", "rhel9"]
         test_case: [ "openshift-pytest" ]
 
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index be81147b..3c2e1167 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -47,7 +47,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        version: [ "10", "11", "12", "13", "15", "16" ]
+        version: [ "11", "12", "13", "15", "16" ]
         os_test: [ "rhel8", "rhel9"]
         test_case: [ "openshift-4" ]
     steps:
diff --git a/Makefile b/Makefile
index c1fc54ab..378c0a01 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 10 12 13 14 15 16
+VERSIONS = 12 13 14 15 16
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/README.md b/README.md
index 0b2ff603..51c2104f 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,6 @@ For learning more information about concepts used in these container images, see
 
 PostgreSQL versions currently supported are:
 
-- [postgresql-10](https://github.com/sclorg/postgresql-container/tree/master/10)
 - [postgresql-12](https://github.com/sclorg/postgresql-container/tree/master/12)
 - [postgresql-13](https://github.com/sclorg/postgresql-container/tree/master/13)
 - [postgresql-14](https://github.com/sclorg/postgresql-container/tree/master/14)
@@ -99,7 +98,6 @@ To contribute, please follow these steps:
 
 For detailed information on the usage of specific PostgreSQL Dockerfiles, please refer to the corresponding usage documentation:
 
-- [PostgreSQL 10 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/10)
 - [PostgreSQL 12 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/12)
 - [PostgreSQL 13 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/13)
 - [PostgreSQL 14 Usage Documentation](https://github.com/sclorg/postgresql-container/tree/master/14)
diff --git a/examples/postgresql-ephemeral-template.json b/examples/postgresql-ephemeral-template.json
index 31674d1e..d8e4d842 100644
--- a/examples/postgresql-ephemeral-template.json
+++ b/examples/postgresql-ephemeral-template.json
@@ -228,8 +228,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (10-el7, 10-el8, or latest).",
-      "value": "10-el8",
+      "description": "Version of PostgreSQL image to be used (13-el8, 15-el8, or latest).",
+      "value": "15-el8",
       "required": true
     }
   ]
diff --git a/examples/postgresql-persistent-template.json b/examples/postgresql-persistent-template.json
index fa131ed8..fe686d67 100644
--- a/examples/postgresql-persistent-template.json
+++ b/examples/postgresql-persistent-template.json
@@ -252,8 +252,8 @@
     {
       "name": "POSTGRESQL_VERSION",
       "displayName": "Version of PostgreSQL Image",
-      "description": "Version of PostgreSQL image to be used (10-el7, 10-el8, or latest).",
-      "value": "10-el8",
+      "description": "Version of PostgreSQL image to be used (13-el8, 15-el8, or latest).",
+      "value": "15-el8",
       "required": true
     }
   ]
diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index e520914b..fe036bf3 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -19,7 +19,7 @@
     latest: "16-el9"
     distros:
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15, 16]
+        app_versions: [12, 13, 15, 16]
 
       - name: RHEL 9
         app_versions: [13, 15, 16]
@@ -28,7 +28,7 @@
     latest: "16-el9"
     distros:
       - name: RHEL 8
-        app_versions: [10, 12, 13, 15, 16]
+        app_versions: [12, 13, 15, 16]
 
       - name: RHEL 9
         app_versions: [13, 15, 16]
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index ccae28c0..1dd1c669 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -9,24 +9,6 @@
   },
   "spec": {
     "tags": [
-      {
-        "name": "10-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "12-el8",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index ccae28c0..1dd1c669 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -9,24 +9,6 @@
   },
   "spec": {
     "tags": [
-      {
-        "name": "10-el8",
-        "annotations": {
-          "openshift.io/display-name": "PostgreSQL 10 (RHEL 8)",
-          "openshift.io/provider-display-name": "Red Hat, Inc.",
-          "description": "Provides a PostgreSQL 10 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
-          "iconClass": "icon-postgresql",
-          "tags": "database,postgresql",
-          "version": "10"
-        },
-        "from": {
-          "kind": "DockerImage",
-          "name": "registry.redhat.io/rhel8/postgresql-10:latest"
-        },
-        "referencePolicy": {
-          "type": "Local"
-        }
-      },
       {
         "name": "12-el8",
         "annotations": {
diff --git a/specs/multispec.yml b/specs/multispec.yml
index af8e8c5a..d4bc0911 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -56,15 +56,6 @@ specs:
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
 
   version:
-    "10":
-      version: "10"
-      prev_version: "9.6"
-      short: "10"
-      prev_short: "96"
-      common_image_name: "{{ spec.org }}/postgresql-10-{{ spec.prod }}"
-      rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
-      latest_fedora: "f34"
-
     "12":
       version: "12"
       prev_version: "10"
@@ -115,9 +106,6 @@ specs:
 
 matrix:
   include:
-    - version: "10"
-      distros:
-        - rhel-8-x86_64
     - version: "12"
       distros:
         - rhel-8-x86_64
diff --git a/test/run_test b/test/run_test
index e198b8f4..e0557a64 100755
--- a/test/run_test
+++ b/test/run_test
@@ -686,7 +686,7 @@ run_upgrade_test ()
 {
   local ret=0
 
-    local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
+    local upgrade_path="none 12 13 15 16 none" prev= act=
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
@@ -711,12 +711,7 @@ run_migration_test ()
     [ "${OS}" == "fedora" ] && return 0
 
     local from_version
-    # Only test a subset of the migration path on non-intel hosts
-    if [ "$(uname -m)" == "x86_64" ]; then
-        local upgrade_path="9.2 9.4 9.5 9.6 10 12 13 15"
-    else
-        local upgrade_path="10 12 13 15"
-    fi
+    local upgrade_path="12 13 15 16"
 
     for from_version in $upgrade_path; do
         # Do not test migration from $VERSION:remote to $VERSION:local
diff --git a/test/run_upgrade_test b/test/run_upgrade_test
index e91282bc..9e194981 100755
--- a/test/run_upgrade_test
+++ b/test/run_upgrade_test
@@ -74,6 +74,7 @@ assert_upgrade_succeeds ()
         info "Upgrading to $upgrade_to"
         UPGRADE_IMAGE=$(get_image_id "$upgrade_to")
         run_server "$DATADIR" "$UPGRADE_IMAGE" "-e POSTGRESQL_UPGRADE=$1"
+        docker logs "$CID"
         wait_for_postgres "$CID"
         eval "data_${dataspec}_check"
         debug "the upgrading container of version '$upgrade_to' responded"
@@ -81,6 +82,7 @@ assert_upgrade_succeeds ()
         docker rm -f "$CID" >/dev/null
 
         run_server "$DATADIR" "$UPGRADE_IMAGE"
+        docker logs "$CID"
         wait_for_postgres "$CID"
         eval "data_${dataspec}_check"
         debug "restarted server of version '$upgrade_to' responded"

From 256a1215b2a1541f6360d188405d725275d4e5fd Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 16 Aug 2024 14:19:09 +0200
Subject: [PATCH 455/509] Add support for testing postgresql container in C10S

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index 16bd7965..b92035fd 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -58,7 +58,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "11", "12", "13", "14", "15", "16" ]
-        os_test: [ "fedora", "rhel8", "rhel9", "c9s" ]
+        os_test: [ "fedora", "rhel8", "rhel9", "c9s", "c10s" ]
         test_case: [ "container" ]
 
     if: |

From 707980b4b5fc1c5f0b4c36c2820e74b2e79973c1 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Mon, 2 Sep 2024 17:28:50 +0200
Subject: [PATCH 456/509] Remove scl check that makes upgrade not working

The SCL should be NOOP in RHEL8+, but due to wrong check of
VERSION_ID -lt 8, which does not evaluate correctly when
VERSION_ID is '9.4', the paths are incorrectly set to /opt...
in some versions of RHEL, not in Fedora.
---
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 common                                        |  2 +-
 .../container-scripts/postgresql/common.sh    | 25 ++-----------------
 7 files changed, 13 insertions(+), 139 deletions(-)

diff --git a/12/root/usr/share/container-scripts/postgresql/common.sh b/12/root/usr/share/container-scripts/postgresql/common.sh
index f480fa2b..0486c735 100644
--- a/12/root/usr/share/container-scripts/postgresql/common.sh
+++ b/12/root/usr/share/container-scripts/postgresql/common.sh
@@ -313,22 +313,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -345,13 +331,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;
diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh
index ce9a8e92..369fd133 100644
--- a/13/root/usr/share/container-scripts/postgresql/common.sh
+++ b/13/root/usr/share/container-scripts/postgresql/common.sh
@@ -313,22 +313,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -345,13 +331,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
index 058ebfac..70ff0766 100644
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ b/14/root/usr/share/container-scripts/postgresql/common.sh
@@ -313,22 +313,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -345,13 +331,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;
diff --git a/15/root/usr/share/container-scripts/postgresql/common.sh b/15/root/usr/share/container-scripts/postgresql/common.sh
index e15bea30..76a2eb0f 100644
--- a/15/root/usr/share/container-scripts/postgresql/common.sh
+++ b/15/root/usr/share/container-scripts/postgresql/common.sh
@@ -313,22 +313,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -345,13 +331,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;
diff --git a/16/root/usr/share/container-scripts/postgresql/common.sh b/16/root/usr/share/container-scripts/postgresql/common.sh
index c7306a3b..fdb4410e 100644
--- a/16/root/usr/share/container-scripts/postgresql/common.sh
+++ b/16/root/usr/share/container-scripts/postgresql/common.sh
@@ -313,22 +313,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -345,13 +331,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;
diff --git a/common b/common
index 1e271d8d..6f1b33a3 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1e271d8d077833ceed1bc0fcb1eb9629ea5ea410
+Subproject commit 6f1b33a34c353520f4a8fd1906b4f24b13d10d86
diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh
index 7ca09dce..bdad9f9b 100644
--- a/src/root/usr/share/container-scripts/postgresql/common.sh
+++ b/src/root/usr/share/container-scripts/postgresql/common.sh
@@ -314,22 +314,8 @@ run_pgupgrade ()
   old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
   new_raw_version=${POSTGRESQL_VERSION//\./}
 
-  if test "$old_raw_version" = 92; then
-    old_collection=postgresql92
-  else
-    old_collection=rh-postgresql$old_raw_version
-  fi
-
-  # Backward compatibility for RHEL/CentOS 7
-  source /etc/os-release
-
-  if [[ $VERSION_ID -lt 8 ]]; then
-    old_pgengine=/opt/rh/$old_collection/root/usr/bin
-    new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
-  else
-    old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-    new_pgengine=/usr/bin
-  fi
+  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
+  new_pgengine=/usr/bin
 
   PGDATA_new="${PGDATA}-new"
 
@@ -346,13 +332,6 @@ run_pgupgrade ()
   # anyways
   set +u
 
-  # we need to have the old SCL enabled, otherwise the $old_pgengine is not
-  # working.  The scl_source script doesn't pay attention to non-zero exit
-  # statuses, so use 'set +e'.
-  set +e
-  source scl_source enable $old_collection
-  set -e
-
   case $POSTGRESQL_UPGRADE in
     copy) # we accept this
       ;;

From 3e0032a8b1382fc074937ac022a4e1853a565796 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 3 Sep 2024 13:00:16 +0200
Subject: [PATCH 457/509] Use /run/postgresql and create it if not exists

---
 12/Dockerfile.rhel8 | 3 ++-
 13/Dockerfile.c9s   | 3 ++-
 13/Dockerfile.rhel8 | 3 ++-
 13/Dockerfile.rhel9 | 3 ++-
 15/Dockerfile.c9s   | 3 ++-
 15/Dockerfile.rhel8 | 3 ++-
 15/Dockerfile.rhel9 | 3 ++-
 16/Dockerfile.c9s   | 3 ++-
 16/Dockerfile.rhel8 | 3 ++-
 16/Dockerfile.rhel9 | 3 ++-
 src/Dockerfile      | 3 ++-
 11 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index c9b76963..95bd17de 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:12 && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
index 075839d2..ab81c7bc 100644
--- a/13/Dockerfile.c9s
+++ b/13/Dockerfile.c9s
@@ -52,7 +52,8 @@ RUN  { yum -y module enable postgresql:13 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index b6e39c72..93dae539 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:13 && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index a53a917f..31ba1775 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:13 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
index 25ab942f..b13e8303 100644
--- a/15/Dockerfile.c9s
+++ b/15/Dockerfile.c9s
@@ -52,7 +52,8 @@ RUN  { yum -y module enable postgresql:15 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index 09304483..bb278bcb 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:15 && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 23566a5b..f59932a1 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:15 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
index 7eafdcf5..b5f84829 100644
--- a/16/Dockerfile.c9s
+++ b/16/Dockerfile.c9s
@@ -52,7 +52,8 @@ RUN  { yum -y module enable postgresql:16 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
index 510b8f10..adf4b0f4 100644
--- a/16/Dockerfile.rhel8
+++ b/16/Dockerfile.rhel8
@@ -54,7 +54,8 @@ RUN yum -y module enable postgresql:16 && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index a81820a1..030fa59b 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -54,7 +54,8 @@ RUN { yum -y module enable postgresql:16 || :; } && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
diff --git a/src/Dockerfile b/src/Dockerfile
index 3d020c1c..7b6ac535 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -81,7 +81,8 @@ RUN {{ spec.environment_setup }}
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \

From 7758a908cbd837fbf0369b4902c8737976aa69bb Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 3 Sep 2024 16:20:53 +0200
Subject: [PATCH 458/509] Be more cautious about what images to pull

The set is different on different distro versions, so let's not let docker pull
fail, instead be more cautious about what versions we actually expect to exist.
---
 test/run_test | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index e0557a64..2c0c52f9 100755
--- a/test/run_test
+++ b/test/run_test
@@ -686,14 +686,33 @@ run_upgrade_test ()
 {
   local ret=0
 
-    local upgrade_path="none 12 13 15 16 none" prev= act=
+    local upgrade_path= prev= act=
+    case $OS in
+        rhel8)
+            upgrade_path="none 12 13 15 16 none"
+            ;;
+        rhel9|c9s)
+            upgrade_path="none 13 15 16 none"
+            ;;
+        rhel10|c10s)
+            upgrade_path="none 13 15 16 none"
+            ;;
+        fedora)
+            upgrade_path="none 12 13 14 15 16 none"
+            ;;
+        *)
+            echo "unsupported OS variable" >&2
+            return 1
+            ;;
+    esac
+
     for act in $upgrade_path; do
         if test "$act" = $VERSION; then
             break
         fi
         prev=$act
     done
-    test "$prev" != none
+    test "$prev" != none || return 0
     # Check if the previous image is available in the registry
     docker pull "$(get_image_id "$prev:remote")" || return 0
 

From b7f073f512a85a88d047a71656b471fecde7f0c7 Mon Sep 17 00:00:00 2001
From: Honza Horak <hhorak@redhat.com>
Date: Tue, 3 Sep 2024 16:21:03 +0200
Subject: [PATCH 459/509] Fix pagila RPM url and wait patiently for the server
 start

Previous epel7 mirror URL does not work after RHEL7 EOL, but the same
RPM is still available in koji. A test for a correct download should
hopefully make the download failure easier to debug in the future.

The check functions did not actually wait when the first podman exec
failed, so in case the server was not up soon, the check failed too
early. It is ok to wait for the server a bit, so let's repeat the
podman exec with psql until it succeeds or 30s pass.
---
 test/pagila.sh        |  6 +++---
 test/pg-test-lib.sh   | 29 ++++++++++++++++++++---------
 test/run_upgrade_test |  1 +
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/test/pagila.sh b/test/pagila.sh
index 2068de68..36c89a94 100755
--- a/test/pagila.sh
+++ b/test/pagila.sh
@@ -7,9 +7,9 @@ die() { echo "$*" >&2 ; exit 1; }
 test -z "$CID" && die "Please specify \$CID variable"
 # test -d common || die "Please run me from git root directory"
 
-pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/
+pagila_koji=https://kojipkgs.fedoraproject.org//packages/pagila/0.10.1/3.el7/noarch/
 pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
-pagila=$pagila_mirror$pagila_base
+pagila=$pagila_koji$pagila_base
 pagila_file="$PWD/postgresql-container-pagila.sql"
 pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae802701
 
@@ -20,7 +20,7 @@ pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae80270
   test ! -f "$pagila_file" || exit 0
 
   set -o pipefail
-  curl -s "$pagila" > "$pagila_base"
+  curl -s "$pagila" > "$pagila_base" || die "ERROR: Could not download $pagila"
   for file in ./usr/share/pagila/pagila-schema.sql \
       ./usr/share/pagila/pagila-data.sql \
       ./usr/share/pagila/pagila-insert-data.sql ; \
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index bb240df8..3bc6749d 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -54,14 +54,19 @@ data_pagila_check ()
 2'
     # Deliberately moving heredoc into the container, otherwise it does not work
     # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
-    local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
+    SECONDS=15
+    local output
+    while [ $SECONDS -gt 0 ] ; do
+        output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
 select count(*) from information_schema.tables where table_schema = 'public';
 select count(*) from information_schema.triggers;
 select count(*) from staff;
-EOF"
+EOF" 2>/dev/null || :
 )
-    test "$exp_output" = "$output" \
-        || error "Unexpected output: '$output', expected: '$exp_output'"
+        test "$exp_output" = "$output" && return
+        sleep 1
+    done
+    error "Unexpected output: '$output', expected: '$exp_output', and/or we waited too long"
 }
 
 data_empty_create ()
@@ -82,11 +87,17 @@ data_empty_check ()
 3'
     # Deliberately moving heredoc into the container, otherwise it does not work
     # in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
-    local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
+    SECONDS=15
+    local output
+    while [ $SECONDS -gt 0 ] ; do
+        output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
 select * from blah order by id;
-EOF"
+EOF" 2>/dev/null || :
 )
-    test "$exp_output" = "$output" || error "Unexpected output '$output'"
+        test "$exp_output" = "$output" && return
+	sleep 1
+    done
+    error "Unexpected output '$output', expected: '$exp_output', and/or we waited too long"
 }
 
 # wait_for_postgres CID
@@ -105,9 +116,9 @@ wait_for_postgres ()
         output=$(docker exec -i "$cid" bash -c \
             "psql -h localhost -tA -c 'select 1;' 2>/dev/null || :")
         case $output in
-        1*) return ;;
+        1*) debug "server up" ; return ;;
         "") ;;
-        *) echo "$output" ; false ;;
+        *) debug "server down" ; echo "$output" ; false ;;
         esac
         sleep 1
         counter=$(( counter + 1 ))
diff --git a/test/run_upgrade_test b/test/run_upgrade_test
index 9e194981..410d0cdf 100755
--- a/test/run_upgrade_test
+++ b/test/run_upgrade_test
@@ -29,6 +29,7 @@ background_container ()
 {
     CID=$(eval "docker run -d $2 $1 $3")
     test -n "$CID"
+    info "Started container $CID" >&2
 }
 
 # run_server DATADIR IMAGE_ID DOCKER_ARGS

From 3c7bb2f43ae646c633ceb9e6c534582ec421ca42 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 12:18:52 +0200
Subject: [PATCH 460/509] Do not build PSQL12, 13, 14 on Fedora at all.

It is based on F38 that has already reached EOL

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 Makefile              |  2 +-
 specs/multispec.yml   | 41 ++++++++++++++++++-----------------------
 src/Dockerfile.fedora |  4 ++--
 3 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile
index 378c0a01..b8212b2e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Variables are documented in common/build.sh.
 BASE_IMAGE_NAME = postgresql
-VERSIONS = 12 13 14 15 16
+VERSIONS = 12 13 15 16
 OPENSHIFT_NAMESPACES = 9.2
 NOT_RELEASED_VERSIONS =
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index d4bc0911..a5ae7f21 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -2,9 +2,9 @@ version: 1
 
 specs:
   distroinfo:
-    fedora:
+    fedora39:
       distros:
-        - fedora-38-x86_64
+        - fedora-39-x86_64
       s2i_base: quay.io/fedora/s2i-core
       org: "fedora"
       prod: "fedora"
@@ -12,8 +12,18 @@ specs:
       redhat_component: "postgresql-{{ spec.short }}-container"
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       pkgs: "postgresql-server postgresql-contrib"
-      environment_setup: >-4
-           { yum -y module enable postgresql:{{ spec.version }} || :; } && \
+
+    fedora40:
+      distros:
+        - fedora-40-x86_64
+      s2i_base: quay.io/fedora/s2i-core
+      org: "fedora"
+      prod: "fedora"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+      redhat_component: "postgresql-{{ spec.short }}-container"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "postgresql-server postgresql-contrib"
+
     rhel8:
        distros:
          - rhel-8-x86_64
@@ -75,16 +85,6 @@ specs:
       rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
       latest_fedora: "f38"
 
-    "14":
-      version: "14"
-      prev_version: "13"
-      short: "14"
-      prev_short: "13"
-      common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      rhel_image_name: "fedora/postgresql-{{ spec.short }}"
-      c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f38"
-
     "15":
       version: "15"
       prev_version: "13"
@@ -92,7 +92,7 @@ specs:
       prev_short: "13"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       rhel_image_name: "rhel8/postgresql-{{ spec.short }}"
-      latest_fedora: "f38"
+      latest_fedora: "f40"
 
     "16":
       version: "16"
@@ -101,7 +101,7 @@ specs:
       prev_short: "15"
       common_image_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
       c9s_image_name: "sclorg/postgresql-{{ spec.short }}-c9s"
-      latest_fedora: "f39"
+      latest_fedora: "f40"
 
 
 matrix:
@@ -109,25 +109,20 @@ matrix:
     - version: "12"
       distros:
         - rhel-8-x86_64
-        - fedora-38-x86_64
     - version: "13"
       distros:
         - rhel-8-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
-        - fedora-38-x86_64
-    - version: "14"
-      distros:
-        - fedora-38-x86_64
     - version: "15"
       distros:
         - rhel-8-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
-        - fedora-38-x86_64
+        - fedora-40-x86_64
     - version: "16"
       distros:
         - rhel-8-x86_64
         - rhel-9-x86_64
         - centos-stream-9-x86_64
-        - fedora-38-x86_64
+        - fedora-40-x86_64
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index b5d6cd38..87a3b82c 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -1,5 +1,5 @@
-{% if spec.version == "16" %}
-FROM quay.io/fedora/s2i-core:39
+{% if spec.version == "16" or spec.version == "15" %}
+FROM quay.io/fedora/s2i-core:40
 {% else %}
 FROM quay.io/fedora/s2i-core:38
 {% endif %}

From fa9cff7dc94d0820d517846f2885c13810cc4b3e Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 12:19:52 +0200
Subject: [PATCH 461/509] Remove generated source for Fedora PSQL images

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 12/Dockerfile.fedora                          |  89 ---
 13/Dockerfile.fedora                          |  89 ---
 14/Dockerfile.fedora                          |  89 ---
 14/README.md                                  |   1 -
 14/root/usr/bin/container-entrypoint          |   3 -
 14/root/usr/bin/run-postgresql                |  59 --
 14/root/usr/bin/run-postgresql-master         |   5 -
 14/root/usr/bin/run-postgresql-slave          |  39 --
 14/root/usr/bin/usage                         |   4 -
 14/root/usr/libexec/check-container           |  27 -
 14/root/usr/libexec/fix-permissions           |  39 --
 .../container-scripts/postgresql/README.md    | 203 -------
 .../container-scripts/postgresql/common.sh    | 514 ------------------
 ...ustom-postgresql-replication.conf.template |   7 -
 .../openshift-custom-postgresql.conf.template |  21 -
 .../openshift-custom-recovery.conf.template   |   8 -
 .../container-scripts/postgresql/scl_enable   |   3 -
 .../postgresql/start/set_passwords.sh         |  23 -
 14/s2i/bin/assemble                           |  14 -
 14/s2i/bin/usage                              |   1 -
 14/test                                       |   1 -
 21 files changed, 1239 deletions(-)
 delete mode 100644 12/Dockerfile.fedora
 delete mode 100644 13/Dockerfile.fedora
 delete mode 100644 14/Dockerfile.fedora
 delete mode 120000 14/README.md
 delete mode 100755 14/root/usr/bin/container-entrypoint
 delete mode 100755 14/root/usr/bin/run-postgresql
 delete mode 100755 14/root/usr/bin/run-postgresql-master
 delete mode 100755 14/root/usr/bin/run-postgresql-slave
 delete mode 100755 14/root/usr/bin/usage
 delete mode 100755 14/root/usr/libexec/check-container
 delete mode 100755 14/root/usr/libexec/fix-permissions
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/README.md
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/common.sh
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/scl_enable
 delete mode 100644 14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
 delete mode 100755 14/s2i/bin/assemble
 delete mode 100755 14/s2i/bin/usage
 delete mode 120000 14/test

diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora
deleted file mode 100644
index afcc8bc9..00000000
--- a/12/Dockerfile.fedora
+++ /dev/null
@@ -1,89 +0,0 @@
-FROM quay.io/fedora/s2i-core:38
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV NAME=postgresql \
-    VERSION=0 \
-    ARCH=x86_64 \
-    \
-    POSTGRESQL_VERSION=12 \
-    POSTGRESQL_PREV_VERSION=10 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 12" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql12" \
-      com.redhat.component="$NAME" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="fedora/$NAME-12" \
-      version="0" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-12"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
-    INSTALL_PKGS+=" findutils xz" && \
-    INSTALL_PKGS+=" pgaudit" && \
-    dnf -y module enable postgresql:12 && \
-    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    dnf clean all && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora
deleted file mode 100644
index 124e1bb2..00000000
--- a/13/Dockerfile.fedora
+++ /dev/null
@@ -1,89 +0,0 @@
-FROM quay.io/fedora/s2i-core:38
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV NAME=postgresql \
-    VERSION=0 \
-    ARCH=x86_64 \
-    \
-    POSTGRESQL_VERSION=13 \
-    POSTGRESQL_PREV_VERSION=12 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 13" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql13" \
-      com.redhat.component="$NAME" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="fedora/$NAME-13" \
-      version="0" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-13"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
-    INSTALL_PKGS+=" findutils xz" && \
-    INSTALL_PKGS+=" pgaudit" && \
-    dnf -y module enable postgresql:13 && \
-    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    dnf clean all && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora
deleted file mode 100644
index 888ebc88..00000000
--- a/14/Dockerfile.fedora
+++ /dev/null
@@ -1,89 +0,0 @@
-FROM quay.io/fedora/s2i-core:38
-
-# PostgreSQL image for OpenShift.
-# Volumes:
-#  * /var/lib/psql/data   - Database cluster for PostgreSQL
-# Environment:
-#  * $POSTGRESQL_USER     - Database user name
-#  * $POSTGRESQL_PASSWORD - User's password
-#  * $POSTGRESQL_DATABASE - Name of the database to create
-#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
-#                           PostgreSQL administrative account
-
-ENV NAME=postgresql \
-    VERSION=0 \
-    ARCH=x86_64 \
-    \
-    POSTGRESQL_VERSION=14 \
-    POSTGRESQL_PREV_VERSION=13 \
-    HOME=/var/lib/pgsql \
-    PGUSER=postgres \
-    APP_DATA=/opt/app-root
-
-ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
-    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
-The image contains the client and server programs that you'll need to \
-create, run, maintain and access a PostgreSQL DBMS server."
-
-LABEL summary="$SUMMARY" \
-      description="$DESCRIPTION" \
-      io.k8s.description="$DESCRIPTION" \
-      io.k8s.display-name="PostgreSQL 14" \
-      io.openshift.expose-services="5432:postgresql" \
-      io.openshift.tags="database,postgresql,postgresql14" \
-      com.redhat.component="$NAME" \
-      maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
-      name="fedora/$NAME-14" \
-      version="0" \
-      usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-14"
-
-EXPOSE 5432
-
-COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
-
-# This image must forever use UID 26 for postgres user so our volumes are
-# safe in the future. This should *never* change, the last test is there
-# to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
-    INSTALL_PKGS+=" findutils xz" && \
-    INSTALL_PKGS+=" pgaudit" && \
-    dnf -y module enable postgresql:14 && \
-    dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
-    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
-    dnf clean all && \
-    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
-    mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
-
-# Get prefix path and path to scripts rather than hard-code them in scripts
-ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
-
-COPY root /
-COPY ./s2i/bin/ $STI_SCRIPTS_PATH
-
-# Hard links are not supported in Testing Farm approach during sync to guest
-# operation system. Therefore tests are failing on error
-# /usr/libexec/s2i/run no such file or directory
-RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
-
-VOLUME ["/var/lib/pgsql/data"]
-
-# S2I permission fixes
-# --------------------
-# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
-#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
-#    Such process wouldn't be able to execute the default 'assemble' script
-#    correctly (it transitively executes 'fix-permissions' script).  So let's
-#    add the 'postgres' user into 'root' group here
-#
-# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
-#    anyways) to assure that s2i process is actually able to _read_ the
-#    user-specified scripting.
-RUN usermod -a -G root postgres && \
-    /usr/libexec/fix-permissions --read-only "$APP_DATA"
-
-USER 26
-
-ENTRYPOINT ["container-entrypoint"]
-CMD ["run-postgresql"]
diff --git a/14/README.md b/14/README.md
deleted file mode 120000
index d359f030..00000000
--- a/14/README.md
+++ /dev/null
@@ -1 +0,0 @@
-root/usr/share/container-scripts/postgresql/README.md
\ No newline at end of file
diff --git a/14/root/usr/bin/container-entrypoint b/14/root/usr/bin/container-entrypoint
deleted file mode 100755
index 5fc44481..00000000
--- a/14/root/usr/bin/container-entrypoint
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec "$@"
diff --git a/14/root/usr/bin/run-postgresql b/14/root/usr/bin/run-postgresql
deleted file mode 100755
index 5ac3e928..00000000
--- a/14/root/usr/bin/run-postgresql
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "${CONTAINER_SCRIPTS_PATH}/common.sh"
-
-set_pgdata
-
-process_extending_files \
-        "${APP_DATA}/src/postgresql-pre-start" \
-        "${CONTAINER_SCRIPTS_PATH}/pre-start"
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-# Is this brand new data volume?
-PG_INITIALIZED=false
-
-if [ ! -f "$PGDATA/postgresql.conf" ]; then
-  initialize_database
-  PG_INITIALIZED=:
-else
-  try_pgupgrade
-fi
-
-# Use insanely large timeout (24h) to ensure that the potential recovery has
-# enough time here to happen (unless liveness probe kills us).  Note that in
-# case of server failure this command still exists immediately.
-pg_ctl start -w --timeout 86400 -o "-h ''"
-
-# This is just a pedantic safety measure (the timeout above is unlikely to
-# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
-# returns exit_status=0 even if the server is still starting.  For more info
-# see the issue#297 and
-# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
-pg_isready
-
-if $PG_INITIALIZED ; then
-    process_extending_files \
-        "${APP_DATA}/src/postgresql-init" \
-        "${CONTAINER_SCRIPTS_PATH}/init"
-    migrate_db
-    create_users
-fi
-
-create_extensions
-process_extending_files \
-    "${APP_DATA}/src/postgresql-start" \
-    "${CONTAINER_SCRIPTS_PATH}/start"
-
-pg_ctl stop
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/14/root/usr/bin/run-postgresql-master b/14/root/usr/bin/run-postgresql-master
deleted file mode 100755
index 79e7cc24..00000000
--- a/14/root/usr/bin/run-postgresql-master
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-exec run-postgresql "$@"
diff --git a/14/root/usr/bin/run-postgresql-slave b/14/root/usr/bin/run-postgresql-slave
deleted file mode 100755
index 586bf5d7..00000000
--- a/14/root/usr/bin/run-postgresql-slave
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-export ENABLE_REPLICATION=true
-
-set -eu
-export_vars=$(cgroup-limits) ; export $export_vars
-
-source "$CONTAINER_SCRIPTS_PATH"/common.sh
-
-set_pgdata
-
-function initialize_replica() {
-  echo "Initializing PostgreSQL slave ..."
-  # TODO: Validate and reuse existing data?
-  rm -rf $PGDATA
-  PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
-
-  # PostgreSQL recovery configuration.
-  generate_postgresql_recovery_config
-  cat >> "$PGDATA/postgresql.auto.conf" <<EOF
-
-# Custom OpenShift recovery configuration:
-include '${POSTGRESQL_RECOVERY_FILE}'
-EOF
-  # activate standby mode
-  touch "$PGDATA/standby.signal"
-}
-
-check_env_vars
-generate_passwd_file
-generate_postgresql_config
-
-wait_for_postgresql_master
-export MASTER_FQDN=$(postgresql_master_addr)
-initialize_replica
-
-unset_env_vars
-echo "Starting server..."
-exec postgres "$@"
diff --git a/14/root/usr/bin/usage b/14/root/usr/bin/usage
deleted file mode 100755
index fa9228b5..00000000
--- a/14/root/usr/bin/usage
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cat /usr/share/container-scripts/postgresql/README.md
-
diff --git a/14/root/usr/libexec/check-container b/14/root/usr/libexec/check-container
deleted file mode 100755
index 04a5b625..00000000
--- a/14/root/usr/libexec/check-container
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-# Try whether the PostgreSQL in container accepts connections.
-#
-# With --live, be tolerant to starting PG server.  If the /bin/postgres binary
-# has not been executed yet (the shell script is initializing the container),
-# wait for it (this script might run forever, we expect that the timeout is
-# maintained externally).
-
-test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
-
-if test x"$1" = "x--live"; then
-    # Since livenessProbe is about to detect container deadlocks, and we
-    # so far don't know about real deadlocks to be detected -- we keep
-    # liveness probe to report that container is always ready (as long as
-    # we are able to execute shell, enable collections, etc., which is
-    # good for container sanity testing anyways).
-    exit 0
-fi
-
-# Readiness check follows, the --timeout is set to "infinite" because it
-# is handled externally (readinessProbe.timeoutSeconds).
-pg_isready -q \
-    -h 127.0.0.1 \
-    ${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
-    ${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
-    --timeout 0
diff --git a/14/root/usr/libexec/fix-permissions b/14/root/usr/libexec/fix-permissions
deleted file mode 100755
index f4b2f86d..00000000
--- a/14/root/usr/libexec/fix-permissions
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-documentation="\
-Recursively fix permissions on the given directories to allow GID=0
-read/write regular files and read/write/execute directories.
-
-To run this command, you have to be in the group root=0!"
-
-uid=26
-write=w
-
-usage ()
-{
-    cat >&2 <<EOF
-$0: Error: ${1-usage error}
-
-Usage: $0 [--read-only] DIR [DIR ..]
-
-$documentation
-EOF
-    exit 1
-}
-
-while test $# -gt 0; do
-    case $1 in
-    --read-only) write= ; shift ;;
-    *) break ;;
-    esac
-done
-
-test $# -eq 0 && usage "no DIR specified"
-
-for dir; do
-    test -d "$dir" || usage "no such directory '$dir'"
-    echo >&2 "fixing permissions on '$dir' directory"
-    find "$dir" -exec chown "$uid:0" {} \;
-    find "$dir" -exec chmod "g+r$write" {} \;
-    find "$dir" -type d -exec chmod g+x {} +
-done
diff --git a/14/root/usr/share/container-scripts/postgresql/README.md b/14/root/usr/share/container-scripts/postgresql/README.md
deleted file mode 100644
index 1f7cd4ba..00000000
--- a/14/root/usr/share/container-scripts/postgresql/README.md
+++ /dev/null
@@ -1,203 +0,0 @@
-# PostgreSQL 14 SQL Database Server Container Image
-
-This container image features the PostgreSQL 14 SQL database server, suitable for OpenShift and general applications. Users have the option to select from RHEL, CentOS Stream, and Fedora-based images. RHEL images can be found in the [Red Hat Container Catalog](https://access.redhat.com/containers/), while CentOS Stream images are available on [Quay.io](https://quay.io/organization/sclorg), and Fedora images can be accessed in [Quay.io](https://quay.io/organization/fedora). The resulting image can be executed using [podman](https://github.com/containers/libpod).
-
-Please note that while the examples provided in this README utilize `podman`, it is possible to substitute any instance of `podman` with `docker` and the same arguments. `podman` can be installed with on Fedora with command `dnf install podman-docker`.
-
-## Overview
-
-This container image offers a containerized version of the PostgreSQL postgres daemon and client application. The postgres server daemon accepts client connections and grants access to PostgreSQL database content on behalf of said clients. For more information regarding the PostgreSQL project, please visit the official project website (https://www.postgresql.org/).
-
-## Usage
-
-Assuming you are utilizing the `fedora/postgresql-14` image, which is accessible via the `postgresql:14` imagestream tag in Openshift, the following steps outline usage. To set only the mandatory environment variables without storing the database in a host directory, execute this command:
-
-```bash
-$ podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 fedora/postgresql-14
-```
-
-This command creates a container named `postgresql_database` running PostgreSQL with the database `db` and a user with the credentials `user:pass`.
-
-> Note: The user `postgres` is reserved for internal usage
-
-Port 5432 will be exposed and mapped to the host. For persistent database storage across container executions, include the `-v /host/db/path:/var/lib/pgsql/data` argument (refer to the information below). This directory will serve as the PostgreSQL database cluster.
-
-In an Openshift environment, the same can be achieved using templates provided by Openshift or found in [examples](https://github.com/sclorg/postgresql-container/tree/master/examples):
-
-```bash
-$ oc process -f examples/postgresql-ephemeral-template.json -p POSTGRESQL_VERSION=14 -p POSTGRESQL_USER=user -p POSTGRESQL_PASSWORD=pass -p POSTGRESQL_DATABASE=db | oc create -f -
-```
-
-If the database cluster directory has not been initialized, the entrypoint script will first run [`initdb`](http://www.postgresql.org/docs/14/static/app-initdb.html) to set up the necessary database users and passwords. Once the database has been initialized or if it was previously in place,[`postgres`](http://www.postgresql.org/docs/14/static/app-postgres.html) will be executed and run as PID 1. The detached container can be stopped using `podman stop postgresql_database`.
-
-## Environment Variables and Volumes
-
-The image recognizes the following environment variables, which can be set during initialization by passing `-e VAR=VALUE` to the Docker run command.
-
-**`POSTGRESQL_USER`**  
- User name for PostgreSQL account to be created
-
-**`POSTGRESQL_PASSWORD`**  
- Password for the user account
-
-**`POSTGRESQL_DATABASE`**  
- Database name
-
-**`POSTGRESQL_ADMIN_PASSWORD`**  
- Password for the `postgres` admin account (optional)
-
-Alternatively, the following options are related to migration scenario:
-
-**`POSTGRESQL_MIGRATION_REMOTE_HOST`**  
- Hostname/IP to migrate from
-
-**`POSTGRESQL_MIGRATION_ADMIN_PASSWORD`**  
- Password for the remote 'postgres' admin user
-
-**`POSTGRESQL_MIGRATION_IGNORE_ERRORS (optional, default 'no')`**  
- Set to 'yes' to ignore sql import errors
-
-The following environment variables influence the PostgreSQL configuration file. They are all optional.
-
-**`POSTGRESQL_MAX_CONNECTIONS (default: 100)`**  
- The maximum number of client connections allowed
-
-**`POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)`**  
- Sets the maximum number of transactions that can be in the "prepared" state. If you are using prepared transactions, you will probably want this to be at least as large as max_connections
-
-**`POSTGRESQL_SHARED_BUFFERS (default: 1/4 of memory limit or 32M)`**
-Sets how much memory is dedicated to PostgreSQL to use for caching data
-
-**`POSTGRESQL_EFFECTIVE_CACHE_SIZE (default: 1/2 of memory limit or 128M)`**
-Set to an estimate of how much memory is available for disk caching by the operating system and within the database itself
-
-**`POSTGRESQL_LOG_DESTINATION (default: /var/lib/pgsql/data/userdata/log/postgresql-*.log)`**  
- Where to log errors, the default is `/var/lib/pgsql/data/userdata/log/postgresql-*.log` and this file is rotated; it can be changed to `/dev/stderr` to make debugging easier
-
-The following environment variables deal with extensions. They are all optional, and if not set, no extensions will be enabled.
-
-**`POSTGRESQL_LIBRARIES`**
-       A comma-separated list of libraries that Postgres will preload using shared_preload_libraries.
-
-**`POSTGRESQL_EXTENSIONS`**
-       A space-separated list of extensions to create when the server start. Once created, the extensions will stay even if the variable is cleared.
-
-
-You can also set the following mount points by passing the `-v /host/dir:/container/dir:Z` flag to Docker.
-
-**`/var/lib/pgsql/data`**  
- PostgreSQL database cluster directory
-
-**Notice: When mouting a directory from the host into the container, ensure that the mounted
-directory has the appropriate permissions and that the owner and group of the directory
-matches the user UID or name which is running inside the container.**
-
-Typically (unless you use `podman run -u` option) processes in container
-run under UID 26, so -- on GNU/Linux -- you can fix the datadir permissions
-for example by:
-
-```bash
-$ setfacl -m u:26:-wx /your/data/dir
-$ podman run <...> -v /your/data/dir:/var/lib/pgsql/data:Z <...>
-```
-
-## Data Migration
-
-The PostgreSQL container supports data migration from a remote PostgreSQL server. Execute the following command to initiate the process:
-
-```bash
-$ podman run -d --name postgresql_database \
-    -e POSTGRESQL_MIGRATION_REMOTE_HOST=172.17.0.2 \
-    -e POSTGRESQL_MIGRATION_ADMIN_PASSWORD=remoteAdminP@ssword \
-    [ OPTIONAL_CONFIGURATION_VARIABLES ]
-    rhel8/postgresql-13
-```
-
-The migration is performed using the **dump and restore** method (running `pg_dumpall` against the remote cluster and importing the dump locally using `psql`). The process is streamed (via a Unix pipeline), eliminating the need for intermediate dump files and conserving storage space.
-
-If some SQL commands fail during the application, the default behavior of the migration script is to fail, ensuring an **all** or **nothing** outcome for scripted, unattended migration. In most cases, successful migration is expected (but not guaranteed) when migrating from a previous version of the PostgreSQL server container created using the same principles as this one (e.g., migration from `rhel8/postgresql-12` to `rhel8/postgresql-13`).
-Migration from a different type of PostgreSQL container may likely fail.
-
-If the **all or nothing** principle is unsuitable for your needs and you are aware of the risks, the optional `POSTGRESQL_MIGRATION_IGNORE_ERRORS` option offers a **best effort** migration (some data may be lost; users must review the standard error output and address issues manually after migration).
-
-Please note that the container image provides assistance for user convenience, but fully automatic migration is not guaranteed. Before starting the database migration, be prepared to perform manual steps to ensure all data is migrated.
-
-Do not use variables like `POSTGRESQL_USER`in migration scenarios, as all data (including information about databases, roles, and passwords) is copied from the old cluster. Make sure to use the same `OPTIONAL_CONFIGURATION_VARIABLES`as you did when initializing the old PostgreSQL container. If the remote cluster has some non-default configurations, you may need to manually copy the configuration files.
-
-**Security warning**: Be aware that IP communication between the old and new PostgreSQL clusters is not encrypted by default. Users must configure SSL on the remote cluster or ensure security through other means.
-
-## PostgreSQL Auto-Tuning
-
-When running the PostgreSQL image with the `--memory` parameter set, and no values provided for `POSTGRESQL_SHARED_BUFFERS` and
-`POSTGRESQL_EFFECTIVE_CACHE_SIZE` these values are automatically calculated based on the `--memory` parameter value.
-
-The values are determined using the [upstream](https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server) formulas. For `shared_buffers` 1/4 of the provided memory is used, and for `effective_cache_size`, 1/2 of the provided memory is set.
-
-## PostgreSQL Admin Account
-
-By default, the admin account `postgres` has no password set, allowing only local connections. To set a password, define the `POSTGRESQL_ADMIN_PASSWORD` environment variable when initializing your container. This allows you to log in to the `postgres` account remotely, while local connections still do not require a password.
-
-## Changing Passwords
-
-As passwords are part of the image configuration, the only supported method for changing passwords for the database user (`POSTGRESQL_USER`) and `postgres`
-admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `POSTGRESQL_ADMIN_PASSWORD`, respectively.
-
-Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
-
-## Extending Image
-
-You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `fedora/postgresql-14` image, available via `postgresql:14` imagestream tag in Openshift.
-
-To build a customized image `new-postgresql` with configuration from `https://github.com/sclorg/postgresql-container/tree/master/examples/extending-image`, run:
-
-```bash
-$ oc new-app postgresql:14~https://github.com/sclorg/postgresql-container.git \
-  --name new-postgresql \
-  --context-dir examples/extending-image/ \
-  -e POSTGRESQL_USER=user \
-  -e POSTGRESQL_DATABASE=db \
-  -e POSTGRESQL_PASSWORD=password
-```
-
-or via `s2i`:
-
-```
-$ s2i build --context-dir examples/extending-image/ https://github.com/sclorg/postgresql-container.git fedora/postgresql-14 new-postgresql
-```
-
-The directory passed to Openshift should contain one or more of the following directories:
-
-##### `postgresql-pre-start/`
-
-This directory should contain `*.sh` files that will be sourced during the early start of the container. At this point, there is no PostgreSQL daemon running in the background.
-
-##### `postgresql-cfg/`
-
-Configuration files (`*.conf`) contained in this directory will be included at the end of the image's postgresql.conf file.
-
-##### `postgresql-init/`
-
-This directory should contain shell scripts (`*.sh`) that are sourced when the database is freshly initialized (after a successful initdb run, which makes the data directory non-empty). At the time of sourcing these scripts, the local PostgreSQL server is running. For re-deployment scenarios with a persistent data directory, the scripts are not sourced (no-op).
-
-##### `postgresql-start/`
-
-This directory has the same semantics as `postgresql-init/`, except that these scripts are always sourced (after `postgresql-init/` scripts, if they exist).
-
----
-
-During the s2i build, all provided files are copied into the `/opt/app-root/src`
-directory in the new image. Only one file with the same name can be used for customization, and user-provided files take precedence over default files in `/usr/share/container-scripts/`. This means that it is possible to overwrite the default files.
-
-## Troubleshooting
-
-Initially, the postgres daemon logs are written to the standard output, making them accessible within the container log. To examine the log, execute the following command:
-
-```bash
-podman logs <container>
-```
-
-Subsequently, log output is redirected to the logging collector process and will appear in the "pg_log" directory.
-
-## Additional Resources
-
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/14/root/usr/share/container-scripts/postgresql/common.sh b/14/root/usr/share/container-scripts/postgresql/common.sh
deleted file mode 100644
index 70ff0766..00000000
--- a/14/root/usr/share/container-scripts/postgresql/common.sh
+++ /dev/null
@@ -1,514 +0,0 @@
-# Configuration settings.
-export POSTGRESQL_MAX_CONNECTIONS=${POSTGRESQL_MAX_CONNECTIONS:-100}
-export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIONS:-0}
-
-# Perform auto-tuning based on the container cgroups limits (only when the
-# limits are set).
-# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
-# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
-if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" ]]; then
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
-else
-    # Use 1/4 of given memory for shared buffers
-    shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
-    # Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
-    effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
-    export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
-    export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
-fi
-
-export POSTGRESQL_LOG_DESTINATION=${POSTGRESQL_LOG_DESTINATION:-}
-
-export POSTGRESQL_RECOVERY_FILE=$HOME/openshift-custom-recovery.conf
-export POSTGRESQL_CONFIG_FILE=$HOME/openshift-custom-postgresql.conf
-
-postinitdb_actions=
-
-# match . files when moving userdata below
-shopt -s dotglob
-# extglob enables the !(userdata) glob pattern below.
-shopt -s extglob
-
-function usage() {
-  if [ $# == 1 ]; then
-    echo >&2 "error: $1"
-  fi
-
-  cat >&2 <<EOF
-For general container run, you must either specify the following environment
-variables:
-  POSTGRESQL_USER  POSTGRESQL_PASSWORD  POSTGRESQL_DATABASE
-Or the following environment variable:
-  POSTGRESQL_ADMIN_PASSWORD
-Or both.
-
-To migrate data from different PostgreSQL container:
-  POSTGRESQL_MIGRATION_REMOTE_HOST (hostname or IP address)
-  POSTGRESQL_MIGRATION_ADMIN_PASSWORD (password of remote 'postgres' user)
-And optionally:
-  POSTGRESQL_MIGRATION_IGNORE_ERRORS=yes (default is 'no')
-
-Optional settings:
-  POSTGRESQL_MAX_CONNECTIONS (default: 100)
-  POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
-  POSTGRESQL_SHARED_BUFFERS (default: 32MB)
-
-For more information see /usr/share/container-scripts/postgresql/README.md
-within the container or visit https://github.com/sclorg/postgresql-container.
-EOF
-  exit 1
-}
-
-function check_env_vars() {
-  if [[ -v POSTGRESQL_USER || -v POSTGRESQL_PASSWORD || -v POSTGRESQL_DATABASE ]]; then
-    # one var means all three must be specified
-    [[ -v POSTGRESQL_USER && -v POSTGRESQL_PASSWORD && -v POSTGRESQL_DATABASE ]] || usage
-
-    [ ${#POSTGRESQL_USER}     -le 63 ] || usage "PostgreSQL username too long (maximum 63 characters)"
-    [ ${#POSTGRESQL_DATABASE} -le 63 ] || usage "Database name too long (maximum 63 characters)"
-    postinitdb_actions+=",simple_db"
-  fi
-
-  if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",admin_pass"
-  fi
-
-  if [ -v POSTGRESQL_MIGRATION_REMOTE_HOST -a \
-       -v POSTGRESQL_MIGRATION_ADMIN_PASSWORD ]; then
-    postinitdb_actions+=",migration"
-  fi
-
-  case "$postinitdb_actions" in
-    ,simple_db,admin_pass) ;;
-    ,migration|,simple_db|,admin_pass) ;;
-    *) usage ;;
-  esac
-}
-
-# Make sure env variables don't propagate to PostgreSQL process.
-function unset_env_vars() {
-  unset POSTGRESQL_{DATABASE,USER,PASSWORD,ADMIN_PASSWORD}
-}
-
-# postgresql_master_addr lookups the 'postgresql-master' DNS and get list of the available
-# endpoints. Each endpoint is a PostgreSQL container with the 'master' PostgreSQL running.
-function postgresql_master_addr() {
-  local service_name=${POSTGRESQL_MASTER_SERVICE_NAME:-postgresql-master}
-  local endpoints=$(dig ${service_name} A +search | grep ";${service_name}" | cut -d ';' -f 2 2>/dev/null)
-  # FIXME: This is for debugging (docker run)
-  if [ -v POSTGRESQL_MASTER_IP ]; then
-    endpoints=${POSTGRESQL_MASTER_IP:-}
-  fi
-  if [ -z "$endpoints" ]; then
-    >&2 echo "Failed to resolve PostgreSQL master IP address"
-    exit 3
-  fi
-  echo -n "$(echo $endpoints | cut -d ' ' -f 1)"
-}
-
-# Converts the version in format x.y or x.y.z to a number.
-version2number ()
-{
-    local old_IFS=$IFS
-    local to_print= depth=${2-3} width=${3-2} sum=0 one_part
-    IFS='.'
-    set -- $1
-    while test $depth -ge 1; do
-        depth=$(( depth - 1 ))
-        part=${1-0} ; shift || :
-        printf "%0${width}d" "$part"
-    done
-    IFS=$old_IFS
-}
-
-# On non-intel arches, data_sync_retry = off does not work
-# Upstream discussion: https://www.postgresql.org/message-id/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
-# Upstream changes that caused this issue:
-# https://github.com/postgres/postgres/commit/483520eca426fb1b428e8416d1d014ac5ad80ef4
-# https://github.com/postgres/postgres/commit/9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1
-# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779150
-# Special handle of data_sync_retry should handle only in some cases.
-# These cases are: non-intel architectures, and version higher or equal 12.0, 10.7, 9.6.12
-# Return value 0 means the hack is needed.
-function should_hack_data_sync_retry() {
-  [ "$(uname -m)" == 'x86_64' ] && return 1
-  local version_number=$(version2number "$(pg_ctl -V | sed -e 's/^pg_ctl (PostgreSQL) //')")
-  # this matches all 12.x and versions of 10.x where we need the hack
-  [ "$version_number" -ge 100700 ] && return 0
-  # this matches all 10.x that were not matched above
-  [ "$version_number" -ge 100000 ] && return 1
-  # this matches all 9.x where need the hack
-  [ "$version_number" -ge 090612 ] && return 0
-  # all rest should be older 9.x releases
-  return 1
-}
-
-function generate_postgresql_libraries_config() {
-  if [ -v POSTGRESQL_LIBRARIES ]; then
-    echo "shared_preload_libraries='${POSTGRESQL_LIBRARIES}'" >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-}
-
-
-# New config is generated every time a container is created. It only contains
-# additional custom settings and is included from $PGDATA/postgresql.conf.
-function generate_postgresql_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql.conf.template" \
-      > "${POSTGRESQL_CONFIG_FILE}"
-
-  if [ "${ENABLE_REPLICATION}" == "true" ]; then
-    envsubst \
-        < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-postgresql-replication.conf.template" \
-        >> "${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  if should_hack_data_sync_retry ; then
-    echo "data_sync_retry = on" >>"${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  # For easier debugging, allow users to log to stderr (will be visible
-  # in the pod logs) using a single variable
-  # https://github.com/sclorg/postgresql-container/issues/353
-  if [ -n "${POSTGRESQL_LOG_DESTINATION:-}" ] ; then
-    echo "log_destination = 'stderr'" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "logging_collector = on" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "log_directory = '$(dirname "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
-    echo "log_filename = '$(basename "${POSTGRESQL_LOG_DESTINATION}")'" >>"${POSTGRESQL_CONFIG_FILE}"
-  fi
-
-  generate_postgresql_libraries_config
-  (
-  shopt -s nullglob
-  for conf in "${APP_DATA}"/src/postgresql-cfg/*.conf; do
-    echo include \'${conf}\' >> "${POSTGRESQL_CONFIG_FILE}"
-  done
-  )
-}
-
-function generate_postgresql_recovery_config() {
-  envsubst \
-      < "${CONTAINER_SCRIPTS_PATH}/openshift-custom-recovery.conf.template" \
-      > "${POSTGRESQL_RECOVERY_FILE}"
-}
-
-# Generate passwd file based on current uid
-function generate_passwd_file() {
-  export USER_ID=$(id -u)
-  export GROUP_ID=$(id -g)
-  grep -v -e ^postgres -e ^$USER_ID -e ^$(id -un) /etc/passwd > "$HOME/passwd"
-  echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
-  export LD_PRELOAD=libnss_wrapper.so
-  export NSS_WRAPPER_PASSWD=${HOME}/passwd
-  export NSS_WRAPPER_GROUP=/etc/group
-}
-
-initdb_wrapper ()
-{
-  # Initialize the database cluster with utf8 support enabled by default.
-  # This might affect performance, see:
-  # http://www.postgresql.org/docs/14/static/locale.html
-  LANG=${LANG:-en_US.utf8} "$@"
-}
-
-function initialize_database() {
-  initdb_wrapper initdb
-
-  # PostgreSQL configuration.
-  cat >> "$PGDATA/postgresql.conf" <<EOF
-
-# Custom OpenShift configuration:
-include '${POSTGRESQL_CONFIG_FILE}'
-EOF
-
-  # Access control configuration.
-  # FIXME: would be nice-to-have if we could allow connections only from
-  #        specific hosts / subnet
-  cat >> "$PGDATA/pg_hba.conf" <<EOF
-
-#
-# Custom OpenShift configuration starting at this point.
-#
-
-# Allow connections from all hosts.
-host all all all md5
-
-# Allow replication connections from all hosts.
-host replication all all md5
-EOF
-}
-
-function create_users() {
-  if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-    createuser "$POSTGRESQL_USER"
-    createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
-  fi
-
-  if [ -v POSTGRESQL_MASTER_USER ]; then
-    createuser "$POSTGRESQL_MASTER_USER"
-    echo "ALTER DATABASE postgres OWNER TO $POSTGRESQL_MASTER_USER;" | psql
-    echo "GRANT ALL PRIVILEGES on DATABASE postgres TO $POSTGRESQL_MASTER_USER;" | psql
-  fi
-}
-
-migrate_db ()
-{
-    test "$postinitdb_actions" = ",migration" || return 0
-
-    set -o pipefail
-    # Migration path.
-    (
-        if [ ${POSTGRESQL_MIGRATION_IGNORE_ERRORS-no} = no ]; then
-            echo '\set ON_ERROR_STOP on'
-        fi
-        # initdb automatically creates 'postgres' role;  creating it again would
-        # fail the whole migration so we drop it here
-        PGPASSWORD="$POSTGRESQL_MIGRATION_ADMIN_PASSWORD" \
-        pg_dumpall -h "$POSTGRESQL_MIGRATION_REMOTE_HOST" \
-            | grep -v '^CREATE ROLE postgres;'
-    ) | psql
-    set +o pipefail
-}
-
-function set_pgdata ()
-{
-  export PGDATA=$HOME/data/userdata
-  # create a subdirectory that the user owns
-  mkdir -p "$PGDATA"
-  # backwards compatibility case, we used to put the data here,
-  # move it into our new expected location (userdata)
-  if [ -e ${HOME}/data/PG_VERSION ]; then
-    pushd "${HOME}/data"
-    # move everything except the userdata directory itself, into the userdata directory.
-    mv !(userdata) "userdata"
-    popd
-  fi
-  # ensure sane perms for postgresql startup
-  chmod 700 "$PGDATA"
-}
-
-function wait_for_postgresql_master() {
-  while true; do
-    master_fqdn=$(postgresql_master_addr)
-    echo "Waiting for PostgreSQL master (${master_fqdn}) to accept connections ..."
-    if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-      PGPASSWORD=${POSTGRESQL_ADMIN_PASSWORD} psql "postgresql://postgres@${master_fqdn}" -c "SELECT 1;" && return 0
-    else
-      PGPASSWORD=${POSTGRESQL_PASSWORD} psql "postgresql://${POSTGRESQL_USER}@${master_fqdn}/${POSTGRESQL_DATABASE}" -c "SELECT 1;" && return 0
-    fi
-    sleep 1
-  done
-}
-
-
-run_pgupgrade ()
-(
-  # Remove .pid file if the file persists after ugly shut down
-  if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
-    rm -rf "$PGDATA/postmaster.pid"
-  fi
-
-  optimized=false
-  old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
-  new_raw_version=${POSTGRESQL_VERSION//\./}
-
-  old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
-  new_pgengine=/usr/bin
-
-  PGDATA_new="${PGDATA}-new"
-
-  printf >&2 "\n==========  \$PGDATA upgrade: %s -> %s  ==========\n\n" \
-             "$POSTGRESQL_PREV_VERSION" \
-             "$POSTGRESQL_VERSION"
-
-  info_msg () { printf >&2 "\n===>  $*\n\n" ;}
-
-  # pg_upgrade writes logs to cwd, so go to the persistent storage first
-  cd "$HOME"/data
-
-  # disable this because of scl_source, 'set +u' just makes the code ugly
-  # anyways
-  set +u
-
-  case $POSTGRESQL_UPGRADE in
-    copy) # we accept this
-      ;;
-    hardlink)
-      optimized=:
-      ;;
-    *)
-      echo >&2 "Unsupported value: \$POSTGRESQL_UPGRADE=$POSTGRESQL_UPGRADE"
-      false
-      ;;
-  esac
-
-  # boot up data directory with old postgres once again to make sure
-  # it was shut down properly, otherwise the upgrade process fails
-  info_msg "Starting old postgresql once again for a clean shutdown..."
-  "${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
-  info_msg "Waiting for postgresql to be ready for shutdown again..."
-  "${old_pgengine}/pg_isready" -h 127.0.0.1
-  info_msg "Shutting down old postgresql cleanly..."
-  "${old_pgengine}/pg_ctl" stop
-
-  # Ensure $PGDATA_new doesn't exist yet, so we can immediately remove it if
-  # there's some problem.
-  test ! -e "$PGDATA_new"
-
-  # initialize the database
-  info_msg "Initialize new data directory; we will migrate to that."
-  initdb_cmd=( initdb_wrapper "$new_pgengine"/initdb "$PGDATA_new" )
-  eval "\${initdb_cmd[@]} ${POSTGRESQL_UPGRADE_INITDB_OPTIONS-}" || \
-    { rm -rf "$PGDATA_new" ; false ; }
-
-  upgrade_cmd=(
-      "$new_pgengine"/pg_upgrade
-      "--old-bindir=$old_pgengine"
-      "--new-bindir=$new_pgengine"
-      "--old-datadir=$PGDATA"
-      "--new-datadir=$PGDATA_new"
-  )
-
-  # Dangerous --link option, we loose $DATADIR if something goes wrong.
-  ! $optimized || upgrade_cmd+=(--link)
-
-  # User-specififed options for pg_upgrade.
-  eval "upgrade_cmd+=(${POSTGRESQL_UPGRADE_PGUPGRADE_OPTIONS-})"
-
-  # On non-intel arches the data_sync_retry set to on
-  sed -i -e 's/data_sync_retry/#data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  # the upgrade
-  info_msg "Starting the pg_upgrade process."
-
-  # Once we stop support for PostgreSQL 9.4, we don't need
-  # REDHAT_PGUPGRADE_FROM_RHEL hack as we don't upgrade from 9.2 -- that means
-  # that we don't need to fiddle with unix_socket_director{y,ies} option.
-  REDHAT_PGUPGRADE_FROM_RHEL=1 \
-  "${upgrade_cmd[@]}" || { cat $(find "$PGDATA_new"/.. -name pg_upgrade_server.log) ; rm -rf "$PGDATA_new" && false ; }
-
-  # Move the important configuration and remove old data.  This is highly
-  # careless, but we can't do more for this over-automatized process.
-  info_msg "Swap the old and new PGDATA and cleanup."
-  mv "$PGDATA"/*.conf "$PGDATA_new"
-  rm -rf "$PGDATA"
-  mv "$PGDATA_new" "$PGDATA"
-
-  # Get back the option we changed above
-  sed -i -e 's/#data_sync_retry/data_sync_retry/' "${POSTGRESQL_CONFIG_FILE}"
-
-  info_msg "Upgrade DONE."
-)
-
-
-# Run right after container startup, when the data volume is already initialized
-# (not initialized by this container run) and thus there exists a chance that
-# the data was generated by incompatible PostgreSQL major version.
-try_pgupgrade ()
-{
-  local versionfile="$PGDATA"/PG_VERSION version upgrade_available
-
-  # This file always exists.
-  test -f "$versionfile"
-  version=$(cat "$versionfile")
-
-  # If we don't support pg_upgrade, skip.
-  test -z "${POSTGRESQL_PREV_VERSION-}" && return 0
-
-  if test "$POSTGRESQL_VERSION" = "$version"; then
-      # No need to call pg_upgrade.
-
-      # Mistakenly requests upgrade?  If not, just start the DB.
-      test -z "${POSTGRESQL_UPGRADE-}" && return 0
-
-      # Make _sure_ we have this safety-belt here, otherwise our users would
-      # just specify '-e POSTGRESQL_UPGRADE=hardlink' permanently, even for
-      # re-deployment cases when upgrade is not needed.  Setting such
-      # unfortunate default could mean that pg_upgrade might (after some user
-      # mistake) migrate (or even destruct, especially with --link) the old data
-      # directory with limited rollback options, if any.
-      echo >&2
-      echo >&2 "== WARNING!! =="
-      echo >&2 "PostgreSQL server version matches the datadir PG_VERSION."
-      echo >&2 "The \$POSTGRESQL_UPGRADE makes no sense and you probably"
-      echo >&2 "made some mistake, keeping the variable set you might"
-      echo >&2 "risk a data loss in future!"
-      echo >&2 "==============="
-      echo >&2
-
-      # Exit here, but allow _really explicit_ foot-shot.
-      ${POSTGRESQL_UPGRADE_FORCE-false}
-      return 0
-  fi
-
-  # At this point in code we know that PG_VERSION doesn't match the PostgreSQL
-  # server major version;  this might mean that user either (a) mistakenly
-  # deploys from a bad image, or (b) user wants to perform upgrade.  For the
-  # upgrade we require explicit request -- just to avoid disasters in (a)-cases.
-
-  if test -z "${POSTGRESQL_UPGRADE-}"; then
-    echo >&2 "Incompatible data directory.  This container image provides"
-    echo >&2 "PostgreSQL '$POSTGRESQL_VERSION', but data directory is of"
-    echo >&2 "version '$version'."
-    echo >&2
-    echo >&2 "This image supports automatic data directory upgrade from"
-    echo >&2 "'$POSTGRESQL_PREV_VERSION', please _carefully_ consult image documentation"
-    echo >&2 "about how to use the '\$POSTGRESQL_UPGRADE' startup option."
-    # We could wait for postgresql startup failure (there's no risk of data dir
-    # corruption), but fail rather early.
-    false
-  fi
-
-  # We support pg_upgrade process only from previous version of this container
-  # (upgrade to N to N+1 is possible, so e.g. 9.4 to 9.5).
-  if test "$POSTGRESQL_PREV_VERSION" != "$version"; then
-    echo >&2 "With this container image you can only upgrade from data directory"
-    echo >&2 "of version '$POSTGRESQL_PREV_VERSION', not '$version'."
-    false
-  fi
-
-  run_pgupgrade
-}
-
-# get_matched_files PATTERN DIR [DIR ...]
-# ---------------------------------------
-# Print all basenames for files matching PATTERN in DIRs.
-get_matched_files ()
-{
-  local pattern=$1 dir
-  shift
-  for dir; do
-    test -d "$dir" || continue
-    find -L "$dir" -maxdepth 1 -type f -name "$pattern" -printf "%f\n"
-  done
-}
-
-# process_extending_files DIR [DIR ...]
-# -------------------------------------
-# Source all *.sh files in DIRs in alphabetical order, but if the file exists in
-# more then one DIR, source only the first occurrence (first found wins).
-process_extending_files()
-{
-  local filename dir
-  while read filename ; do
-    for dir in "$@"; do
-      local file="$dir/$filename"
-      if test -f "$file"; then
-        echo "=> sourcing $file ..."
-        source "$file"
-        set -e # ensure that users don't mistakenly change this
-        break
-      fi
-    done
-  done <<<"$(get_matched_files '*.sh' "$@" | sort -u)"
-}
-
-create_extensions()
-{
-  if [ -v POSTGRESQL_EXTENSIONS ]; then
-    for EXT in $POSTGRESQL_EXTENSIONS; do
-      psql -c "CREATE EXTENSION IF NOT EXISTS ${EXT};"
-    done
-  fi
-}
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
deleted file mode 100644
index d133e511..00000000
--- a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql-replication.conf.template
+++ /dev/null
@@ -1,7 +0,0 @@
-# required on master for replication
-wal_level = hot_standby         # minimal, archive, hot_standby, or logical
-max_wal_senders = 6             # max number of walsender processes
-wal_keep_size = 6400            # number of segments (400) * size of segments (16MB each); 0 disables
-
-# required on replicas for replication
-hot_standby = on
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
deleted file mode 100644
index 3c2bc7f3..00000000
--- a/14/root/usr/share/container-scripts/postgresql/openshift-custom-postgresql.conf.template
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-# Listen on all interfaces.
-listen_addresses = '*'
-
-# Determines the maximum number of concurrent connections to the database server. Default: 100
-max_connections = ${POSTGRESQL_MAX_CONNECTIONS}
-
-# Allow each connection to use a prepared transaction
-max_prepared_transactions = ${POSTGRESQL_MAX_PREPARED_TRANSACTIONS}
-
-# Sets the amount of memory the database server uses for shared memory buffers. Default: 32MB
-shared_buffers = ${POSTGRESQL_SHARED_BUFFERS}
-
-# Sets the planner's assumption about the effective size of the disk cache that is available to a single query
-effective_cache_size = ${POSTGRESQL_EFFECTIVE_CACHE_SIZE}
diff --git a/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template b/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
deleted file mode 100644
index 58d8e336..00000000
--- a/14/root/usr/share/container-scripts/postgresql/openshift-custom-recovery.conf.template
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Custom OpenShift configuration.
-#
-# NOTE: This file is rewritten every time the container is started!
-#       Changes to this file will be overwritten.
-#
-
-primary_conninfo = 'host=${MASTER_FQDN} port=5432 user=${POSTGRESQL_MASTER_USER} password=${POSTGRESQL_MASTER_PASSWORD}'
diff --git a/14/root/usr/share/container-scripts/postgresql/scl_enable b/14/root/usr/share/container-scripts/postgresql/scl_enable
deleted file mode 100644
index 1d967f9b..00000000
--- a/14/root/usr/share/container-scripts/postgresql/scl_enable
+++ /dev/null
@@ -1,3 +0,0 @@
-# This will make scl collection binaries work out of box.
-unset BASH_ENV PROMPT_COMMAND ENV
-source scl_source enable $ENABLED_COLLECTIONS
diff --git a/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh b/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
deleted file mode 100644
index 60d70e36..00000000
--- a/14/root/usr/share/container-scripts/postgresql/start/set_passwords.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-_psql () { psql --set ON_ERROR_STOP=1 "$@" ; }
-
-if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
-_psql --set=username="$POSTGRESQL_USER" \
-      --set=password="$POSTGRESQL_PASSWORD" \
-<<< "ALTER USER :\"username\" WITH ENCRYPTED PASSWORD :'password';"
-fi
-
-if [ -v POSTGRESQL_MASTER_USER ]; then
-_psql --set=masteruser="$POSTGRESQL_MASTER_USER" \
-      --set=masterpass="$POSTGRESQL_MASTER_PASSWORD" \
-<<'EOF'
-ALTER USER :"masteruser" WITH REPLICATION;
-ALTER USER :"masteruser" WITH ENCRYPTED PASSWORD :'masterpass';
-EOF
-fi
-
-if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then
-_psql --set=adminpass="$POSTGRESQL_ADMIN_PASSWORD" \
-<<<"ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD :'adminpass';"
-fi
diff --git a/14/s2i/bin/assemble b/14/s2i/bin/assemble
deleted file mode 100755
index 6ed8f7aa..00000000
--- a/14/s2i/bin/assemble
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-shopt -s dotglob
-echo "---> Installing application source ..."
-
-
-mv /tmp/src/* ./
-
-# Fix source directory permissions
-/usr/libexec/fix-permissions --read-only ./
diff --git a/14/s2i/bin/usage b/14/s2i/bin/usage
deleted file mode 100755
index 9f413123..00000000
--- a/14/s2i/bin/usage
+++ /dev/null
@@ -1 +0,0 @@
-groff -t -man -ETascii /help.1
diff --git a/14/test b/14/test
deleted file mode 120000
index 419df4f9..00000000
--- a/14/test
+++ /dev/null
@@ -1 +0,0 @@
-../test
\ No newline at end of file

From e3737da417ee87bf644dc7fa452088f9ef9d09e4 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 12:20:14 +0200
Subject: [PATCH 462/509] Test PSQL15,16 on the top of F40

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 15/Dockerfile.fedora        | 2 +-
 16/Dockerfile.fedora        | 2 +-
 test/test-lib-postgresql.sh | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index 130f7cca..dc6d6b04 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:38
+FROM quay.io/fedora/s2i-core:40
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index a759f112..1a3421d6 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -1,4 +1,4 @@
-FROM quay.io/fedora/s2i-core:39
+FROM quay.io/fedora/s2i-core:40
 
 # PostgreSQL image for OpenShift.
 # Volumes:
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index 60fc7082..bb255e38 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -75,7 +75,7 @@ function run_latest_imagestreams_test() {
   local result=1
   # Switch to root directory of a container
   echo "Testing the latest version in imagestreams"
-  pushd "${THISDIR}/.." >/dev/null || return 1
+  pushd "${THISDIR}/../.." >/dev/null || return 1
   ct_check_latest_imagestreams
   result=$?
   popd >/dev/null || return 1

From 9ada13f89c155721055782e400ea2393090708a4 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 12:20:35 +0200
Subject: [PATCH 463/509] Do not push PSQL12,13,14 images on quay.io at all.
 EOL in May 2024

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 28dce68a..1e34d515 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -38,30 +38,6 @@ jobs:
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 16
 
-          - dockerfile: "12/Dockerfile.fedora"
-            registry_namespace: "fedora"
-            tag: "12"
-            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
-            image_name: "postgresql-12"
-            docker_context: 12
-
-          - dockerfile: "13/Dockerfile.fedora"
-            registry_namespace: "fedora"
-            tag: "13"
-            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
-            image_name: "postgresql-13"
-            docker_context: 13
-
-          - dockerfile: "14/Dockerfile.fedora"
-            registry_namespace: "fedora"
-            tag: "14"
-            quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
-            quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
-            image_name: "postgresql-14"
-            docker_context: 14
-
           - dockerfile: "15/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "15"
@@ -77,6 +53,7 @@ jobs:
             quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
             image_name: "postgresql-16"
             docker_context: 16
+
     steps:
       - name: check if Dockerfile is c9s, then Build multi arch image and push to quay.io registry
         if: matrix.dockerfile == '13/Dockerfile.c9s' || matrix.dockerfile == '15/Dockerfile.c9s' || matrix.dockerfile == '16/Dockerfile.c9s'

From 1f25ddaf4bb56954386deee0c174c3a14b8035d2 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 13:08:56 +0200
Subject: [PATCH 464/509] Fix Fedora package names for F40

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 15/Dockerfile.fedora  |  8 ++++----
 16/Dockerfile.fedora  |  9 +++++----
 src/Dockerfile.fedora | 19 ++++++++-----------
 3 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/15/Dockerfile.fedora b/15/Dockerfile.fedora
index dc6d6b04..5940bee6 100644
--- a/15/Dockerfile.fedora
+++ b/15/Dockerfile.fedora
@@ -44,17 +44,17 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql15-server postgresql15-contrib nss_wrapper postgresql15-upgrade procps-ng util-linux" && \
     INSTALL_PKGS+=" findutils xz" && \
-    INSTALL_PKGS+=" pgaudit" && \
-    dnf -y module enable postgresql:15 && \
+    INSTALL_PKGS+=" postgresql15-pgaudit" && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora
index 1a3421d6..15ba45d1 100644
--- a/16/Dockerfile.fedora
+++ b/16/Dockerfile.fedora
@@ -44,17 +44,18 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
-    INSTALL_PKGS+=" procps-ng util-linux postgresql16-upgrade" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \
     INSTALL_PKGS+=" findutils xz" && \
-    INSTALL_PKGS+=" postgresql16-pgaudit" && \
+    INSTALL_PKGS+=" pgaudit" && \
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 87a3b82c..82585d34 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -49,20 +49,16 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 {% if spec.version == "16" %}
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
-    INSTALL_PKGS+=" procps-ng util-linux postgresql16-upgrade" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
+    INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \
 {% else %}
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql15-server postgresql15-contrib nss_wrapper postgresql15-upgrade procps-ng util-linux" && \
 {% endif %}
     INSTALL_PKGS+=" findutils xz" && \
-{% if spec.version not in ["9.6", "10", "11", "16"] %}
-    INSTALL_PKGS+=" pgaudit" && \
-{% endif %}
 {% if spec.version == "16" %}
-    INSTALL_PKGS+=" postgresql16-pgaudit" && \
-{% endif %}
-{% if spec.version not in ["16"] %}
-    dnf -y module enable postgresql:{{ spec.version }} && \
+    INSTALL_PKGS+=" pgaudit" && \
+{% else %}
+    INSTALL_PKGS+=" postgresql15-pgaudit" && \
 {% endif %}
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
@@ -70,7 +66,8 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont
     dnf clean all && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql

From f6258dc170b1288492008faf61a9d226a30a67ca Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 13:56:54 +0200
Subject: [PATCH 465/509] Do not wait for container forever

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run_test | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/test/run_test b/test/run_test
index 2c0c52f9..08260e6c 100755
--- a/test/run_test
+++ b/test/run_test
@@ -329,9 +329,14 @@ function test_config_option() {
 # Wait until the PG container becomes ready
 wait_ready ()
 {
-  while ! docker exec "$(get_cid "$1")" /usr/libexec/check-container ; do
+  local max_attempts=20
+  for i in $(seq $max_attempts); do
+    if docker exec "$(get_cid "$1")" /usr/libexec/check-container; then
+      return 0
+    fi
     sleep 1
   done
+  return 1
 }
 
 
@@ -887,7 +892,8 @@ run_s2i_enable_ssl_test()
   DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
     IMAGE_NAME="$s2i_image_name" create_container "$container_name"
 
-  wait_ready "$container_name"
+  wait_ready "$container_name" || \
+    false "FAIL: Container did not start up properly."
   CONTAINER_IP=$(get_container_ip $container_name)
 
   DB=postgres assert_login_access postgres password true
@@ -907,7 +913,8 @@ run_s2i_bake_data_test ()
   DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
     IMAGE_NAME="$s2i_image_name" create_container "$container_name"
 
-  wait_ready "$container_name"
+  wait_ready "$container_name" || \
+    false "FAIL: Container did not start up properly."
 
   test "hello world" == "$(docker exec "$(get_cid "$container_name")" \
                            bash -c "psql -tA -c 'SELECT * FROM test;'")"
@@ -942,7 +949,8 @@ $DOCKER_EXTRA_ARGS
   " create_container "$name"
 
   assert_runtime_option "$name" shared_preload_libraries pgaudit || ret=1
-  wait_ready "$name"
+  wait_ready "$name" || \
+    false "FAIL: Container did not start up properly."
 
   # enable the pgaudit extension
   # Deliberately moving heredoc into the container, otherwise it does not work
@@ -986,7 +994,8 @@ run_logging_test()
   " create_container "$name"
 
   assert_runtime_option "$name" log_destination logging_collector log_directory log_filename
-  wait_ready "$name"
+  wait_ready "$name" || \
+    false "FAIL: Container did not start up properly."
 
   # try loggin in as a user that does not exist to trigger an error log message
   echo 'psql -U nonexistent' | docker exec -i $(get_cid "$name") bash || :

From 0909678cf2eba17c2d03dd6d109d47d7ccfbc9ce Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 6 Sep 2024 14:30:21 +0200
Subject: [PATCH 466/509] Update src/Dockerfile.fedora be more future looking.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile.fedora | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Dockerfile.fedora b/src/Dockerfile.fedora
index 82585d34..5078ddd8 100644
--- a/src/Dockerfile.fedora
+++ b/src/Dockerfile.fedora
@@ -52,13 +52,13 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
     INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \
 {% else %}
-RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql15-server postgresql15-contrib nss_wrapper postgresql15-upgrade procps-ng util-linux" && \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib nss_wrapper postgresql{{ spec.short }}-upgrade procps-ng util-linux" && \
 {% endif %}
     INSTALL_PKGS+=" findutils xz" && \
 {% if spec.version == "16" %}
     INSTALL_PKGS+=" pgaudit" && \
 {% else %}
-    INSTALL_PKGS+=" postgresql15-pgaudit" && \
+    INSTALL_PKGS+=" postgresql{{ spec.short }}-pgaudit" && \
 {% endif %}
     dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \

From 90a2b4dcc9e5f7808ca981bc689fc54ca2d3d18f Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 9 Sep 2024 13:46:01 +0000
Subject: [PATCH 467/509] Bump common from `6f1b33a` to `1e271d8`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `6f1b33a` to `1e271d8`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/6f1b33a34c353520f4a8fd1906b4f24b13d10d86...1e271d8d077833ceed1bc0fcb1eb9629ea5ea410)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 6f1b33a3..1e271d8d 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 6f1b33a34c353520f4a8fd1906b4f24b13d10d86
+Subproject commit 1e271d8d077833ceed1bc0fcb1eb9629ea5ea410

From 1171b9d77c4f37231194b413d03625bb1e3fae1c Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 09:54:48 +0200
Subject: [PATCH 468/509] Add support for building and testing PSQL16 on CentOS
 Stream 10

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.yml        |  3 +++
 specs/multispec.yml | 12 ++++++++++++
 src/Dockerfile      |  4 ++++
 3 files changed, 19 insertions(+)

diff --git a/manifest.yml b/manifest.yml
index bcf27884..b11b4022 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -32,6 +32,9 @@ DISTGEN_MULTI_RULES:
   - src: src/Dockerfile
     dest: Dockerfile.c9s
 
+  - src: src/Dockerfile
+    dest: Dockerfile.c10s
+
   - src: src/Dockerfile.fedora
     dest: Dockerfile.fedora
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index a5ae7f21..69db1896 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -65,6 +65,17 @@ specs:
       environment_setup: >-4
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
 
+    c10s:
+      distros:
+        - centos-stream-10-x86_64
+      s2i_base: quay.io/sclorg/s2i-core-c10s:c10s
+      org: "sclorg"
+      prod: "c10s"
+      openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+      redhat_component: "postgresql-{{ spec.short }}-container"
+      img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
+      pkgs: "postgresql-server postgresql-contrib glibc-locale-source"
+
   version:
     "12":
       version: "12"
@@ -126,3 +137,4 @@ matrix:
         - rhel-9-x86_64
         - centos-stream-9-x86_64
         - fedora-40-x86_64
+        - centos-stream-10-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 7b6ac535..f7ca468f 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -55,6 +55,9 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {% if spec.repo_enable_reason %}
 {{ spec.repo_enable_reason }}
 {% endif %}
+{% if spec.prod == "c10s" %}
+RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+{% else %}
 RUN {{ spec.environment_setup }}
 {% if spec.has_devel_repo %}
   {% if config.os.id == 'rhel' %}
@@ -67,6 +70,7 @@ RUN {{ spec.environment_setup }}
   {% endif %}
 {% endif %}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+{% endif %}
 {% if spec.version not in ["9.6", "10", "11"] %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \

From d1f2e5bd2f29b7e0c3832103b9f118339ed509de Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 09:55:28 +0200
Subject: [PATCH 469/509] Add generated DOckerfile.c10s

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s | 89 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 16/Dockerfile.c10s

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
new file mode 100644
index 00000000..49523525
--- /dev/null
+++ b/16/Dockerfile.c10s
@@ -0,0 +1,89 @@
+FROM quay.io/sclorg/s2i-core-c10s:c10s
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=15 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="sclorg/postgresql-16-c10s" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-16-c10s" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib glibc-locale-source" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
+    rpm -V $INSTALL_PKGS && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]

From 7c8007a869e8b2951ab6df40126213a72f7c20c4 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 09:57:17 +0200
Subject: [PATCH 470/509] Update imagestreams for PSQL 16 and C10S

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/imagestreams.yaml      |  3 +++
 imagestreams/postgresql-centos.json | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index fe036bf3..c0abe2fb 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -15,6 +15,9 @@
       - name: CentOS Stream 9
         app_versions: [13, 15, 16]
 
+      - name: CentOS Stream 10
+        app_versions: [16]
+
   - filename: postgresql-rhel.json
     latest: "16-el9"
     distros:
diff --git a/imagestreams/postgresql-centos.json b/imagestreams/postgresql-centos.json
index bc139daf..797e6ee9 100644
--- a/imagestreams/postgresql-centos.json
+++ b/imagestreams/postgresql-centos.json
@@ -63,6 +63,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (CentOS Stream 10)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on CentOS Stream 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "quay.io/sclorg/postgresql-16-c10s:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {

From de22fd23afda6b48b5c7ecc739d4639ed85f6b29 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 09:57:36 +0200
Subject: [PATCH 471/509] Update build and push with postgresql-16-c10s

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/build-and-push.yml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml
index 1e34d515..5d1a77fa 100644
--- a/.github/workflows/build-and-push.yml
+++ b/.github/workflows/build-and-push.yml
@@ -38,6 +38,14 @@ jobs:
             quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
             docker_context: 16
 
+          - dockerfile: "16/Dockerfile.c10s"
+            registry_namespace: "sclorg"
+            tag: "c10s"
+            image_name: "postgresql-16-c10s"
+            quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
+            quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
+            docker_context: 16
+
           - dockerfile: "15/Dockerfile.fedora"
             registry_namespace: "fedora"
             tag: "15"

From 31bd839f1e354bd23cd239516f7a08f776c8c0df Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 10:12:54 +0200
Subject: [PATCH 472/509] Do not fix /run/postgresql because it does not exist
 during installation

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index 49523525..26134e36 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -51,7 +51,8 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server pos
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql
+    # Directory /var/run/postgresql was removed and /run/postgresql is marked as %ghost dir
+    /usr/libexec/fix-permissions /var/lib/pgsql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \

From 039a6cd553baf56c76c5c0b0210846eba3cdad60 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 21 Aug 2024 10:24:36 +0200
Subject: [PATCH 473/509] Add c10s case to test/pg-test-lib.sh

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/pg-test-lib.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 3bc6749d..9b184df9 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -33,6 +33,10 @@ get_image_id ()
                 ns=c9s
                 local image=quay.io/sclorg/postgresql-${version}-$ns
                 ;;
+            c10s)
+                ns=c10s
+                local image=quay.io/sclorg/postgresql-${version}-$ns
+                ;;
             esac
             docker pull "$image" >/dev/null
             echo "$image"

From 06e6ee2e75b5571381ef89da83a98f3e00cb9685 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 5 Sep 2024 09:19:40 +0200
Subject: [PATCH 474/509] Update 16/Dockerfile.c10s

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index 26134e36..8e6ce27b 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -51,8 +51,8 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server pos
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
     test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
     mkdir -p /var/lib/pgsql/data && \
-    # Directory /var/run/postgresql was removed and /run/postgresql is marked as %ghost dir
-    /usr/libexec/fix-permissions /var/lib/pgsql
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
 
 # Get prefix path and path to scripts rather than hard-code them in scripts
 ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \

From 91d2b425e603f9fc2b234e147b96c2e980322811 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 5 Sep 2024 13:26:52 +0200
Subject: [PATCH 475/509] Remove SCL part, Use gettext-envsubst and
 nss_wrapper-libs

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index f7ca468f..0daebdaa 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -56,20 +56,10 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {{ spec.repo_enable_reason }}
 {% endif %}
 {% if spec.prod == "c10s" %}
-RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
 {% else %}
 RUN {{ spec.environment_setup }}
-{% if spec.has_devel_repo %}
-  {% if config.os.id == 'rhel' %}
-    {% if spec.has_devel_repo.rhel == 'brew' %}
-    yum-config-manager --add-repo http://download.devel.redhat.com/brewroot/repos/rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build/latest/x86_64 && \
-    echo gpgcheck=0 >> /etc/yum.repos.d/download.devel.redhat.com_brewroot_repos_rhscl-{{ spec.rhscl_version.development }}-rh-postgresql{{ spec.version }}-rhel-7-build_latest_x86_64.repo && \
-    {% elif spec.has_devel_repo.rhel == 'beta' %}
-    yum-config-manager --enable rhel-server-rhscl-7-beta-rpms && \
-    {% endif %}
-  {% endif %}
-{% endif %}
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper {{ spec.pkgs }}" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
 {% endif %}
 {% if spec.version not in ["9.6", "10", "11"] %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \

From 0fbaf938ae513f0e08523fc5c523ce176a056daa Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 5 Sep 2024 13:27:45 +0200
Subject: [PATCH 476/509] Add generated files

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 12/Dockerfile.rhel8 | 2 +-
 13/Dockerfile.c9s   | 2 +-
 13/Dockerfile.rhel8 | 2 +-
 13/Dockerfile.rhel9 | 2 +-
 15/Dockerfile.c9s   | 2 +-
 15/Dockerfile.rhel8 | 2 +-
 15/Dockerfile.rhel9 | 2 +-
 16/Dockerfile.c10s  | 2 +-
 16/Dockerfile.c9s   | 2 +-
 16/Dockerfile.rhel8 | 2 +-
 16/Dockerfile.rhel9 | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8
index 95bd17de..c37c48e5 100644
--- a/12/Dockerfile.rhel8
+++ b/12/Dockerfile.rhel8
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum -y module enable postgresql:12 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/13/Dockerfile.c9s b/13/Dockerfile.c9s
index ab81c7bc..4b870a53 100644
--- a/13/Dockerfile.c9s
+++ b/13/Dockerfile.c9s
@@ -42,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN  { yum -y module enable postgresql:13 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/13/Dockerfile.rhel8 b/13/Dockerfile.rhel8
index 93dae539..c736efdc 100644
--- a/13/Dockerfile.rhel8
+++ b/13/Dockerfile.rhel8
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum -y module enable postgresql:13 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index 31ba1775..af4da6c6 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN { yum -y module enable postgresql:13 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/15/Dockerfile.c9s b/15/Dockerfile.c9s
index b13e8303..e78d45b8 100644
--- a/15/Dockerfile.c9s
+++ b/15/Dockerfile.c9s
@@ -42,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN  { yum -y module enable postgresql:15 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/15/Dockerfile.rhel8 b/15/Dockerfile.rhel8
index bb278bcb..302ee20f 100644
--- a/15/Dockerfile.rhel8
+++ b/15/Dockerfile.rhel8
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum -y module enable postgresql:15 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index f59932a1..1a09870a 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN { yum -y module enable postgresql:15 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index 8e6ce27b..c532efe7 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -41,7 +41,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib glibc-locale-source" && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql-server postgresql-contrib glibc-locale-source" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s
index b5f84829..9eaa70c3 100644
--- a/16/Dockerfile.c9s
+++ b/16/Dockerfile.c9s
@@ -42,7 +42,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN  { yum -y module enable postgresql:16 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8
index adf4b0f4..caeb622d 100644
--- a/16/Dockerfile.rhel8
+++ b/16/Dockerfile.rhel8
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN yum -y module enable postgresql:16 && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index 030fa59b..e560842d 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN { yum -y module enable postgresql:16 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \

From 99235a813e722f17b546dfffb40a903c28e875a7 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 10 Sep 2024 09:11:51 +0200
Subject: [PATCH 477/509] Add xz to C10S Dockerfile

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 specs/multispec.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/specs/multispec.yml b/specs/multispec.yml
index 69db1896..659b432c 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -74,7 +74,7 @@ specs:
       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
       redhat_component: "postgresql-{{ spec.short }}-container"
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "postgresql-server postgresql-contrib glibc-locale-source"
+      pkgs: "postgresql-server postgresql-contrib glibc-locale-source xz"
 
   version:
     "12":

From 4c7424b3dce37c4dfb6c45e00df16f5dcf28cc2a Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 10 Sep 2024 09:12:08 +0200
Subject: [PATCH 478/509] Add generated sources

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index c532efe7..4100459f 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -41,7 +41,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql-server postgresql-contrib glibc-locale-source" && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql-server postgresql-contrib glibc-locale-source xz" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \

From 5cf1905413039bf8369a3a8c2d96d1ceb2736f9b Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 13 Sep 2024 11:23:06 +0200
Subject: [PATCH 479/509] Let's use suffix names for C10S

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s  | 7 ++++---
 specs/multispec.yml | 3 ++-
 src/Dockerfile      | 6 ++++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index 4100459f..7b0c9335 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -41,11 +41,12 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql-server postgresql-contrib glibc-locale-source xz" && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql16-server postgresql16-contrib glibc-locale-source xz" && \
+    PSQL_PKGS=postgresql16-server postgresql16-contrib glibc-locale-source xz && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
-    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
-    rpm -V $INSTALL_PKGS && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \
+    rpm -V $INSTALL_PKGS postgresql-server-16 postgresql-contrib-16 && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 659b432c..e45b97c1 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -74,7 +74,8 @@ specs:
       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
       redhat_component: "postgresql-{{ spec.short }}-container"
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "postgresql-server postgresql-contrib glibc-locale-source xz"
+      pkgs: "postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib glibc-locale-source xz"
+      check_pkgs: "postgresql-server-{{ spec.short }} postgresql-contrib-{{ spec.short }}"
 
   version:
     "12":
diff --git a/src/Dockerfile b/src/Dockerfile
index 0daebdaa..01eec376 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -57,6 +57,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {% endif %}
 {% if spec.prod == "c10s" %}
 RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
+    PSQL_PKGS={{ spec.pkgs }} && \
 {% else %}
 RUN {{ spec.environment_setup }}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
@@ -65,8 +66,13 @@ RUN {{ spec.environment_setup }}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
 {% endif %}
+{% if spec.prod == "c10s" %}
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \
+    rpm -V $INSTALL_PKGS {{ spec.check_pkgs }} && \
+{% else %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
     rpm -V $INSTALL_PKGS && \
+{% endif %}
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     {% if spec.post_install %}
     {{ spec.post_install }}

From a101cdea73b8e1344e6cf50d85bdbed5d942e923 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 13 Sep 2024 12:47:11 +0200
Subject: [PATCH 480/509] Replace package nss_wrapper with nss_wrapper-libs

Add PSQL_PKGS as alone variable

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 16/Dockerfile.c10s  | 7 +++----
 specs/multispec.yml | 4 ++--
 src/Dockerfile      | 6 ++++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/16/Dockerfile.c10s b/16/Dockerfile.c10s
index 7b0c9335..388dcdb8 100644
--- a/16/Dockerfile.c10s
+++ b/16/Dockerfile.c10s
@@ -41,12 +41,11 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs postgresql16-server postgresql16-contrib glibc-locale-source xz" && \
-    PSQL_PKGS=postgresql16-server postgresql16-contrib glibc-locale-source xz && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
+    PSQL_PKGS="postgresql16-server postgresql16-contrib postgresql16-upgrade" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
-    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \
-    rpm -V $INSTALL_PKGS postgresql-server-16 postgresql-contrib-16 && \
+    rpm -V $INSTALL_PKGS postgresql-server postgresql-contrib postgresql-upgrade && \
     postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
     yum -y clean all --enablerepo='*' && \
     localedef -f UTF-8 -i en_US en_US.UTF-8 && \
diff --git a/specs/multispec.yml b/specs/multispec.yml
index e45b97c1..4a36adcd 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -74,8 +74,8 @@ specs:
       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
       redhat_component: "postgresql-{{ spec.short }}-container"
       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}-{{ spec.prod }}"
-      pkgs: "postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib glibc-locale-source xz"
-      check_pkgs: "postgresql-server-{{ spec.short }} postgresql-contrib-{{ spec.short }}"
+      pkgs: "postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib postgresql{{ spec.short }}-upgrade"
+      check_pkgs: "postgresql-server postgresql-contrib postgresql-upgrade"
 
   version:
     "12":
diff --git a/src/Dockerfile b/src/Dockerfile
index 01eec376..ac6e25f6 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -56,15 +56,17 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {{ spec.repo_enable_reason }}
 {% endif %}
 {% if spec.prod == "c10s" %}
-RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
-    PSQL_PKGS={{ spec.pkgs }} && \
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
+    PSQL_PKGS="{{ spec.pkgs }}" && \
 {% else %}
 RUN {{ spec.environment_setup }}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
 {% endif %}
 {% if spec.version not in ["9.6", "10", "11"] %}
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    {% if spec.prod != "c10s" %}
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
+    {% endif %}
 {% endif %}
 {% if spec.prod == "c10s" %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \

From 22773e9528d2d628653b6522685dde8b86941b96 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 16 Sep 2024 13:08:30 +0200
Subject: [PATCH 481/509] Add Helm chart tests for PSQL

We need to test if helm charts work in postgresql container

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/run-openshift-pytest                 |  2 +-
 test/test_helm_postgresql_imagestreams.py | 47 +++++++++++++++++++
 test/test_helm_postgresql_template.py     | 56 +++++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 test/test_helm_postgresql_imagestreams.py
 create mode 100644 test/test_helm_postgresql_template.py

diff --git a/test/run-openshift-pytest b/test/run-openshift-pytest
index 63eae5e3..e619157e 100755
--- a/test/run-openshift-pytest
+++ b/test/run-openshift-pytest
@@ -10,4 +10,4 @@ THISDIR=$(dirname ${BASH_SOURCE[0]})
 
 git show -s
 
-cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_postgresql_*.py
+cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py
diff --git a/test/test_helm_postgresql_imagestreams.py b/test/test_helm_postgresql_imagestreams.py
new file mode 100644
index 00000000..bf0ea4b4
--- /dev/null
+++ b/test/test_helm_postgresql_imagestreams.py
@@ -0,0 +1,47 @@
+import os
+import sys
+
+import pytest
+
+from pathlib import Path
+
+from container_ci_suite.helm import HelmChartsAPI
+from container_ci_suite.utils import check_variables
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
+    sys.exit(1)
+
+test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
+
+
+class TestHelmRHELPostgresqlImageStreams:
+
+    def setup_method(self):
+        package_name = "postgresql-imagestreams"
+        path = test_dir
+        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
+        self.hc_api.clone_helm_chart_repo(
+            repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
+            subdir="charts/redhat"
+        )
+
+    def teardown_method(self):
+        self.hc_api.delete_project()
+
+    @pytest.mark.parametrize(
+        "version,registry,expected",
+        [
+            ("10-el8", "registry.redhat.io/rhel8/postgresql-10:latest", False),
+            ("13-el8", "registry.redhat.io/rhel8/postgresql-13:latest", True),
+            ("13-el9", "registry.redhat.io/rhel9/postgresql-13:latest", True),
+            ("15-el8", "registry.redhat.io/rhel8/postgresql-15:latest", True),
+            ("15-el9", "registry.redhat.io/rhel9/postgresql-15:latest", True),
+            ("16-el8", "registry.redhat.io/rhel8/postgresql-16:latest", True),
+            ("16-el9", "registry.redhat.io/rhel9/postgresql-16:latest", True),
+        ],
+    )
+    def test_package_imagestream(self, version, registry, expected):
+        assert self.hc_api.helm_package()
+        assert self.hc_api.helm_installation()
+        assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
diff --git a/test/test_helm_postgresql_template.py b/test/test_helm_postgresql_template.py
new file mode 100644
index 00000000..7c16e52b
--- /dev/null
+++ b/test/test_helm_postgresql_template.py
@@ -0,0 +1,56 @@
+import os
+import sys
+
+import pytest
+
+from pathlib import Path
+
+from container_ci_suite.helm import HelmChartsAPI
+from container_ci_suite.utils import check_variables
+
+if not check_variables():
+    print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
+    sys.exit(1)
+
+test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
+
+
+VERSION = os.getenv("VERSION")
+IMAGE_NAME = os.getenv("IMAGE_NAME")
+OS = os.getenv("TARGET")
+
+TAGS = {
+    "rhel8": "-el8",
+    "rhel9": "-el9"
+}
+TAG = TAGS.get(OS, None)
+
+
+class TestHelmPostgresqlPersistent:
+
+    def setup_method(self):
+        package_name = "postgresql-persistent"
+        path = test_dir
+        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
+        self.hc_api.clone_helm_chart_repo(
+            repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
+            subdir="charts/redhat"
+        )
+
+    def teardown_method(self):
+        self.hc_api.delete_project()
+
+    def test_package_persistent(self):
+        self.hc_api.package_name = "postgresql-imagestreams"
+        assert self.hc_api.helm_package()
+        assert self.hc_api.helm_installation()
+        self.hc_api.package_name = "postgresql-persistent"
+        assert self.hc_api.helm_package()
+        assert self.hc_api.helm_installation(
+            values={
+                ".image.tag": f"{VERSION}{TAG}",
+                ".namespace": self.hc_api.namespace
+            }
+        )
+        assert self.hc_api.is_pod_running(pod_name_prefix="postgresql-persistent")
+        assert self.hc_api.test_helm_chart(expected_str=["accepting connection"])

From 50499ae27fd0e9900405ee214a7088dd3ba034c6 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 30 Sep 2024 13:42:23 +0000
Subject: [PATCH 482/509] Bump common from `1e271d8` to `008d6ea`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `1e271d8` to `008d6ea`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/1e271d8d077833ceed1bc0fcb1eb9629ea5ea410...008d6eaccbea0502db3e87d36eef153cdbad0171)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 1e271d8d..008d6eac 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1e271d8d077833ceed1bc0fcb1eb9629ea5ea410
+Subproject commit 008d6eaccbea0502db3e87d36eef153cdbad0171

From bd8f052215df500cb22fd9ae243954066b8ea4d6 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 4 Oct 2024 10:14:09 +0200
Subject: [PATCH 483/509] Do not enable module postgresql-13 for RHEL-9.

This is not module but RPM packages

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 src/Dockerfile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/Dockerfile b/src/Dockerfile
index ac6e25f6..55da1c75 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -58,6 +58,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {% if spec.prod == "c10s" %}
 RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
     PSQL_PKGS="{{ spec.pkgs }}" && \
+{% elif spec.prod == "rhel9" and spec.version == "13" %} \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
 {% else %}
 RUN {{ spec.environment_setup }}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \

From 34fc6a4454bbbf61b2c552d4429cd1828a575650 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 4 Oct 2024 10:14:40 +0200
Subject: [PATCH 484/509] Add generated Dockerfile by distgen

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 13/Dockerfile.rhel9 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index af4da6c6..19d70596 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -42,8 +42,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # This image must forever use UID 26 for postgres user so our volumes are
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
-RUN { yum -y module enable postgresql:13 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
+ \
+RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \

From 355d42ff04c8250b04a4ed06d44bb364a77fca28 Mon Sep 17 00:00:00 2001
From: Ales Nezbeda <anezbeda@redhat.com>
Date: Wed, 2 Oct 2024 14:12:37 +0200
Subject: [PATCH 485/509] Fix error in `run_pgaudit_test()`

Initially command `test was missing`, but after it was added
test failed and crashed in a way that no more tests were run.
This behavior is known issue tracked here in issue #537

Problem is that `DOCKER_EXTRA_ARGS` variable is set already
which it shouldn't be, so the `test` command returns 0,
so no `cp` happens and we get the crash.

Variable is empty, but apparently do exist as
`test -v DOCKER_EXTRA_ARGS` is `TRUE`.

Introduced by PR #399
---
 test/run_test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/run_test b/test/run_test
index 08260e6c..6e768a7d 100755
--- a/test/run_test
+++ b/test/run_test
@@ -934,7 +934,7 @@ run_pgaudit_test()
   # create a dir for config
   config_dir=$(mktemp -d --tmpdir pg-hook-volume.XXXXX)
   add_cleanup_command /bin/rm -rf "$config_dir"
-  -v DOCKER_EXTRA_ARGS || cp -r "$test_dir"/examples/pgaudit/* "$config_dir"
+  test -n "$DOCKER_EXTRA_ARGS" || cp -r "$test_dir"/examples/pgaudit/* "$config_dir"
   setfacl -R -m u:26:rwx "$config_dir"
 
   # create a dir for data

From 468f21ea48b70549efd52007904a289e4f32a019 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zachar?=
 <1548503+lukaszachy@users.noreply.github.com>
Date: Fri, 18 Oct 2024 13:54:23 +0200
Subject: [PATCH 486/509] Disable tests depending on  help.1 file presence

This file will no longer be included in images produced by Konflux, thus we shouldn't test it.
---
 test/run_test | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/test/run_test b/test/run_test
index 6e768a7d..b571b2f0 100755
--- a/test/run_test
+++ b/test/run_test
@@ -20,7 +20,6 @@ run_container_creation_tests
 run_general_tests
 run_change_password_test
 run_replication_test
-run_doc_test
 run_s2i_test
 run_test_cfg_hook
 run_s2i_bake_data_test
@@ -805,9 +804,6 @@ ${mount_opts}
 run_s2i_test() {
   local temp_file
   local ret=0
-  echo "  Testing s2i usage"
-  ct_s2i_usage "${IMAGE_NAME}" --pull-policy=never 1>/dev/null || ret=1
-
   echo "  Testing s2i build"
 
   local s2i_image_name=$IMAGE_NAME-testapp_$(ct_random_string)

From 4b24f8bb3cf8e2040b9cf29d15162ecda18c21b0 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 4 Nov 2024 14:56:25 +0100
Subject: [PATCH 487/509] Allow auto-merger bot that checks what is missing in
 current pull request.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/auto-merge.yml                     |  1 +
 .github/workflows/auto-merge-on-demand.yml | 71 ++++++++++++++++++++++
 .github/workflows/auto-merge.yml           | 43 +++++++++++++
 .github/workflows/pr-metadata.yml          | 27 ++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 .github/auto-merge.yml
 create mode 100644 .github/workflows/auto-merge-on-demand.yml
 create mode 100644 .github/workflows/auto-merge.yml
 create mode 100644 .github/workflows/pr-metadata.yml

diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml
new file mode 100644
index 00000000..4aaecf6d
--- /dev/null
+++ b/.github/auto-merge.yml
@@ -0,0 +1 @@
+target-branch: []
diff --git a/.github/workflows/auto-merge-on-demand.yml b/.github/workflows/auto-merge-on-demand.yml
new file mode 100644
index 00000000..47003fdd
--- /dev/null
+++ b/.github/workflows/auto-merge-on-demand.yml
@@ -0,0 +1,71 @@
+name: Auto Merge Scheduled / On Demand
+on:
+  schedule:
+    # Workflow runs every 45 minutes
+    - cron: '*/45 * * * *'
+  workflow_dispatch:
+    inputs:
+      pr-number:
+        description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs'
+        required: true
+        default: '0'
+
+permissions:
+  contents: read
+
+jobs:
+  # Get all open PRs
+  gather-pull-requests:
+    if: github.repository_owner == 'sclorg'
+    runs-on: ubuntu-latest
+
+    outputs:
+      pr-numbers: ${{ steps.get-pr-numbers.outputs.result }}
+      pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }}
+
+    steps:
+      - id: get-pr-numbers
+        if: inputs.pr-number == '0'
+        name: Get all open PRs
+        uses: actions/github-script@v7
+        with:
+          # !FIXME: this is not working if there is more than 100 PRs opened
+          script: |
+            const { data: pullRequests } = await github.rest.pulls.list({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              state: 'open',
+              per_page: 100
+            });
+            return pullRequests.map(pr => pr.number);
+
+      - id: parse-manual-input
+        if: inputs.pr-number != '0'
+        name: Parse manual input
+        run: |
+          # shellcheck disable=SC2086
+          echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
+        shell: bash
+
+  validate-pr:
+    name: 'Validation of Pull Request #${{ matrix.pr-number }}'
+    needs: [ gather-pull-requests ]
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
+
+    permissions:
+      # required for merging PRs
+      contents: write
+      # required for PR comments and setting labels
+      pull-requests: write
+
+    steps:
+      - name: Auto Merge wrapper
+        uses: sclorg/auto-merge-wrapper@v1
+        with:
+          pr-number: ${{ matrix.pr-number }}
+          token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml
new file mode 100644
index 00000000..f5a580e9
--- /dev/null
+++ b/.github/workflows/auto-merge.yml
@@ -0,0 +1,43 @@
+name: Auto Merge
+on:
+  workflow_run:
+    workflows: [ Gather Pull Request Metadata ]
+    types:
+      - completed
+
+permissions:
+  contents: read
+
+jobs:
+  download-metadata:
+    if: >
+      github.event.workflow_run.event == 'pull_request' &&
+      github.event.workflow_run.conclusion == 'success'
+    runs-on: ubuntu-latest
+
+    outputs:
+      pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }}
+
+    steps:
+      - id: Artifact
+        name: Download Artifact
+        uses: redhat-plumbers-in-action/download-artifact@v1
+        with:
+          name: pr-metadata
+
+  auto-merge:
+    needs: [ download-metadata ]
+    runs-on: ubuntu-latest
+
+    permissions:
+      # required for merging PRs
+      contents: write
+      # required for PR comments and setting labels
+      pull-requests: write
+
+    steps:
+      - name: Auto Merge wrapper
+        uses: sclorg/auto-merge-wrapper@v1
+        with:
+          pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
+          token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/pr-metadata.yml b/.github/workflows/pr-metadata.yml
new file mode 100644
index 00000000..e4c77dbe
--- /dev/null
+++ b/.github/workflows/pr-metadata.yml
@@ -0,0 +1,27 @@
+name: Gather Pull Request Metadata
+on:
+  pull_request:
+    types: [ opened, reopened, synchronize ]
+    branches: [ master ]
+
+permissions:
+  contents: read
+
+jobs:
+  gather-metadata:
+    if: github.repository_owner == 'sclorg'
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Repository checkout
+        uses: actions/checkout@v4
+
+      - id: Metadata
+        name: Gather Pull Request Metadata
+        uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
+
+      - name: Upload artifact with gathered metadata
+        uses: actions/upload-artifact@v4
+        with:
+          name: pr-metadata
+          path: ${{ steps.Metadata.outputs.metadata-file }}

From 60136473d71fd7de54dd55f1d6a492b10cf78a63 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 5 Nov 2024 12:17:08 +0100
Subject: [PATCH 488/509] Rename helm PyTest suite so it is executed at the
 end.

Helm Charts uses shared cluster but the other uses
our cluster.

Container-ci-suite does not allow switching between OpenShift 4 clusters

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 ...magestreams.py => test_shared_helm_postgresql_imagestreams.py} | 0
 ...gresql_template.py => test_shared_helm_postgresql_template.py} | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename test/{test_helm_postgresql_imagestreams.py => test_shared_helm_postgresql_imagestreams.py} (100%)
 rename test/{test_helm_postgresql_template.py => test_shared_helm_postgresql_template.py} (100%)

diff --git a/test/test_helm_postgresql_imagestreams.py b/test/test_shared_helm_postgresql_imagestreams.py
similarity index 100%
rename from test/test_helm_postgresql_imagestreams.py
rename to test/test_shared_helm_postgresql_imagestreams.py
diff --git a/test/test_helm_postgresql_template.py b/test/test_shared_helm_postgresql_template.py
similarity index 100%
rename from test/test_helm_postgresql_template.py
rename to test/test_shared_helm_postgresql_template.py

From a48a60eb06b8bd152502c5250839b3f6a4b2c6d9 Mon Sep 17 00:00:00 2001
From: Ales Nezbeda <anezbeda@redhat.com>
Date: Fri, 1 Nov 2024 15:18:20 +0100
Subject: [PATCH 489/509] Document all test functions

---
 test/run_test | 66 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/test/run_test b/test/run_test
index b571b2f0..fa1576a4 100755
--- a/test/run_test
+++ b/test/run_test
@@ -27,7 +27,7 @@ run_s2i_enable_ssl_test
 run_upgrade_test
 run_migration_test
 run_pgaudit_test
-run_new_pgaudit_test
+run_env_extension_load_test
 run_logging_test
 "
 
@@ -291,6 +291,12 @@ function try_image_invalid_combinations() {
   return $ret
 }
 
+# run_container_creation_tests
+# --------------------
+# Asserts that container image fails to run in certain illegal use of arguments,
+# while it correctly runs in other combinations.
+# NOTE: Previously the `creation_succeeds` combinations were supposed to fail, but
+# these cases are now supposed to work
 function run_container_creation_tests() {
   local ret=0
   echo "  Testing image entrypoint usage"
@@ -583,6 +589,11 @@ function run_master_restart_test() {
   return $ret
 }
 
+# run_replication_test
+# --------------------
+# Start two containers one as main, one as secondary. Checks whether the main
+# sees secondary server connected. Tries to create data on main server and
+# checks whether they are correctly replicated to secondary server.
 function run_replication_test() {
   local DB=postgres
   local PGUSER=master
@@ -610,6 +621,10 @@ function run_replication_test() {
   return $ret
 }
 
+# run_change_password_test
+# --------------------
+# Check whether starting container with different password argument correctly
+# changes the password and allows connection to old already used db.
 function run_change_password_test() {
   echo "  Testing password change"
   local name="change_password"
@@ -686,6 +701,11 @@ $volume_options
   return $ret
 }
 
+# run_upgrade_test
+# --------------------
+# Testing upgrade from previous version to current version using
+# POSTGRESQL_UPGRADE env variable. Checks that upgrade is successfull using two
+# demo databases (simple and pagila)
 run_upgrade_test ()
 {
   local ret=0
@@ -728,6 +748,11 @@ run_upgrade_test ()
   return $ret
 }
 
+# run_migration_test
+# --------------------
+# Testing migration from each supported version to currently tested one. Pagila
+# is used as a demo database - data integrity is checked. Asserts that no
+# invalid options can be passed without container failing to start.
 run_migration_test ()
 {
   local ret=0
@@ -750,6 +775,10 @@ run_migration_test ()
   return $ret
 }
 
+# run_doc_test
+# --------------------
+# Checks whether `help.1` file with specific terms is included in default
+# working directory in the container image.
 run_doc_test() {
   local tmpdir=$(mktemp -d)
   local f
@@ -801,6 +830,10 @@ ${mount_opts}
   return $ret
 }
 
+# run_s2i_test
+# --------------------
+# Build S2I image with basic script. Try running the container with usage of the
+# script that we built into that S2I image. Compare with original image.
 run_s2i_test() {
   local temp_file
   local ret=0
@@ -826,6 +859,10 @@ run_s2i_test() {
   return $ret
 }
 
+# run_general_tests
+# --------------------
+# Tests different combinations of parameters and that they work. Also tests SCL
+# usage. Tries to actually SELECT something from the database.
 function run_general_tests() {
   local ret=0
   PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin || ret=1
@@ -841,6 +878,10 @@ function run_general_tests() {
   return $ret
 }
 
+# run_test_cfg_hook
+# --------------------
+# Checks whether using config files in persistent mounted volume works. Also
+# checks that the config file has priority over env variables.
 run_test_cfg_hook()
 {
   local ret=0
@@ -877,6 +918,10 @@ run_test_cfg_hook()
   return $ret
 }
 
+# run_s2i_enable_ssl_test
+# --------------------
+# Creates S2I image with SSL config and certificates. Tries to connect with
+# required SSL connection.
 run_s2i_enable_ssl_test()
 {
   local s2i_image_name="$IMAGE_NAME-ssl_$(ct_random_string)"
@@ -898,6 +943,10 @@ run_s2i_enable_ssl_test()
     false "FAIL: Did not manage to connect using SSL only."
 }
 
+# run_s2i_bake_data_test
+# --------------------
+# Testing pre-start script and `init.sql` file with prefilled data placed in S2I
+# resulting image.
 run_s2i_bake_data_test ()
 {
   local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
@@ -916,6 +965,11 @@ run_s2i_bake_data_test ()
                            bash -c "psql -tA -c 'SELECT * FROM test;'")"
 }
 
+# run_pgaudit_test
+# --------------------
+# Configure container to include pgaudit using config directory volumes. Check
+# that pgaudit is loaded. Set pgaudit logging and check that logs are present in
+# log folder.
 run_pgaudit_test()
 {
   local ret=0
@@ -975,6 +1029,10 @@ EOSQL" || ret=3
   return $ret
 }
 
+# run_logging_test
+# --------------------
+# Checks that changing log location via `POSTGRESQL_LOG_DESTINATION` env
+# variable works correctly.
 run_logging_test()
 {
   local data_dir name=pg-test-logging
@@ -1018,7 +1076,11 @@ run_logging_test()
   echo "  Success!"
 }
 
-run_new_pgaudit_test() {
+# run_env_extension_load_test
+# --------------------
+# Tries to load pgaudit extension using environment variables
+# `POSTGRESQL_EXTENSIONS` and `POSTGRESQL_LIBRARIES`
+run_env_extension_load_test() {
     DOCKER_EXTRA_ARGS="
 -e POSTGRESQL_EXTENSIONS=pgaudit
 -e POSTGRESQL_LIBRARIES=pgaudit"

From fe6e2e87e3f9388c0ebcb843ca859de6334fb609 Mon Sep 17 00:00:00 2001
From: Ales Nezbeda <anezbeda@redhat.com>
Date: Fri, 1 Nov 2024 15:29:55 +0100
Subject: [PATCH 490/509] Reorganize function into categories

Helper functions, disabled tests, test functions
---
 test/run_test | 182 +++++++++++++++++++++++++++-----------------------
 1 file changed, 98 insertions(+), 84 deletions(-)

diff --git a/test/run_test b/test/run_test
index fa1576a4..d459369e 100755
--- a/test/run_test
+++ b/test/run_test
@@ -37,6 +37,10 @@ test -n "${VERSION-}" || false 'make sure $VERSION is defined'
 test -n "${OS-}" || false 'make sure $OS is defined'
 
 
+####
+# HELPER FUNCTIONS
+####
+
 DOCKER_EXTRA_ARGS=
 
 volumes_to_clean=
@@ -291,35 +295,6 @@ function try_image_invalid_combinations() {
   return $ret
 }
 
-# run_container_creation_tests
-# --------------------
-# Asserts that container image fails to run in certain illegal use of arguments,
-# while it correctly runs in other combinations.
-# NOTE: Previously the `creation_succeeds` combinations were supposed to fail, but
-# these cases are now supposed to work
-function run_container_creation_tests() {
-  local ret=0
-  echo "  Testing image entrypoint usage"
-  try_image_invalid_combinations || ret=1
-  try_image_invalid_combinations  -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=2
-
-VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-  assert_container_creation_fails -e POSTGRESQL_USER= -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=3
-  assert_container_creation_fails -e POSTGRESQL_USER=$VERY_LONG_IDENTIFIER -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=4
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=5
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=6
-  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=$VERY_LONG_IDENTIFIER -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=7
-  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\"" || ret=8
-
-  assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD="the @password" || ret=9
-  assert_container_creation_succeeds -e POSTGRESQL_PASSWORD="the pass" -e POSTGRESQL_USER="the user" -e POSTGRESQL_DATABASE="the db" || ret=10
-
-  if [ $ret -eq 0 ]; then
-    echo "  Success!"
-  fi
-  return $ret
-}
-
 function test_config_option() {
   local name=$1 ; shift
   local setting=$1 ; shift
@@ -537,6 +512,38 @@ function setup_replication_cluster() {
 
 }
 
+test_the_app_image () {
+  local container_name=$1
+  local mount_opts=$2
+  local ret=0
+  echo "    Testing s2i app image with invalid configuration"
+  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db || ret=1
+  echo "    Testing s2i app image with correct configuration"
+
+    DOCKER_ARGS="
+-e POSTGRESQL_DATABASE=db
+-e POSTGRESQL_USER=user
+-e POSTGRESQL_PASSWORD=password
+-e POSTGRESQL_ADMIN_PASSWORD=password
+-e POSTGRESQL_BACKUP_USER=backuser
+-e POSTGRESQL_BACKUP_PASSWORD=pass
+${mount_opts}
+" create_container "$container_name" || ret=2
+
+  # need this to wait for the container to start up
+  PGUSER=user     PASS=password           test_connection "$container_name" || ret=3
+  PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name" || ret=4
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
+}
+
+
+####
+# DISABLED TESTS
+####
+
 # This test is removed from the test suite
 # In our CI is failing sporadically and solution is not available yet.
 # Let's remove it from test but the test function remains.
@@ -589,6 +596,68 @@ function run_master_restart_test() {
   return $ret
 }
 
+# run_doc_test
+# --------------------
+# Checks whether `help.1` file with specific terms is included in default
+# working directory in the container image.
+run_doc_test() {
+  local tmpdir=$(mktemp -d)
+  local f
+  echo "  Testing documentation in the container image"
+  # Extract the help files from the container
+  for f in help.1 ; do
+    docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
+    # Check whether the files include some important information
+    for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' Volume 5432 ; do
+      if ! cat ${tmpdir}/$(basename ${f}) | grep -E -q -e "${term}" ; then
+        echo "ERROR: File /${f} does not include '${term}'."
+        return 1
+      fi
+    done
+  done
+  # Check whether the files use the correct format
+  if ! file ${tmpdir}/help.1 | grep -q roff ; then
+    echo "ERROR: /help.1 is not in troff or groff format"
+    return 1
+  fi
+  echo "  Success!"
+  echo
+}
+
+
+####
+# TESTING FUNCTIONS
+####
+
+# run_container_creation_tests
+# --------------------
+# Asserts that container image fails to run in certain illegal use of arguments,
+# while it correctly runs in other combinations.
+# NOTE: Previously the `creation_succeeds` combinations were supposed to fail, but
+# these cases are now supposed to work
+function run_container_creation_tests() {
+  local ret=0
+  echo "  Testing image entrypoint usage"
+  try_image_invalid_combinations || ret=1
+  try_image_invalid_combinations  -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=2
+
+VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+  assert_container_creation_fails -e POSTGRESQL_USER= -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=3
+  assert_container_creation_fails -e POSTGRESQL_USER=$VERY_LONG_IDENTIFIER -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=4
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD="\"" -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=5
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=9invalid -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=6
+  assert_container_creation_fails -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=$VERY_LONG_IDENTIFIER -e POSTGRESQL_ADMIN_PASSWORD=admin_pass || ret=7
+  assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD="\"" || ret=8
+
+  assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD="the @password" || ret=9
+  assert_container_creation_succeeds -e POSTGRESQL_PASSWORD="the pass" -e POSTGRESQL_USER="the user" -e POSTGRESQL_DATABASE="the db" || ret=10
+
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
+}
+
 # run_replication_test
 # --------------------
 # Start two containers one as main, one as secondary. Checks whether the main
@@ -775,61 +844,6 @@ run_migration_test ()
   return $ret
 }
 
-# run_doc_test
-# --------------------
-# Checks whether `help.1` file with specific terms is included in default
-# working directory in the container image.
-run_doc_test() {
-  local tmpdir=$(mktemp -d)
-  local f
-  echo "  Testing documentation in the container image"
-  # Extract the help files from the container
-  for f in help.1 ; do
-    docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
-    # Check whether the files include some important information
-    for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' Volume 5432 ; do
-      if ! cat ${tmpdir}/$(basename ${f}) | grep -E -q -e "${term}" ; then
-        echo "ERROR: File /${f} does not include '${term}'."
-        return 1
-      fi
-    done
-  done
-  # Check whether the files use the correct format
-  if ! file ${tmpdir}/help.1 | grep -q roff ; then
-    echo "ERROR: /help.1 is not in troff or groff format"
-    return 1
-  fi
-  echo "  Success!"
-  echo
-}
-
-test_the_app_image () {
-  local container_name=$1
-  local mount_opts=$2
-  local ret=0
-  echo "    Testing s2i app image with invalid configuration"
-  assert_container_creation_fails -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db || ret=1
-  echo "    Testing s2i app image with correct configuration"
-
-    DOCKER_ARGS="
--e POSTGRESQL_DATABASE=db
--e POSTGRESQL_USER=user
--e POSTGRESQL_PASSWORD=password
--e POSTGRESQL_ADMIN_PASSWORD=password
--e POSTGRESQL_BACKUP_USER=backuser
--e POSTGRESQL_BACKUP_PASSWORD=pass
-${mount_opts}
-" create_container "$container_name" || ret=2
-
-  # need this to wait for the container to start up
-  PGUSER=user     PASS=password           test_connection "$container_name" || ret=3
-  PGUSER=backuser PASS=pass     DB=backup test_connection "$container_name" || ret=4
-  if [ $ret -eq 0 ]; then
-    echo "  Success!"
-  fi
-  return $ret
-}
-
 # run_s2i_test
 # --------------------
 # Build S2I image with basic script. Try running the container with usage of the

From f4d56eb401bb68776a40ec765617b575525f43c1 Mon Sep 17 00:00:00 2001
From: Ales Nezbeda <anezbeda@redhat.com>
Date: Fri, 1 Nov 2024 15:35:00 +0100
Subject: [PATCH 491/509] Reorder tests sources to match order of tests in
 TEST_LIST

---
 test/run_test | 260 +++++++++++++++++++++++++-------------------------
 1 file changed, 130 insertions(+), 130 deletions(-)

diff --git a/test/run_test b/test/run_test
index d459369e..98e9fdb2 100755
--- a/test/run_test
+++ b/test/run_test
@@ -658,32 +658,19 @@ VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   return $ret
 }
 
-# run_replication_test
+# run_general_tests
 # --------------------
-# Start two containers one as main, one as secondary. Checks whether the main
-# sees secondary server connected. Tries to create data on main server and
-# checks whether they are correctly replicated to secondary server.
-function run_replication_test() {
-  local DB=postgres
-  local PGUSER=master
-  local PASS=master
+# Tests different combinations of parameters and that they work. Also tests SCL
+# usage. Tries to actually SELECT something from the database.
+function run_general_tests() {
   local ret=0
-
-  echo "Testing master-slave replication"
-  local cluster_args="-e POSTGRESQL_ADMIN_PASSWORD=pass -e POSTGRESQL_MASTER_USER=$PGUSER -e POSTGRESQL_MASTER_PASSWORD=$PASS"
-  local cid_suffix="basic"
-  local master_ip=
-  local slave_cids=
-
-  # Setup the cluster
-  setup_replication_cluster || ret=1
-
-  # Check if the master knows about the slaves
-  CONTAINER_IP=$master_ip
-  test_slave_visibility || ret=2
-
-  # Do some real work to test replication in practice
-  table_name="t1" test_value_replication || ret=3
+  PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin || ret=1
+  PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin || ret=2
+  DB=postgres ADMIN_PASS=r00t run_tests only_admin || ret=3
+  # Test with arbitrary uid for the container
+  DOCKER_ARGS="-u 12345" PGUSER=user2 PASS=pass run_tests no_admin_altuid || ret=4
+  DOCKER_ARGS="-u 12345" PGUSER=user3 PASS=pass1 ADMIN_PASS=r00t run_tests admin_altuid || ret=5
+  DB=postgres DOCKER_ARGS="-u 12345" ADMIN_PASS=rOOt run_tests only_admin_altuid || ret=6
   if [ $ret -eq 0 ]; then
     echo "  Success!"
   fi
@@ -770,74 +757,32 @@ $volume_options
   return $ret
 }
 
-# run_upgrade_test
+# run_replication_test
 # --------------------
-# Testing upgrade from previous version to current version using
-# POSTGRESQL_UPGRADE env variable. Checks that upgrade is successfull using two
-# demo databases (simple and pagila)
-run_upgrade_test ()
-{
+# Start two containers one as main, one as secondary. Checks whether the main
+# sees secondary server connected. Tries to create data on main server and
+# checks whether they are correctly replicated to secondary server.
+function run_replication_test() {
+  local DB=postgres
+  local PGUSER=master
+  local PASS=master
   local ret=0
 
-    local upgrade_path= prev= act=
-    case $OS in
-        rhel8)
-            upgrade_path="none 12 13 15 16 none"
-            ;;
-        rhel9|c9s)
-            upgrade_path="none 13 15 16 none"
-            ;;
-        rhel10|c10s)
-            upgrade_path="none 13 15 16 none"
-            ;;
-        fedora)
-            upgrade_path="none 12 13 14 15 16 none"
-            ;;
-        *)
-            echo "unsupported OS variable" >&2
-            return 1
-            ;;
-    esac
-
-    for act in $upgrade_path; do
-        if test "$act" = $VERSION; then
-            break
-        fi
-        prev=$act
-    done
-    test "$prev" != none || return 0
-    # Check if the previous image is available in the registry
-    docker pull "$(get_image_id "$prev:remote")" || return 0
-
-    # TODO: We run this script from $VERSION directory, through test/run symlink.
-    test/run_upgrade_test "$prev:remote" "$VERSION:local" || ret=1
-  if [ $ret -eq 0 ]; then
-    echo "  Success!"
-  fi
-  return $ret
-}
+  echo "Testing master-slave replication"
+  local cluster_args="-e POSTGRESQL_ADMIN_PASSWORD=pass -e POSTGRESQL_MASTER_USER=$PGUSER -e POSTGRESQL_MASTER_PASSWORD=$PASS"
+  local cid_suffix="basic"
+  local master_ip=
+  local slave_cids=
 
-# run_migration_test
-# --------------------
-# Testing migration from each supported version to currently tested one. Pagila
-# is used as a demo database - data integrity is checked. Asserts that no
-# invalid options can be passed without container failing to start.
-run_migration_test ()
-{
-  local ret=0
-    [ "${OS}" == "fedora" ] && return 0
+  # Setup the cluster
+  setup_replication_cluster || ret=1
 
-    local from_version
-    local upgrade_path="12 13 15 16"
+  # Check if the master knows about the slaves
+  CONTAINER_IP=$master_ip
+  test_slave_visibility || ret=2
 
-    for from_version in $upgrade_path; do
-        # Do not test migration from $VERSION:remote to $VERSION:local
-        test $(version2number $from_version) -lt $(version2number "$VERSION") \
-            || break
-        # Skip if the previous image is not available in the registry
-        docker pull "$(get_image_id "$from_version:remote")" || continue
-        test/run_migration_test $from_version:remote $VERSION:local || ret=1
-    done
+  # Do some real work to test replication in practice
+  table_name="t1" test_value_replication || ret=3
   if [ $ret -eq 0 ]; then
     echo "  Success!"
   fi
@@ -873,25 +818,6 @@ run_s2i_test() {
   return $ret
 }
 
-# run_general_tests
-# --------------------
-# Tests different combinations of parameters and that they work. Also tests SCL
-# usage. Tries to actually SELECT something from the database.
-function run_general_tests() {
-  local ret=0
-  PGUSER=user PASS=pass POSTGRESQL_MAX_CONNECTIONS=42 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=42 POSTGRESQL_SHARED_BUFFERS=64MB run_tests no_admin || ret=1
-  PGUSER=user1 PASS=pass1 ADMIN_PASS=r00t run_tests admin || ret=2
-  DB=postgres ADMIN_PASS=r00t run_tests only_admin || ret=3
-  # Test with arbitrary uid for the container
-  DOCKER_ARGS="-u 12345" PGUSER=user2 PASS=pass run_tests no_admin_altuid || ret=4
-  DOCKER_ARGS="-u 12345" PGUSER=user3 PASS=pass1 ADMIN_PASS=r00t run_tests admin_altuid || ret=5
-  DB=postgres DOCKER_ARGS="-u 12345" ADMIN_PASS=rOOt run_tests only_admin_altuid || ret=6
-  if [ $ret -eq 0 ]; then
-    echo "  Success!"
-  fi
-  return $ret
-}
-
 # run_test_cfg_hook
 # --------------------
 # Checks whether using config files in persistent mounted volume works. Also
@@ -932,6 +858,28 @@ run_test_cfg_hook()
   return $ret
 }
 
+# run_s2i_bake_data_test
+# --------------------
+# Testing pre-start script and `init.sql` file with prefilled data placed in S2I
+# resulting image.
+run_s2i_bake_data_test ()
+{
+  local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
+  ct_s2i_build_as_df "file://$test_dir/examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
+  images_to_clean+=( "$s2i_image_name" )
+
+  local container_name=bake-data-test
+
+  DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
+    IMAGE_NAME="$s2i_image_name" create_container "$container_name"
+
+  wait_ready "$container_name" || \
+    false "FAIL: Container did not start up properly."
+
+  test "hello world" == "$(docker exec "$(get_cid "$container_name")" \
+                           bash -c "psql -tA -c 'SELECT * FROM test;'")"
+}
+
 # run_s2i_enable_ssl_test
 # --------------------
 # Creates S2I image with SSL config and certificates. Tries to connect with
@@ -957,26 +905,78 @@ run_s2i_enable_ssl_test()
     false "FAIL: Did not manage to connect using SSL only."
 }
 
-# run_s2i_bake_data_test
+# run_upgrade_test
 # --------------------
-# Testing pre-start script and `init.sql` file with prefilled data placed in S2I
-# resulting image.
-run_s2i_bake_data_test ()
+# Testing upgrade from previous version to current version using
+# POSTGRESQL_UPGRADE env variable. Checks that upgrade is successfull using two
+# demo databases (simple and pagila)
+run_upgrade_test ()
 {
-  local s2i_image_name="$IMAGE_NAME-bake_$(ct_random_string)"
-  ct_s2i_build_as_df "file://$test_dir/examples/s2i-dump-data" "${IMAGE_NAME}" "$s2i_image_name" 1>/dev/null
-  images_to_clean+=( "$s2i_image_name" )
+  local ret=0
 
-  local container_name=bake-data-test
+    local upgrade_path= prev= act=
+    case $OS in
+        rhel8)
+            upgrade_path="none 12 13 15 16 none"
+            ;;
+        rhel9|c9s)
+            upgrade_path="none 13 15 16 none"
+            ;;
+        rhel10|c10s)
+            upgrade_path="none 13 15 16 none"
+            ;;
+        fedora)
+            upgrade_path="none 12 13 14 15 16 none"
+            ;;
+        *)
+            echo "unsupported OS variable" >&2
+            return 1
+            ;;
+    esac
 
-  DOCKER_ARGS="-e POSTGRESQL_ADMIN_PASSWORD=password" \
-    IMAGE_NAME="$s2i_image_name" create_container "$container_name"
+    for act in $upgrade_path; do
+        if test "$act" = $VERSION; then
+            break
+        fi
+        prev=$act
+    done
+    test "$prev" != none || return 0
+    # Check if the previous image is available in the registry
+    docker pull "$(get_image_id "$prev:remote")" || return 0
 
-  wait_ready "$container_name" || \
-    false "FAIL: Container did not start up properly."
+    # TODO: We run this script from $VERSION directory, through test/run symlink.
+    test/run_upgrade_test "$prev:remote" "$VERSION:local" || ret=1
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
+}
 
-  test "hello world" == "$(docker exec "$(get_cid "$container_name")" \
-                           bash -c "psql -tA -c 'SELECT * FROM test;'")"
+# run_migration_test
+# --------------------
+# Testing migration from each supported version to currently tested one. Pagila
+# is used as a demo database - data integrity is checked. Asserts that no
+# invalid options can be passed without container failing to start.
+run_migration_test ()
+{
+  local ret=0
+    [ "${OS}" == "fedora" ] && return 0
+
+    local from_version
+    local upgrade_path="12 13 15 16"
+
+    for from_version in $upgrade_path; do
+        # Do not test migration from $VERSION:remote to $VERSION:local
+        test $(version2number $from_version) -lt $(version2number "$VERSION") \
+            || break
+        # Skip if the previous image is not available in the registry
+        docker pull "$(get_image_id "$from_version:remote")" || continue
+        test/run_migration_test $from_version:remote $VERSION:local || ret=1
+    done
+  if [ $ret -eq 0 ]; then
+    echo "  Success!"
+  fi
+  return $ret
 }
 
 # run_pgaudit_test
@@ -1043,6 +1043,17 @@ EOSQL" || ret=3
   return $ret
 }
 
+# run_env_extension_load_test
+# --------------------
+# Tries to load pgaudit extension using environment variables
+# `POSTGRESQL_EXTENSIONS` and `POSTGRESQL_LIBRARIES`
+run_env_extension_load_test() {
+    DOCKER_EXTRA_ARGS="
+-e POSTGRESQL_EXTENSIONS=pgaudit
+-e POSTGRESQL_LIBRARIES=pgaudit"
+    run_pgaudit_test
+}
+
 # run_logging_test
 # --------------------
 # Checks that changing log location via `POSTGRESQL_LOG_DESTINATION` env
@@ -1090,17 +1101,6 @@ run_logging_test()
   echo "  Success!"
 }
 
-# run_env_extension_load_test
-# --------------------
-# Tries to load pgaudit extension using environment variables
-# `POSTGRESQL_EXTENSIONS` and `POSTGRESQL_LIBRARIES`
-run_env_extension_load_test() {
-    DOCKER_EXTRA_ARGS="
--e POSTGRESQL_EXTENSIONS=pgaudit
--e POSTGRESQL_LIBRARIES=pgaudit"
-    run_pgaudit_test
-}
-
 # configuration defaults
 POSTGRESQL_MAX_CONNECTIONS=100
 POSTGRESQL_MAX_PREPARED_TRANSACTIONS=0

From 2b0c29b6d1722b44c49f2ce0a89dd99ec53b9bd3 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 13 Jan 2025 13:31:15 +0000
Subject: [PATCH 492/509] Bump common from `008d6ea` to `1d0d261`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `008d6ea` to `1d0d261`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/008d6eaccbea0502db3e87d36eef153cdbad0171...1d0d26106141ea319833145c1674558035c46a2f)

---
updated-dependencies:
- dependency-name: common
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 008d6eac..1d0d2610 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 008d6eaccbea0502db3e87d36eef153cdbad0171
+Subproject commit 1d0d26106141ea319833145c1674558035c46a2f

From 9606f1390add885d227883401d5008681ee5bd14 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 15 Jan 2025 09:47:37 +0100
Subject: [PATCH 493/509] Enable testing postgresql-container on RHEL10 quest.

No code is changed. GitHub Action should not be needed to call

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/container-tests.yml   | 2 +-
 .github/workflows/openshift-pytests.yml | 2 +-
 .github/workflows/openshift-tests.yml   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/container-tests.yml b/.github/workflows/container-tests.yml
index b92035fd..c9aff50e 100644
--- a/.github/workflows/container-tests.yml
+++ b/.github/workflows/container-tests.yml
@@ -58,7 +58,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "11", "12", "13", "14", "15", "16" ]
-        os_test: [ "fedora", "rhel8", "rhel9", "c9s", "c10s" ]
+        os_test: [ "fedora", "rhel8", "rhel9", "rhel10", "c9s", "c10s" ]
         test_case: [ "container" ]
 
     if: |
diff --git a/.github/workflows/openshift-pytests.yml b/.github/workflows/openshift-pytests.yml
index f41d96ae..a6da8e63 100644
--- a/.github/workflows/openshift-pytests.yml
+++ b/.github/workflows/openshift-pytests.yml
@@ -28,7 +28,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "12", "13", "14", "15", "16" ]
-        os_test: [ "rhel8", "rhel9"]
+        os_test: [ "rhel8", "rhel9", "rhel10"]
         test_case: [ "openshift-pytest" ]
 
     steps:
diff --git a/.github/workflows/openshift-tests.yml b/.github/workflows/openshift-tests.yml
index 3c2e1167..845abd62 100644
--- a/.github/workflows/openshift-tests.yml
+++ b/.github/workflows/openshift-tests.yml
@@ -48,7 +48,7 @@ jobs:
       fail-fast: false
       matrix:
         version: [ "11", "12", "13", "15", "16" ]
-        os_test: [ "rhel8", "rhel9"]
+        os_test: [ "rhel8", "rhel9", "rhel10" ]
         test_case: [ "openshift-4" ]
     steps:
       - uses: sclorg/tfaga-wrapper@main

From b83bbfdd8d44a26de06b9f628ad740e7d4e8b43f Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 28 Jan 2025 15:59:52 +0100
Subject: [PATCH 494/509] Add support for RHEL10 for dist-gen source files.

PostgreSQL 16 is supported on RHEL10.

README.md file is updated for the each version as well.

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 manifest.yml                                          |  3 +++
 specs/multispec.yml                                   | 11 +++++++++++
 src/Dockerfile                                        |  4 ++--
 .../usr/share/container-scripts/postgresql/README.md  |  2 +-
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/manifest.yml b/manifest.yml
index b11b4022..de712638 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -29,6 +29,9 @@ DISTGEN_MULTI_RULES:
   - src: src/Dockerfile
     dest: Dockerfile.rhel9
 
+  - src: src/Dockerfile
+    dest: Dockerfile.rhel10
+
   - src: src/Dockerfile
     dest: Dockerfile.c9s
 
diff --git a/specs/multispec.yml b/specs/multispec.yml
index 4a36adcd..70ddfd85 100644
--- a/specs/multispec.yml
+++ b/specs/multispec.yml
@@ -52,6 +52,16 @@ specs:
            { yum -y module enable postgresql:{{ spec.version }} || :; } && \
        post_install: >-4
            (yum -y reinstall tzdata || yum -y update tzdata ) && \
+    rhel10:
+       distros:
+         - rhel-10-x86_64
+       s2i_base: ubi10/s2i-core
+       org: "rhel10"
+       prod: "rhel10"
+       openshift_tags: "database,postgresql,postgresql{{ spec.short }},postgresql-{{ spec.short }}"
+       redhat_component: "postgresql-{{ spec.short }}-container"
+       img_name: "{{ spec.org }}/postgresql-{{ spec.short }}"
+       pkgs: "postgresql{{ spec.short }}-server postgresql{{ spec.short }}-contrib"
     c9s:
       distros:
         - centos-stream-9-x86_64
@@ -139,3 +149,4 @@ matrix:
         - centos-stream-9-x86_64
         - fedora-40-x86_64
         - centos-stream-10-x86_64
+        - rhel-10-x86_64
diff --git a/src/Dockerfile b/src/Dockerfile
index 55da1c75..881312e8 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -55,7 +55,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 {% if spec.repo_enable_reason %}
 {{ spec.repo_enable_reason }}
 {% endif %}
-{% if spec.prod == "c10s" %}
+{% if spec.prod == "c10s" or spec.prod == "rhel10" %}
 RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
     PSQL_PKGS="{{ spec.pkgs }}" && \
 {% elif spec.prod == "rhel9" and spec.version == "13" %} \
@@ -70,7 +70,7 @@ RUN {{ spec.environment_setup }}
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     {% endif %}
 {% endif %}
-{% if spec.prod == "c10s" %}
+{% if spec.prod == "c10s" or spec.prod == "rhel10" %}
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \
     rpm -V $INSTALL_PKGS {{ spec.check_pkgs }} && \
 {% else %}
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 37c2469a..8ab2f87a 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -200,4 +200,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, the RHEL10 Dockerfile is named Dockerfile.rhel10, and the Fedora Dockerfile is named Dockerfile.fedora.

From 30c08c7d387d26a411f0de553820380621b3fbf4 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 28 Jan 2025 16:01:03 +0100
Subject: [PATCH 495/509] Update README.md files and add generated
 16/Dockerfile.rhel10

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .../container-scripts/postgresql/README.md    |  2 +-
 .../container-scripts/postgresql/README.md    |  2 +-
 .../container-scripts/postgresql/README.md    |  2 +-
 16/Dockerfile.rhel10                          | 92 +++++++++++++++++++
 .../container-scripts/postgresql/README.md    |  2 +-
 README.md                                     |  1 +
 6 files changed, 97 insertions(+), 4 deletions(-)
 create mode 100644 16/Dockerfile.rhel10

diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 3cb10149..9420848b 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -200,4 +200,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, the RHEL10 Dockerfile is named Dockerfile.rhel10, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index 3ee52614..d981794b 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -200,4 +200,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, the RHEL10 Dockerfile is named Dockerfile.rhel10, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index c91a0565..33d31a04 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -200,4 +200,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, the RHEL10 Dockerfile is named Dockerfile.rhel10, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/16/Dockerfile.rhel10 b/16/Dockerfile.rhel10
new file mode 100644
index 00000000..b482e7c8
--- /dev/null
+++ b/16/Dockerfile.rhel10
@@ -0,0 +1,92 @@
+FROM ubi10/s2i-core
+
+# PostgreSQL image for OpenShift.
+# Volumes:
+#  * /var/lib/pgsql/data   - Database cluster for PostgreSQL
+# Environment:
+#  * $POSTGRESQL_USER     - Database user name
+#  * $POSTGRESQL_PASSWORD - User's password
+#  * $POSTGRESQL_DATABASE - Name of the database to create
+#  * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
+#                           PostgreSQL administrative account
+
+ENV POSTGRESQL_VERSION=16 \
+    POSTGRESQL_PREV_VERSION=15 \
+    HOME=/var/lib/pgsql \
+    PGUSER=postgres \
+    APP_DATA=/opt/app-root
+
+ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \
+    DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \
+The image contains the client and server programs that you'll need to \
+create, run, maintain and access a PostgreSQL DBMS server."
+
+LABEL summary="$SUMMARY" \
+      description="$DESCRIPTION" \
+      io.k8s.description="$DESCRIPTION" \
+      io.k8s.display-name="PostgreSQL 16" \
+      io.openshift.expose-services="5432:postgresql" \
+      io.openshift.tags="database,postgresql,postgresql16,postgresql-16" \
+      io.openshift.s2i.assemble-user="26" \
+      name="rhel10/postgresql-16" \
+      com.redhat.component="postgresql-16-container" \
+      version="1" \
+      com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
+      usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 rhel10/postgresql-16" \
+      maintainer="SoftwareCollections.org <sclorg@redhat.com>"
+
+EXPOSE 5432
+
+COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
+
+# This image must forever use UID 26 for postgres user so our volumes are
+# safe in the future. This should *never* change, the last test is there
+# to make sure of that.
+RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
+    PSQL_PKGS="postgresql16-server postgresql16-contrib" && \
+    INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
+    INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
+    yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS  && \
+    rpm -V $INSTALL_PKGS  && \
+    postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
+    yum -y clean all --enablerepo='*' && \
+    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
+    test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
+    mkdir -p /var/lib/pgsql/data && \
+    mkdir -p /run/postgresql && \
+    /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql
+
+# Get prefix path and path to scripts rather than hard-code them in scripts
+ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
+    ENABLED_COLLECTIONS=
+
+COPY root /
+COPY ./s2i/bin/ $STI_SCRIPTS_PATH
+
+# Hard links are not supported in Testing Farm approach during sync to guest
+# operation system. Therefore tests are failing on error
+# /usr/libexec/s2i/run no such file or directory
+RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run
+
+# Not using VOLUME statement since it's not working in OpenShift Online:
+# https://github.com/sclorg/httpd-container/issues/30
+# VOLUME ["/var/lib/pgsql/data"]
+
+# S2I permission fixes
+# --------------------
+# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i
+#    build process would be executed as 'uid=26(postgres) gid=26(postgres)'.
+#    Such process wouldn't be able to execute the default 'assemble' script
+#    correctly (it transitively executes 'fix-permissions' script).  So let's
+#    add the 'postgres' user into 'root' group here
+#
+# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build
+#    anyways) to assure that s2i process is actually able to _read_ the
+#    user-specified scripting.
+RUN usermod -a -G root postgres && \
+    /usr/libexec/fix-permissions --read-only "$APP_DATA"
+
+USER 26
+
+ENTRYPOINT ["container-entrypoint"]
+CMD ["run-postgresql"]
diff --git a/16/root/usr/share/container-scripts/postgresql/README.md b/16/root/usr/share/container-scripts/postgresql/README.md
index c79cf68e..348060da 100644
--- a/16/root/usr/share/container-scripts/postgresql/README.md
+++ b/16/root/usr/share/container-scripts/postgresql/README.md
@@ -200,4 +200,4 @@ Subsequently, log output is redirected to the logging collector process and will
 
 ## Additional Resources
 
-The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, and the Fedora Dockerfile is named Dockerfile.fedora.
+The Dockerfile and other sources related to this container image can be found at https://github.com/sclorg/postgresql-container. In this repository, the RHEL8 Dockerfile is named Dockerfile.rhel8, the RHEL9 Dockerfile is named Dockerfile.rhel9, the RHEL10 Dockerfile is named Dockerfile.rhel10, and the Fedora Dockerfile is named Dockerfile.fedora.
diff --git a/README.md b/README.md
index 51c2104f..4c317745 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ PostgreSQL versions currently supported are:
 RHEL versions currently supported are:
 - RHEL8
 - RHEL9
+- RHEL10
 
 CentOS versions currently supported are:
 - CentOS Stream 9

From 2b1fb7873ad303bd353496911d27f03aa5f16249 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 11 Feb 2025 09:22:10 +0100
Subject: [PATCH 496/509] Fix postgresql-container test for Helm Charts.

The helm charts have been renamed
from `postgresql-*` -> `redhat-postgresql-*`

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test_shared_helm_postgresql_imagestreams.py | 2 +-
 test/test_shared_helm_postgresql_template.py     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/test_shared_helm_postgresql_imagestreams.py b/test/test_shared_helm_postgresql_imagestreams.py
index bf0ea4b4..94f988e4 100644
--- a/test/test_shared_helm_postgresql_imagestreams.py
+++ b/test/test_shared_helm_postgresql_imagestreams.py
@@ -18,7 +18,7 @@
 class TestHelmRHELPostgresqlImageStreams:
 
     def setup_method(self):
-        package_name = "postgresql-imagestreams"
+        package_name = "redhat-postgresql-imagestreams"
         path = test_dir
         self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
         self.hc_api.clone_helm_chart_repo(
diff --git a/test/test_shared_helm_postgresql_template.py b/test/test_shared_helm_postgresql_template.py
index 7c16e52b..226e4e04 100644
--- a/test/test_shared_helm_postgresql_template.py
+++ b/test/test_shared_helm_postgresql_template.py
@@ -29,7 +29,7 @@
 class TestHelmPostgresqlPersistent:
 
     def setup_method(self):
-        package_name = "postgresql-persistent"
+        package_name = "redhat-postgresql-persistent"
         path = test_dir
         self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
         self.hc_api.clone_helm_chart_repo(
@@ -41,10 +41,10 @@ def teardown_method(self):
         self.hc_api.delete_project()
 
     def test_package_persistent(self):
-        self.hc_api.package_name = "postgresql-imagestreams"
+        self.hc_api.package_name = "redhat-postgresql-imagestreams"
         assert self.hc_api.helm_package()
         assert self.hc_api.helm_installation()
-        self.hc_api.package_name = "postgresql-persistent"
+        self.hc_api.package_name = "redhat-postgresql-persistent"
         assert self.hc_api.helm_package()
         assert self.hc_api.helm_installation(
             values={

From f74b8a5f69dbdf410f14886589c46a94af24613b Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 12 Feb 2025 11:43:41 +0100
Subject: [PATCH 497/509] Do not use shared_cluster on OpenShift 4

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test_shared_helm_postgresql_imagestreams.py | 2 +-
 test/test_shared_helm_postgresql_template.py     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/test_shared_helm_postgresql_imagestreams.py b/test/test_shared_helm_postgresql_imagestreams.py
index 94f988e4..70d22395 100644
--- a/test/test_shared_helm_postgresql_imagestreams.py
+++ b/test/test_shared_helm_postgresql_imagestreams.py
@@ -20,7 +20,7 @@ class TestHelmRHELPostgresqlImageStreams:
     def setup_method(self):
         package_name = "redhat-postgresql-imagestreams"
         path = test_dir
-        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
+        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
         self.hc_api.clone_helm_chart_repo(
             repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
             subdir="charts/redhat"
diff --git a/test/test_shared_helm_postgresql_template.py b/test/test_shared_helm_postgresql_template.py
index 226e4e04..37562798 100644
--- a/test/test_shared_helm_postgresql_template.py
+++ b/test/test_shared_helm_postgresql_template.py
@@ -31,7 +31,7 @@ class TestHelmPostgresqlPersistent:
     def setup_method(self):
         package_name = "redhat-postgresql-persistent"
         path = test_dir
-        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
+        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
         self.hc_api.clone_helm_chart_repo(
             repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
             subdir="charts/redhat"

From 09b790cac05659c6eea2bcbee2c59245660325f8 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Wed, 12 Feb 2025 13:14:01 +0100
Subject: [PATCH 498/509] Fix helm chart name

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test_shared_helm_postgresql_template.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/test_shared_helm_postgresql_template.py b/test/test_shared_helm_postgresql_template.py
index 37562798..89d2cb7f 100644
--- a/test/test_shared_helm_postgresql_template.py
+++ b/test/test_shared_helm_postgresql_template.py
@@ -49,8 +49,8 @@ def test_package_persistent(self):
         assert self.hc_api.helm_installation(
             values={
                 ".image.tag": f"{VERSION}{TAG}",
-                ".namespace": self.hc_api.namespace
+                ".namespace": self.hc_api.namespace,
             }
         )
-        assert self.hc_api.is_pod_running(pod_name_prefix="postgresql-persistent")
+        assert self.hc_api.is_pod_running(pod_name_prefix="redhat-postgresql-persistent")
         assert self.hc_api.test_helm_chart(expected_str=["accepting connection"])

From e65d040374930106672d88a26b275ee02e56ab37 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 14 Feb 2025 11:31:47 +0100
Subject: [PATCH 499/509] Fix helm_charts_imagestreams

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 test/test_shared_helm_postgresql_imagestreams.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_shared_helm_postgresql_imagestreams.py b/test/test_shared_helm_postgresql_imagestreams.py
index 70d22395..c435c6f9 100644
--- a/test/test_shared_helm_postgresql_imagestreams.py
+++ b/test/test_shared_helm_postgresql_imagestreams.py
@@ -20,7 +20,7 @@ class TestHelmRHELPostgresqlImageStreams:
     def setup_method(self):
         package_name = "redhat-postgresql-imagestreams"
         path = test_dir
-        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
+        self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True)
         self.hc_api.clone_helm_chart_repo(
             repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
             subdir="charts/redhat"

From e2e1e3f44a128c669434a5a17febba79029bf4eb Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 24 Mar 2025 09:25:43 +0100
Subject: [PATCH 500/509] Replace 'bind-utils' with 'bind9.18-utils'

See Jira issue https://issues.redhat.com/browse/RHEL-80345

It is valid only for RHEL9
---
 src/Dockerfile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Dockerfile b/src/Dockerfile
index 881312e8..5e59a742 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -59,7 +59,10 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 RUN INSTALL_PKGS="rsync tar gettext-envsubst bind-utils nss_wrapper-libs glibc-locale-source xz" && \
     PSQL_PKGS="{{ spec.pkgs }}" && \
 {% elif spec.prod == "rhel9" and spec.version == "13" %} \
-RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \
+RUN INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs {{ spec.pkgs }}" && \
+{% elif spec.prod == "rhel9" and spec.version in ["15", "16"] %}
+RUN {{ spec.environment_setup }}
+    INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs {{ spec.pkgs }}" && \
 {% else %}
 RUN {{ spec.environment_setup }}
     INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs {{ spec.pkgs }}" && \

From a3e439c9e3054d3a78c9fb4d30d0bcd90f8288b4 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Mon, 24 Mar 2025 09:27:04 +0100
Subject: [PATCH 501/509] Add dist-gen generated sources

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 13/Dockerfile.rhel9 | 2 +-
 15/Dockerfile.rhel9 | 2 +-
 16/Dockerfile.rhel9 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/13/Dockerfile.rhel9 b/13/Dockerfile.rhel9
index 19d70596..7773e218 100644
--- a/13/Dockerfile.rhel9
+++ b/13/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
  \
-RUN INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
+RUN INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/15/Dockerfile.rhel9 b/15/Dockerfile.rhel9
index 1a09870a..e106a477 100644
--- a/15/Dockerfile.rhel9
+++ b/15/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN { yum -y module enable postgresql:15 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9
index e560842d..a3243da2 100644
--- a/16/Dockerfile.rhel9
+++ b/16/Dockerfile.rhel9
@@ -43,7 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
 # safe in the future. This should *never* change, the last test is there
 # to make sure of that.
 RUN { yum -y module enable postgresql:16 || :; } && \
-    INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
+    INSTALL_PKGS="rsync tar gettext bind9.18-utils nss_wrapper-libs postgresql-server postgresql-contrib" && \
     INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
     INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
     yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \

From 2c022110a747cd2a1fa28f7c9b504a6bbc3678d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20Janu=C5=A1?= <fjanus@redhat.com>
Date: Tue, 15 Apr 2025 10:13:11 +0200
Subject: [PATCH 502/509] Revert documentation removed by the  commit
 9c52e6c5aae6007b1a1742b948ddf19359c7268e (#609)

---
 .../container-scripts/postgresql/README.md    | 24 +++++++++++++++++++
 .../container-scripts/postgresql/README.md    | 24 +++++++++++++++++++
 .../container-scripts/postgresql/README.md    | 24 +++++++++++++++++++
 .../container-scripts/postgresql/README.md    | 24 +++++++++++++++++++
 .../container-scripts/postgresql/README.md    | 24 +++++++++++++++++++
 5 files changed, 120 insertions(+)

diff --git a/12/root/usr/share/container-scripts/postgresql/README.md b/12/root/usr/share/container-scripts/postgresql/README.md
index 9420848b..2b670b51 100644
--- a/12/root/usr/share/container-scripts/postgresql/README.md
+++ b/12/root/usr/share/container-scripts/postgresql/README.md
@@ -144,6 +144,30 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
+## Upgrading Database
+
+Upgrading by switching to newer PostgreSQL image version
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+This image supports automatic upgrade of data directories created by the PostgreSQL server version 10 (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
+
+**`copy`**
+
+Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
+
+**`hardlink`**
+
+
+Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
+
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-12` image, available via `postgresql:12` imagestream tag in Openshift.
diff --git a/13/root/usr/share/container-scripts/postgresql/README.md b/13/root/usr/share/container-scripts/postgresql/README.md
index d981794b..a517159c 100644
--- a/13/root/usr/share/container-scripts/postgresql/README.md
+++ b/13/root/usr/share/container-scripts/postgresql/README.md
@@ -144,6 +144,30 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
+## Upgrading Database
+
+Upgrading by switching to newer PostgreSQL image version
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+This image supports automatic upgrade of data directories created by the PostgreSQL server version 12 (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
+
+**`copy`**
+
+Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
+
+**`hardlink`**
+
+
+Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
+
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-13` image, available via `postgresql:13` imagestream tag in Openshift.
diff --git a/15/root/usr/share/container-scripts/postgresql/README.md b/15/root/usr/share/container-scripts/postgresql/README.md
index 33d31a04..17897b15 100644
--- a/15/root/usr/share/container-scripts/postgresql/README.md
+++ b/15/root/usr/share/container-scripts/postgresql/README.md
@@ -144,6 +144,30 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
+## Upgrading Database
+
+Upgrading by switching to newer PostgreSQL image version
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+This image supports automatic upgrade of data directories created by the PostgreSQL server version 13 (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
+
+**`copy`**
+
+Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
+
+**`hardlink`**
+
+
+Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
+
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `rhel8/postgresql-15` image, available via `postgresql:15` imagestream tag in Openshift.
diff --git a/16/root/usr/share/container-scripts/postgresql/README.md b/16/root/usr/share/container-scripts/postgresql/README.md
index 348060da..b33442fd 100644
--- a/16/root/usr/share/container-scripts/postgresql/README.md
+++ b/16/root/usr/share/container-scripts/postgresql/README.md
@@ -144,6 +144,30 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
+## Upgrading Database
+
+Upgrading by switching to newer PostgreSQL image version
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+This image supports automatic upgrade of data directories created by the PostgreSQL server version 15 (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
+
+**`copy`**
+
+Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
+
+**`hardlink`**
+
+
+Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
+
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `` image, available via `postgresql:16` imagestream tag in Openshift.
diff --git a/src/root/usr/share/container-scripts/postgresql/README.md b/src/root/usr/share/container-scripts/postgresql/README.md
index 8ab2f87a..87943d94 100644
--- a/src/root/usr/share/container-scripts/postgresql/README.md
+++ b/src/root/usr/share/container-scripts/postgresql/README.md
@@ -144,6 +144,30 @@ admin user is by changing the environment variables `POSTGRESQL_PASSWORD` and `P
 
 Changing database passwords through SQL statements or any other method than the environment variables mentioned above will cause a mismatch between the stored variable values and the actual passwords. When a database container starts, it will reset the passwords to the values stored in the environment variables.
 
+## Upgrading Database
+
+Upgrading by switching to newer PostgreSQL image version
+
+---
+
+** Warning! Before deciding to upgrade the data directory, ensure that you have carefully backed up all your data and are prepared for potential manual rollback! **
+This image supports automatic upgrade of data directories created by the PostgreSQL server version {{ spec.prev_version }} (and _only_ this version) - provided by sclorg image. The upgrade process is designed to allow you to switch from _image A_ to _image B_, and set the `$POSTGRESQL_UPGRADE` variable appropriately to explicitly request the database data transformation.
+
+The upgrade process is internally implemented via the `pg_upgrade` binary, which requires the container to contain two versions of the PostgreSQL server (refer to `man pg_upgrade` for more information).
+
+For the `pg_upgrade` process and the new server version, a new data directory must be initialized. The container tooling automatically creates this data directory under `/var/lib/pgsql/data`, which is typically an external bind-mountpoint. The `pg_upgrade` execution is then similar to the **dump and restore**
+approach: it starts both the old and new PostgreSQL servers (within the container) and "dumps" the old data directory while simultaneously "restoring" it into the new data directory. This operation involves copying many data files, so you can decide the type of upgrade by setting `$POSTGRESQL_UPGRADE` accordingly:
+
+**`copy`**
+
+Data files are copied from old datadir to new datadir. This option has a low risk of data loss in case of upgrade failure.
+Note that because the data directory is copied, ensure that you have enough space for the copy. Upgrade failure due to insufficient space may lead to data loss.
+
+**`hardlink`**
+
+
+Data files are hard-linked from the old to the new data directory, providing performance optimization. However, the old directory becomes unusable, even in case of failure.
+
 ## Extending Image
 
 You can extend this image in Openshift using the `Source` build strategy or via the standalone [source-to-image](https://github.com/openshift/source-to-image) application (where available). For this example, assume that you are using the `{{ spec.rhel_image_name }}` image, available via `postgresql:{{ spec.version }}` imagestream tag in Openshift.

From e0bd882176383a965eb736019bfcbfc8ec14e068 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 28 Apr 2025 14:18:08 +0000
Subject: [PATCH 503/509] Bump common from `1d0d261` to `bc49c74`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `1d0d261` to `bc49c74`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/1d0d26106141ea319833145c1674558035c46a2f...bc49c74ec984e34321694f00a6b13021e547d827)

---
updated-dependencies:
- dependency-name: common
  dependency-version: bc49c74ec984e34321694f00a6b13021e547d827
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 1d0d2610..bc49c74e 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 1d0d26106141ea319833145c1674558035c46a2f
+Subproject commit bc49c74ec984e34321694f00a6b13021e547d827

From 5799ce13a52e7c77a278615de33aa698aa7b3905 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 15 May 2025 13:41:43 +0200
Subject: [PATCH 504/509] Add support for testing RHEL10 imagestreams.

Refactoring PyTest so we do not duplicate definitions

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 imagestreams/imagestreams.yaml                 |  6 ++++++
 imagestreams/postgresql-rhel-aarch64.json      | 18 ++++++++++++++++++
 imagestreams/postgresql-rhel.json              | 18 ++++++++++++++++++
 test/__init__.py                               |  0
 test/constants.py                              |  5 +++++
 test/pg-test-lib.sh                            |  4 ++++
 test/test-lib-postgresql.sh                    |  2 ++
 test/test_postgresql_imagestream.py            | 11 +++++------
 test/test_postgresql_imagestream_template.py   | 11 +++++------
 test/test_postgresql_template.py               | 10 ++++------
 ...test_shared_helm_postgresql_imagestreams.py |  1 +
 test/test_shared_helm_postgresql_template.py   |  8 +++-----
 12 files changed, 71 insertions(+), 23 deletions(-)
 create mode 100644 test/__init__.py
 create mode 100644 test/constants.py

diff --git a/imagestreams/imagestreams.yaml b/imagestreams/imagestreams.yaml
index c0abe2fb..98f750a9 100644
--- a/imagestreams/imagestreams.yaml
+++ b/imagestreams/imagestreams.yaml
@@ -27,6 +27,9 @@
       - name: RHEL 9
         app_versions: [13, 15, 16]
 
+      - name: RHEL 10
+        app_versions: [16]
+
   - filename: postgresql-rhel-aarch64.json
     latest: "16-el9"
     distros:
@@ -35,3 +38,6 @@
 
       - name: RHEL 9
         app_versions: [13, 15, 16]
+
+      - name: RHEL 10
+        app_versions: [16]
diff --git a/imagestreams/postgresql-rhel-aarch64.json b/imagestreams/postgresql-rhel-aarch64.json
index 1dd1c669..1f18352c 100644
--- a/imagestreams/postgresql-rhel-aarch64.json
+++ b/imagestreams/postgresql-rhel-aarch64.json
@@ -135,6 +135,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 10)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel10/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {
diff --git a/imagestreams/postgresql-rhel.json b/imagestreams/postgresql-rhel.json
index 1dd1c669..1f18352c 100644
--- a/imagestreams/postgresql-rhel.json
+++ b/imagestreams/postgresql-rhel.json
@@ -135,6 +135,24 @@
           "type": "Local"
         }
       },
+      {
+        "name": "16-el10",
+        "annotations": {
+          "openshift.io/display-name": "PostgreSQL 16 (RHEL 10)",
+          "openshift.io/provider-display-name": "Red Hat, Inc.",
+          "description": "Provides a PostgreSQL 16 database on RHEL 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/README.md.",
+          "iconClass": "icon-postgresql",
+          "tags": "database,postgresql",
+          "version": "16"
+        },
+        "from": {
+          "kind": "DockerImage",
+          "name": "registry.redhat.io/rhel10/postgresql-16:latest"
+        },
+        "referencePolicy": {
+          "type": "Local"
+        }
+      },
       {
         "name": "latest",
         "annotations": {
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/test/constants.py b/test/constants.py
new file mode 100644
index 00000000..26eb71ae
--- /dev/null
+++ b/test/constants.py
@@ -0,0 +1,5 @@
+TAGS = {
+    "rhel8": "-el8",
+    "rhel9": "-el9",
+    "rhel10": "-el10",
+}
diff --git a/test/pg-test-lib.sh b/test/pg-test-lib.sh
index 9b184df9..da0bef44 100644
--- a/test/pg-test-lib.sh
+++ b/test/pg-test-lib.sh
@@ -29,6 +29,10 @@ get_image_id ()
                 ns=rhel9
                 local image=registry.redhat.io/$ns/postgresql-${version}
                 ;;
+            rhel10)
+                ns=rhel10
+                local image=registry.redhat.io/$ns/postgresql-${version}
+                ;;
             c9s)
                 ns=c9s
                 local image=quay.io/sclorg/postgresql-${version}-$ns
diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh
index bb255e38..8d0132fb 100644
--- a/test/test-lib-postgresql.sh
+++ b/test/test-lib-postgresql.sh
@@ -44,6 +44,8 @@ function test_postgresql_imagestream() {
   tag="-el8"
   if [ "${OS}" == "rhel9" ]; then
     tag="-el9"
+  elif [ "${OS}" == "rhel10" ]; then
+    tag="-el10"
   fi
   # Check if the current version is already GA
   # This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
diff --git a/test/test_postgresql_imagestream.py b/test/test_postgresql_imagestream.py
index eb1461a9..1252f405 100644
--- a/test/test_postgresql_imagestream.py
+++ b/test/test_postgresql_imagestream.py
@@ -6,6 +6,8 @@
 from container_ci_suite.openshift import OpenShiftAPI
 from container_ci_suite.utils import check_variables
 
+from constants import TAGS
+
 if not check_variables():
     print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
@@ -14,17 +16,14 @@
 VERSION = os.getenv("VERSION")
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
-TAGS = {
-    "rhel8": "-el8",
-    "rhel9": "-el9"
-}
-TAG = TAGS.get(OS, None)
+
+TAG = TAGS.get(OS)
 
 
 class TestPostgreSQLImagestreamTemplate:
 
     def setup_method(self):
-        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION)
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION, shared_cluster=True)
 
     def teardown_method(self):
         self.oc_api.delete_project()
diff --git a/test/test_postgresql_imagestream_template.py b/test/test_postgresql_imagestream_template.py
index 7ee986a0..b45d1e00 100644
--- a/test/test_postgresql_imagestream_template.py
+++ b/test/test_postgresql_imagestream_template.py
@@ -6,6 +6,8 @@
 from container_ci_suite.openshift import OpenShiftAPI
 from container_ci_suite.utils import check_variables
 
+from constants import TAGS
+
 if not check_variables():
     print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
@@ -14,17 +16,14 @@
 VERSION = os.getenv("VERSION")
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
-TAGS = {
-    "rhel8": "-el8",
-    "rhel9": "-el9"
-}
-TAG = TAGS.get(OS, None)
+
+TAG = TAGS.get(OS)
 
 
 class TestPostgreSQLImagestreamTemplate:
 
     def setup_method(self):
-        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION)
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql", version=VERSION, shared_cluster=True)
 
     def teardown_method(self):
         self.oc_api.delete_project()
diff --git a/test/test_postgresql_template.py b/test/test_postgresql_template.py
index cc19ad85..dc18cf76 100644
--- a/test/test_postgresql_template.py
+++ b/test/test_postgresql_template.py
@@ -6,6 +6,8 @@
 from container_ci_suite.openshift import OpenShiftAPI
 from container_ci_suite.utils import check_variables
 
+from constants import TAGS
+
 if not check_variables():
     print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
@@ -15,17 +17,13 @@
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
 
-TAGS = {
-    "rhel8": "-el8",
-    "rhel9": "-el9"
-}
-TAG = TAGS.get(OS, None)
+TAG = TAGS.get(OS)
 
 
 class TestPostgreSQLDeployTemplate:
 
     def setup_method(self):
-        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql-testing", version=VERSION)
+        self.oc_api = OpenShiftAPI(pod_name_prefix="postgresql-testing", version=VERSION, shared_cluster=True)
 
     def teardown_method(self):
         self.oc_api.delete_project()
diff --git a/test/test_shared_helm_postgresql_imagestreams.py b/test/test_shared_helm_postgresql_imagestreams.py
index c435c6f9..19d108f4 100644
--- a/test/test_shared_helm_postgresql_imagestreams.py
+++ b/test/test_shared_helm_postgresql_imagestreams.py
@@ -39,6 +39,7 @@ def teardown_method(self):
             ("15-el9", "registry.redhat.io/rhel9/postgresql-15:latest", True),
             ("16-el8", "registry.redhat.io/rhel8/postgresql-16:latest", True),
             ("16-el9", "registry.redhat.io/rhel9/postgresql-16:latest", True),
+            ("16-el10", "registry.redhat.io/rhel10/postgresql-16:latest", True),
         ],
     )
     def test_package_imagestream(self, version, registry, expected):
diff --git a/test/test_shared_helm_postgresql_template.py b/test/test_shared_helm_postgresql_template.py
index 89d2cb7f..1e86cacd 100644
--- a/test/test_shared_helm_postgresql_template.py
+++ b/test/test_shared_helm_postgresql_template.py
@@ -8,6 +8,8 @@
 from container_ci_suite.helm import HelmChartsAPI
 from container_ci_suite.utils import check_variables
 
+from constants import TAGS
+
 if not check_variables():
     print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
     sys.exit(1)
@@ -19,11 +21,7 @@
 IMAGE_NAME = os.getenv("IMAGE_NAME")
 OS = os.getenv("TARGET")
 
-TAGS = {
-    "rhel8": "-el8",
-    "rhel9": "-el9"
-}
-TAG = TAGS.get(OS, None)
+TAG = TAGS.get(OS)
 
 
 class TestHelmPostgresqlPersistent:

From 1a17236700eb0829c4dc064b7ff8a84bdbef5b31 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 27 May 2025 15:08:16 +0200
Subject: [PATCH 505/509] Disable schedule for auto-merge-on-demand.

Allow run it on comment '/auto-merge-on-demant'

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/auto-merge-on-demand.yml | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/auto-merge-on-demand.yml b/.github/workflows/auto-merge-on-demand.yml
index 47003fdd..9cd10d05 100644
--- a/.github/workflows/auto-merge-on-demand.yml
+++ b/.github/workflows/auto-merge-on-demand.yml
@@ -1,8 +1,8 @@
-name: Auto Merge Scheduled / On Demand
+name: Auto Merge On Demand
 on:
-  schedule:
-    # Workflow runs every 45 minutes
-    - cron: '*/45 * * * *'
+  issue_comment:
+    types:
+      - created
   workflow_dispatch:
     inputs:
       pr-number:
@@ -16,7 +16,10 @@ permissions:
 jobs:
   # Get all open PRs
   gather-pull-requests:
-    if: github.repository_owner == 'sclorg'
+    if: |
+      github.repository_owner == 'sclorg'
+      || (contains(github.event.comment.body, '/auto-merge-on-demand')
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     runs-on: ubuntu-latest
 
     outputs:
@@ -44,7 +47,7 @@ jobs:
         name: Parse manual input
         run: |
           # shellcheck disable=SC2086
-          echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
+          echo "result="[ ${{ github.event.issue.number }} ]"" >> $GITHUB_OUTPUT
         shell: bash
 
   validate-pr:

From 0f1c793d49d7ed3e453c4406c436b370c477f94d Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Tue, 27 May 2025 15:30:18 +0200
Subject: [PATCH 506/509] Replace it to /auto-merge

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/auto-merge-on-demand.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/auto-merge-on-demand.yml b/.github/workflows/auto-merge-on-demand.yml
index 9cd10d05..9341a611 100644
--- a/.github/workflows/auto-merge-on-demand.yml
+++ b/.github/workflows/auto-merge-on-demand.yml
@@ -18,7 +18,7 @@ jobs:
   gather-pull-requests:
     if: |
       github.repository_owner == 'sclorg'
-      || (contains(github.event.comment.body, '/auto-merge-on-demand')
+      || (contains(github.event.comment.body, '/auto-merge')
       && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
     runs-on: ubuntu-latest
 

From a90beb518036445337992305a951cc4613aa341c Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 19 May 2025 13:14:24 +0000
Subject: [PATCH 507/509] Bump common from `bc49c74` to `a776cb0`

Bumps [common](https://github.com/sclorg/container-common-scripts) from `bc49c74` to `a776cb0`.
- [Commits](https://github.com/sclorg/container-common-scripts/compare/bc49c74ec984e34321694f00a6b13021e547d827...a776cb0a28c696c2d8adfc7184968eed48fd6909)

---
updated-dependencies:
- dependency-name: common
  dependency-version: a776cb0a28c696c2d8adfc7184968eed48fd6909
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index bc49c74e..a776cb0a 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit bc49c74ec984e34321694f00a6b13021e547d827
+Subproject commit a776cb0a28c696c2d8adfc7184968eed48fd6909

From c227e42c516a471c24545a96856747713aba8076 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Thu, 5 Jun 2025 12:28:38 +0200
Subject: [PATCH 508/509] Add missing brackets in action

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 .github/workflows/auto-merge-on-demand.yml | 2 +-
 common                                     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/auto-merge-on-demand.yml b/.github/workflows/auto-merge-on-demand.yml
index 9341a611..e2e043fe 100644
--- a/.github/workflows/auto-merge-on-demand.yml
+++ b/.github/workflows/auto-merge-on-demand.yml
@@ -19,7 +19,7 @@ jobs:
     if: |
       github.repository_owner == 'sclorg'
       || (contains(github.event.comment.body, '/auto-merge')
-      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
+      && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association))
     runs-on: ubuntu-latest
 
     outputs:
diff --git a/common b/common
index a776cb0a..3b998a50 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit a776cb0a28c696c2d8adfc7184968eed48fd6909
+Subproject commit 3b998a502defa3f9ae91888f9687fc1d8e6bfe63

From ba29dd1d4b279e798b5945497c9cb3a362b7ba29 Mon Sep 17 00:00:00 2001
From: "Petr \"Stone\" Hracek" <phracek@redhat.com>
Date: Fri, 25 Jul 2025 10:48:32 +0200
Subject: [PATCH 509/509] Update container-common-scripts to the latest one

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
---
 common | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common b/common
index 3b998a50..048d05c4 160000
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 3b998a502defa3f9ae91888f9687fc1d8e6bfe63
+Subproject commit 048d05c4259bb18eb9f179b60455f3cc5b98f05c
