diff --git a/10/Dockerfile.c8s b/10/Dockerfile.c8s index 9692cd70..de499023 100644 --- a/10/Dockerfile.c8s +++ b/10/Dockerfile.c8s @@ -43,6 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions # 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" && \ + 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/10/Dockerfile.rhel8 b/10/Dockerfile.rhel8 index 236e488b..bb15518c 100644 --- a/10/Dockerfile.rhel8 +++ b/10/Dockerfile.rhel8 @@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions # 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" && \ + 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/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.c8s b/12/Dockerfile.c8s index 08da9e1b..5e96630e 100644 --- a/12/Dockerfile.c8s +++ b/12/Dockerfile.c8s @@ -43,6 +43,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions # 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 procps-ng util-linux postgresql-upgrade" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ diff --git a/12/Dockerfile.fedora b/12/Dockerfile.fedora index f5ce3586..c9d2a1b2 100644 --- a/12/Dockerfile.fedora +++ b/12/Dockerfile.fedora @@ -45,6 +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+="procps-ng util-linux postgresql-upgrade" && \ INSTALL_PKGS+="findutils xz" && \ INSTALL_PKGS+=" pgaudit" && \ dnf -y module enable postgresql:12 && \ diff --git a/12/Dockerfile.rhel8 b/12/Dockerfile.rhel8 index 9c8aa1e5..1f807edb 100644 --- a/12/Dockerfile.rhel8 +++ b/12/Dockerfile.rhel8 @@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions # 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 procps-ng util-linux postgresql-upgrade" && \ INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \ yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ 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.c8s b/13/Dockerfile.c8s index 38a8eab8..c413487e 100644 --- a/13/Dockerfile.c8s +++ b/13/Dockerfile.c8s @@ -45,7 +45,7 @@ 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 --setopt=install_weak_deps=false install $INSTALL_PKGS && \ + 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 && \ diff --git a/13/Dockerfile.fedora b/13/Dockerfile.fedora index 9588e620..28aa3903 100644 --- a/13/Dockerfile.fedora +++ b/13/Dockerfile.fedora @@ -48,6 +48,7 @@ RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-cont INSTALL_PKGS+="findutils xz" && \ INSTALL_PKGS+=" pgaudit" && \ INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ + INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ dnf -y module enable postgresql:13 && \ dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ diff --git a/13/root/usr/share/container-scripts/postgresql/common.sh b/13/root/usr/share/container-scripts/postgresql/common.sh index 9cc5dc96..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" ] && ! pg_isready > /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=/usr/lib64/pgsql/postgresql-$old_raw_version/bin - new_pgengine=/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" \ diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora index a1ece9c2..f8ad3d44 100644 --- a/14/Dockerfile.fedora +++ b/14/Dockerfile.fedora @@ -47,6 +47,7 @@ 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+="findutils xz" && \ INSTALL_PKGS+=" pgaudit" && \ + INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ dnf -y module enable postgresql:14 && \ dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $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.c8s b/15/Dockerfile.c8s index 8579ca0c..632f168a 100644 --- a/15/Dockerfile.c8s +++ b/15/Dockerfile.c8s @@ -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.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..f1d680de 100644 --- a/15/Dockerfile.fedora +++ b/15/Dockerfile.fedora @@ -47,6 +47,7 @@ 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+="findutils xz" && \ INSTALL_PKGS+=" pgaudit" && \ + INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ dnf -y module enable postgresql:15 && \ dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ rpm -V $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.c8s b/16/Dockerfile.c8s index 0498931d..bcd0f283 100644 --- a/16/Dockerfile.c8s +++ b/16/Dockerfile.c8s @@ -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.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..668d907f 100644 --- a/16/Dockerfile.fedora +++ b/16/Dockerfile.fedora @@ -47,6 +47,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \ INSTALL_PKGS+="findutils xz" && \ INSTALL_PKGS+=" postgresql16-pgaudit" && \ + INSTALL_PKGS+=" procps-ng util-linux postgresql-upgrade" && \ dnf -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.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 7f84f3b6..015ddd42 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' or spec.prod == 'c8s' %} 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..5e2e9ffe 100644 --- a/src/Dockerfile.fedora +++ b/src/Dockerfile.fedora @@ -50,6 +50,7 @@ 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 postgresql-upgrade" && \ {% else %} RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \ {% endif %} diff --git a/src/root/usr/share/container-scripts/postgresql/common.sh b/src/root/usr/share/container-scripts/postgresql/common.sh index 74c57499..7afc7ce3 100644 --- a/src/root/usr/share/container-scripts/postgresql/common.sh +++ b/src/root/usr/share/container-scripts/postgresql/common.sh @@ -312,8 +312,17 @@ run_pgupgrade () old_collection=rh-postgresql$old_raw_version fi - old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/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" \