Subject: Bug in repmgr3 package

From: Guillaume Lelarge <[email-masked]>
Date: Tue, 3 Nov 2015 10:54:25 +0100

Hi,

When installing repmgr3 package on a CentOS 6 64 bits, I always end up with
an error at postinstall saying that /var/run/repmgr doesn't exist.

Here is a patch that will hopefully fix that. (The patch deals with all
distro for 9.4 release. I didn't check other releases.)

Regards.

-- 
Guillaume.
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com
diff --git a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi
 
 %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..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi
 
 %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..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi
 
 %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..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi
 
 %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..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi
 
 %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..5ae706f 100644
--- a/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -r repmgr: %{_varrundir}
+fi
 
 %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..5ae706f 100644
--- a/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -r repmgr: %{_varrundir}
+fi
 
 %postun -p /sbin/ldconfig

-- 
Sent via pgsql-pkg-yum mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-yum

---

From: Guillaume Lelarge <[email-masked]>
Date: Tue, 3 Nov 2015 15:42:25 +0100

Hey,

2015-11-03 10:54 GMT+01:00 Guillaume Lelarge <[email-masked]>:

> Hi,
>
> When installing repmgr3 package on a CentOS 6 64 bits, I always end up
> with an error at postinstall saying that /var/run/repmgr doesn't exist.
>
I worked a bit more with repmgr. I found that the initscript doesn't
respect the $user variable all the time. Hence this new patch (which
includes the changes from the first patch).

I'm also wondering why we do have this new OS user (repmgr). It seems to be
more a burden than anything else. Actually, they have a much better
initscript in upstream that makes use the postgres OS user. The RPM package
should embrace that change.

Regards.

-- 
Guillaume.
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com
diff --git a/rpm/redhat/9.4/repmgr/EL-5/repmgr.init b/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-5/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/EL-7/repmgr.init b/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec b/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/EL-7/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/F-20/repmgr.init b/rpm/redhat/9.4/repmgr/F-20/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/F-20/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-20/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-20/repmgr.spec b/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-20/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/F-21/repmgr.init b/rpm/redhat/9.4/repmgr/F-21/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/F-21/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-21/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-21/repmgr.spec b/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
index aba8b39..29c629a 100644
--- a/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-21/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -R repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/F-22/repmgr.init b/rpm/redhat/9.4/repmgr/F-22/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/F-22/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-22/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-22/repmgr.spec b/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
index aba8b39..5ae706f 100644
--- a/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-22/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -r repmgr: %{_varrundir}
+fi

diff --git a/rpm/redhat/9.4/repmgr/F-23/repmgr.init b/rpm/redhat/9.4/repmgr/F-23/repmgr.init
index c900170..95e3757 100644
--- a/rpm/redhat/9.4/repmgr/F-23/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-23/repmgr.init
@@ -54,7 +54,7 @@ start(){
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-23/repmgr.spec b/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
index aba8b39..5ae706f 100644
--- a/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
+++ b/rpm/redhat/9.4/repmgr/F-23/repmgr.spec
@@ -115,7 +115,11 @@ fi
 # This adds the proper /etc/rc*.d links for the script
 /sbin/chkconfig --add %{sname}-%{pgpackageversion}
 %endif
-%{__chown} repmgr: %{_localstatedir}/run/%{sname}
+if [ ! -x %{_varrundir} ]
+then
+	%{__mkdir} -m 700 %{_varrundir}
+	%{__chown} -r repmgr: %{_varrundir}
+fi

---

From: Devrim GÜNDÜZ <[email-masked]>
Date: Mon, 09 Nov 2015 11:19:36 +0200

Hi Guillaume,

Thanks for the patch!

I committed your patch:

http://git.postgresql.org/gitweb/?p=pgrpms.git;a=commit;h=0cdf38c03aebb
45a40aa5895cf0753237320f164

 I also changed the username from repmgr to postgres. I pushed this
change only to 9.5 for now. Will push and test packages today, and then
I'll update the remaining branches.

Regards, Devrim

-- 
Devrim GÜNDÜZ
Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR

---

From: Guillaume Lelarge <[email-masked]>
Date: Mon, 9 Nov 2015 14:02:41 +0100

> I'll update the remaining branches.

Great, thanks Devrim.

---

From: Jeff Frost <[email-masked]>
Date: Mon, 9 Nov 2015 07:51:46 -0800

> On Nov 9, 2015, at 01:19, Devrim GÜNDÜZ <[email-masked]> wrote:
> 

Note that I haven't backed out the version bump on the 9.2 and older versions yet.

---

From: Devrim Gündüz <[email-masked]>
Date: Mon, 09 Nov 2015 22:21:10 +0000

Can you do it until tomorrow evening?

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

---

From: Jeff Frost <[email-masked]>
Date: Mon, 9 Nov 2015 14:21:59 -0800

Do you mean wait to do it until or …?

> On Nov 9, 2015, at 2:21 PM, Devrim Gündüz <[email-masked]> wrote:
>

---

From: Devrim Gündüz <[email-masked]>
Date: Mon, 09 Nov 2015 22:41:02 +0000

Can you revert it today or tomorrow? :)

---

From: Jeff Frost <[email-masked]>
Date: Mon, 9 Nov 2015 14:45:30 -0800

> On Nov 9, 2015, at 2:41 PM, Devrim Gündüz <[email-masked]> wrote:
> 

Can’t revert it because it’s all one big commit (at least not with my current level of git-fu), but I should be able to change them back today or tomorrow.

---

From: Jeff Frost <[email-masked]>
Date: Mon, 9 Nov 2015 22:29:50 -0800

> On Nov 9, 2015, at 2:45 PM, Jeff Frost <[email-masked]> wrote:
> 
> 

Ok, I think  got the 9.[012] versions properly reverted to repmgr 2.0.2.

It appears to build properly, but I don’t have an environment to test it on.