>From e87be2010c7dab69ab77ed965f1f9ad5eacef057 Mon Sep 17 00:00:00 2001
From: Martin <martin@2ndquadrant.com>
Date: Wed, 30 Dec 2015 18:52:46 -0300
Subject: [PATCH] Changes to the spec file to fix a few issues: * Missing
 /var/run/repmgr directory used for the PID file * Change user from repmgr to
 postgres

---
 rpm/redhat/9.3/repmgr/EL-5/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/EL-6/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/EL-7/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/F-19/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/F-20/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/F-21/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/F-22/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.3/repmgr/F-23/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/EL-5/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/EL-6/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/EL-7/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/F-20/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/F-21/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/F-22/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.4/repmgr/F-23/repmgr.spec | 21 +++++++++++++--------
 rpm/redhat/9.5/repmgr/EL-5/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/EL-6/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/EL-7/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/F-20/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/F-21/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/F-22/repmgr.spec | 25 ++++++++++++-------------
 rpm/redhat/9.5/repmgr/F-23/repmgr.spec | 25 ++++++++++++-------------
 22 files changed, 279 insertions(+), 211 deletions(-)

diff --git a/rpm/redhat/9.3/repmgr/EL-5/repmgr.spec b/rpm/redhat/9.3/repmgr/EL-5/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/EL-5/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/EL-5/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/EL-6/repmgr.spec b/rpm/redhat/9.3/repmgr/EL-6/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/EL-6/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/EL-6/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/EL-7/repmgr.spec b/rpm/redhat/9.3/repmgr/EL-7/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/EL-7/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/EL-7/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/F-19/repmgr.spec b/rpm/redhat/9.3/repmgr/F-19/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/F-19/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/F-19/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/F-20/repmgr.spec b/rpm/redhat/9.3/repmgr/F-20/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/F-20/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/F-20/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/F-21/repmgr.spec b/rpm/redhat/9.3/repmgr/F-21/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/F-21/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/F-21/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/F-22/repmgr.spec b/rpm/redhat/9.3/repmgr/F-22/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/F-22/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/F-22/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.3/repmgr/F-23/repmgr.spec b/rpm/redhat/9.3/repmgr/F-23/repmgr.spec
index 36985e8..9563c90 100644
--- a/rpm/redhat/9.3/repmgr/F-23/repmgr.spec
+++ b/rpm/redhat/9.3/repmgr/F-23/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/F-20/repmgr.spec b/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/F-21/repmgr.spec b/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/F-22/repmgr.spec b/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.4/repmgr/F-23/repmgr.spec b/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
index aba8b39..7397199 100644
--- a/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        1%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,13 +97,18 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
-groupadd -r repmgr >/dev/null 2>&1 || :
-useradd -m -g repmgr -r -s /bin/bash \
-        -c "repmgr" repmgr >/dev/null 2>&1 || :
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
-	%{__chown} -R repmgr: /var/log/repmgr
+	%{__chown} -R postgres: /var/log/repmgr
+fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
 fi
 
 %post
@@ -115,7 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
diff --git a/rpm/redhat/9.5/repmgr/EL-5/repmgr.spec b/rpm/redhat/9.5/repmgr/EL-5/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/EL-5/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/EL-5/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/EL-6/repmgr.spec b/rpm/redhat/9.5/repmgr/EL-6/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/EL-6/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/EL-6/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/EL-7/repmgr.spec b/rpm/redhat/9.5/repmgr/EL-7/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/EL-7/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/EL-7/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/F-20/repmgr.spec b/rpm/redhat/9.5/repmgr/F-20/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/F-20/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/F-20/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/F-21/repmgr.spec b/rpm/redhat/9.5/repmgr/F-21/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/F-21/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/F-21/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/F-22/repmgr.spec b/rpm/redhat/9.5/repmgr/F-22/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/F-22/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/F-22/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
diff --git a/rpm/redhat/9.5/repmgr/F-23/repmgr.spec b/rpm/redhat/9.5/repmgr/F-23/repmgr.spec
index 224c6bf..774c08d 100644
--- a/rpm/redhat/9.5/repmgr/F-23/repmgr.spec
+++ b/rpm/redhat/9.5/repmgr/F-23/repmgr.spec
@@ -12,7 +12,7 @@
 
 Name:           %{sname}%{pgmajorversion}
 Version:        3.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Replication Manager for PostgreSQL Clusters
 License:        GPLv3
 URL:            http://www.repmgr.org
@@ -20,7 +20,7 @@ Source0:        http://repmgr.org/download/%{sname}-%{version}.tar.gz
 Source1:	repmgr-%{pgpackageversion}.service
 Source2:	repmgr.init
 Patch0:		repmgr-makefile-pgxs.patch
-Patch1:		repmgr.conf.sample.patch
+#Patch1:		repmgr.conf.sample.patch
 
 %if %{systemd_enabled}
 BuildRequires:		systemd
@@ -62,7 +62,7 @@ future PostgreSQL versions.
 %prep
 %setup -q -n %{sname}-%{version}
 %patch0 -p0
-%patch1 -p0
+#%patch1 -p0
 
 %build
 USE_PGXS=1 %{__make} %{?_smp_mflags}
@@ -97,11 +97,19 @@ install -m 755 %{SOURCE2}  %{buildroot}%{_sysconfdir}/init.d/%{sname}-%{pgpackag
 %endif
 
 %pre
+groupadd -r postgres >/dev/null 2>&1 || :
+useradd -m -g postgres -r -s /bin/bash \
+        -c "postgres" postgres >/dev/null 2>&1 || :
 if [ ! -x /var/log/repmgr ]
 then
 	%{__mkdir} -m 700 /var/log/repmgr
 	%{__chown} -R postgres: /var/log/repmgr
 fi
+if [ ! -x /var/run/repmgr ]
+then
+	%{__mkdir} -m 700 /var/run/repmgr
+	%{__chown} -R postgres: /var/run/repmgr
+fi
 
 %post
 /sbin/ldconfig
@@ -112,11 +120,7 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-if [ ! -x %{_varrundir} ]
-then
-	%{__mkdir} -m 700 %{_varrundir}
-	%{__chown} -R postgres: %{_varrundir}
-fi
+%{__chown} postgres: %{_localstatedir}/run/%{sname}
 
 %postun -p /sbin/ldconfig
 
@@ -147,11 +151,6 @@ fi
 %endif
 
 %changelog
-* Mon Nov 9 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-2
-- Ensure that /var/run/repmgr exists. Per Guillaume Lelarge.
-- Switch to postgres user while running the deamon, instead of
-  repmgr user. Per recent complaints from Guillaume and Justin King.
-
 * Tue Oct 6 2015 - Devrim Gündüz <devrim@gunduz.org> 3.0.2-1
 - Update to 3.0.2
 
-- 
2.5.0

