From a5a8f68ebcf5d2c2b4e680521c6fa916803e21a8 Mon Sep 17 00:00:00 2001 From: Bernd Helmle Date: Wed, 12 Aug 2015 15:28:51 +0200 Subject: [PATCH] Get rid of sed magic to retrieve PGDATA directly from systemd service files. Instead rely on systemctl only, which also allows to use systemd drop-in configuration directives. The former coding also contains a bug, where PGDATA is always overwritten by settings derived from service files directly. --- rpm/redhat/9.4/postgresql/EL-7/postgresql94-setup | 15 --------------- rpm/redhat/9.5/postgresql/EL-7/postgresql95-setup | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/rpm/redhat/9.4/postgresql/EL-7/postgresql94-setup b/rpm/redhat/9.4/postgresql/EL-7/postgresql94-setup index 1f0cb0f..3a745be 100644 --- a/rpm/redhat/9.4/postgresql/EL-7/postgresql94-setup +++ b/rpm/redhat/9.4/postgresql/EL-7/postgresql94-setup @@ -83,26 +83,11 @@ if [ x"$PGDATA" = x ]; then exit 1 fi -# Find the unit file for new version. -if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ] -then - SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" -elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ] -then - SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service" -else - echo "Could not find systemd unit file ${SERVICE_NAME}.service" - exit 1 -fi - # Log file for pg_upgrade PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade.log # Log file for initdb PGLOG=/var/lib/pgsql/9.4/initdb.log -# Get data directory from the service file -PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` - export PGDATA # For SELinux we need to use 'runuser' not 'su' diff --git a/rpm/redhat/9.5/postgresql/EL-7/postgresql95-setup b/rpm/redhat/9.5/postgresql/EL-7/postgresql95-setup index 697e0b4..0ede51e 100644 --- a/rpm/redhat/9.5/postgresql/EL-7/postgresql95-setup +++ b/rpm/redhat/9.5/postgresql/EL-7/postgresql95-setup @@ -83,26 +83,11 @@ if [ x"$PGDATA" = x ]; then exit 1 fi -# Find the unit file for new version. -if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ] -then - SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" -elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ] -then - SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service" -else - echo "Could not find systemd unit file ${SERVICE_NAME}.service" - exit 1 -fi - # Log file for pg_upgrade PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade.log # Log file for initdb PGLOG=/var/lib/pgsql/9.5/initdb.log -# Get data directory from the service file -PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` - export PGDATA # For SELinux we need to use 'runuser' not 'su' -- 1.8.3.1