public inbox for [email protected]  
help / color / mirror / Atom feed
From: Martín Marqués <[email protected]>
To: Jeff Frost <[email protected]>
Cc: Justin King <[email protected]>
Cc: [email protected]
Cc: Ian Barwick <[email protected]>
Subject: Re: repmgr.service
Date: Wed, 30 Dec 2015 18:27:27 -0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAL3i3zT1NXVTyO=jOSXTnj3Uch9T569-LMyehDrUYqn0X+g2=w@mail.gmail.com>
	<[email protected]>
	<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-pkg-yum>

El 22/12/15 a las 23:52, Jeff Frost escribió:
> Sorry for the slow reply on this.
> 
> We did make some changes recently, but it seems this was not one of them.
> 
> A patch would definitely speed us up and would be most welcome!
> 
> 

This is another patch I had pending for a long time which adds some
improvements to the old sysV init scripts.

I'll try to roll the spec file patch.

-- 
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


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


Attachments:

  [text/x-patch] 0001-Improvements-to-sysV-init-script-and-the-use-of-s-sy.patch (92.8K, 2-0001-Improvements-to-sysV-init-script-and-the-use-of-s-sy.patch)
  download | inline diff:
From e4d4b1695c0e04610edde5767a23bdd014b80066 Mon Sep 17 00:00:00 2001
From: Martin <[email protected]>
Date: Wed, 30 Dec 2015 18:22:27 -0300
Subject: [PATCH] Improvements to sysV init script and the use of s sysconfig
 file for extra options the DBA might want to use.

---
 rpm/redhat/9.0/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.0/repmgr/EL-5/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.0/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.0/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.1/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.1/repmgr/EL-5/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.1/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.1/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.2/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.2/repmgr/EL-5/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.2/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.2/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.2/repmgr/EL-7/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.2/repmgr/EL-7/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.2/repmgr/F-19/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.2/repmgr/F-19/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/EL-5/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/EL-7/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/EL-7/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/F-19/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/F-19/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/F-20/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/F-20/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/F-21/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/F-21/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/F-22/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/F-22/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.3/repmgr/F-23/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.3/repmgr/F-23/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.4/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.4/repmgr/EL-7/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/F-20/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/F-21/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/F-22/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.4/repmgr/F-23/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/EL-5/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/EL-5/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/EL-6/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/EL-6/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/EL-7/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/EL-7/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/F-20/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/F-20/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/F-21/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/F-21/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/F-22/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/F-22/repmgrd.sysconfig | 24 +++++++++++++++
 rpm/redhat/9.5/repmgr/F-23/repmgr.init       | 45 +++++++++++++++++++++++-----
 rpm/redhat/9.5/repmgr/F-23/repmgrd.sysconfig | 24 +++++++++++++++
 54 files changed, 1716 insertions(+), 210 deletions(-)
 create mode 100644 rpm/redhat/9.0/repmgr/EL-5/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.0/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.1/repmgr/EL-5/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.1/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.2/repmgr/EL-5/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.2/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.2/repmgr/EL-7/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.2/repmgr/F-19/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/EL-5/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/EL-7/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/F-19/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/F-20/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/F-21/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/F-22/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.3/repmgr/F-23/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.4/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/EL-5/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/EL-6/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/EL-7/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/F-20/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/F-21/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/F-22/repmgrd.sysconfig
 create mode 100644 rpm/redhat/9.5/repmgr/F-23/repmgrd.sysconfig

diff --git a/rpm/redhat/9.0/repmgr/EL-5/repmgr.init b/rpm/redhat/9.0/repmgr/EL-5/repmgr.init
index e00089b..5b5bc6f 100644
--- a/rpm/redhat/9.0/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.0/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.0.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.0/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.0.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.0/repmgr/EL-5/repmgrd.sysconfig b/rpm/redhat/9.0/repmgr/EL-5/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.0/repmgr/EL-5/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.0/repmgr/EL-6/repmgr.init b/rpm/redhat/9.0/repmgr/EL-6/repmgr.init
index e00089b..5b5bc6f 100644
--- a/rpm/redhat/9.0/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.0/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.0.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.0/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.0.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.0/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.0/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.0/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.1/repmgr/EL-5/repmgr.init b/rpm/redhat/9.1/repmgr/EL-5/repmgr.init
index c7c16ac..3e72255 100644
--- a/rpm/redhat/9.1/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.1/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.1.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.1/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.1.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.1/repmgr/EL-5/repmgrd.sysconfig b/rpm/redhat/9.1/repmgr/EL-5/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.1/repmgr/EL-5/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.1/repmgr/EL-6/repmgr.init b/rpm/redhat/9.1/repmgr/EL-6/repmgr.init
index c7c16ac..3e72255 100644
--- a/rpm/redhat/9.1/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.1/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.1.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.1/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.1.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.1/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.1/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.1/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.2/repmgr/EL-5/repmgr.init b/rpm/redhat/9.2/repmgr/EL-5/repmgr.init
index 91a89ef..7a8463e 100644
--- a/rpm/redhat/9.2/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.2/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.2.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.2/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.2.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.2/repmgr/EL-5/repmgrd.sysconfig b/rpm/redhat/9.2/repmgr/EL-5/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.2/repmgr/EL-5/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.2/repmgr/EL-6/repmgr.init b/rpm/redhat/9.2/repmgr/EL-6/repmgr.init
index 91a89ef..7a8463e 100644
--- a/rpm/redhat/9.2/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.2/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.2.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.2/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.2.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.2/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.2/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.2/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.2/repmgr/EL-7/repmgr.init b/rpm/redhat/9.2/repmgr/EL-7/repmgr.init
index 91a89ef..7a8463e 100644
--- a/rpm/redhat/9.2/repmgr/EL-7/repmgr.init
+++ b/rpm/redhat/9.2/repmgr/EL-7/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.2.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.2/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.2.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.2/repmgr/EL-7/repmgrd.sysconfig b/rpm/redhat/9.2/repmgr/EL-7/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.2/repmgr/EL-7/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.2/repmgr/F-19/repmgr.init b/rpm/redhat/9.2/repmgr/F-19/repmgr.init
index 91a89ef..7a8463e 100644
--- a/rpm/redhat/9.2/repmgr/F-19/repmgr.init
+++ b/rpm/redhat/9.2/repmgr/F-19/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.2.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.2/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.2.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.2/repmgr/F-19/repmgrd.sysconfig b/rpm/redhat/9.2/repmgr/F-19/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.2/repmgr/F-19/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/EL-5/repmgr.init b/rpm/redhat/9.3/repmgr/EL-5/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/EL-5/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/EL-5/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/EL-5/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/EL-6/repmgr.init b/rpm/redhat/9.3/repmgr/EL-6/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/EL-7/repmgr.init b/rpm/redhat/9.3/repmgr/EL-7/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/EL-7/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/EL-7/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/EL-7/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/EL-7/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/EL-7/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/F-19/repmgr.init b/rpm/redhat/9.3/repmgr/F-19/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/F-19/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/F-19/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/F-19/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/F-19/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/F-19/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/F-20/repmgr.init b/rpm/redhat/9.3/repmgr/F-20/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/F-20/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/F-20/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/F-20/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/F-20/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/F-20/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/F-21/repmgr.init b/rpm/redhat/9.3/repmgr/F-21/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/F-21/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/F-21/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/F-21/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/F-21/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/F-21/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/F-22/repmgr.init b/rpm/redhat/9.3/repmgr/F-22/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/F-22/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/F-22/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/F-22/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/F-22/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/F-22/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.3/repmgr/F-23/repmgr.init b/rpm/redhat/9.3/repmgr/F-23/repmgr.init
index e7b2237..3f9bf49 100644
--- a/rpm/redhat/9.3/repmgr/F-23/repmgr.init
+++ b/rpm/redhat/9.3/repmgr/F-23/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.3.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.3/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.3.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.3/repmgr/F-23/repmgrd.sysconfig b/rpm/redhat/9.3/repmgr/F-23/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.3/repmgr/F-23/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.4/repmgr/EL-5/repmgr.init b/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.4/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.4/repmgr/EL-7/repmgr.init b/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-7/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-20/repmgr.init b/rpm/redhat/9.4/repmgr/F-20/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/F-20/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-20/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-21/repmgr.init b/rpm/redhat/9.4/repmgr/F-21/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/F-21/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-21/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-22/repmgr.init b/rpm/redhat/9.4/repmgr/F-22/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/F-22/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-22/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.4/repmgr/F-23/repmgr.init b/rpm/redhat/9.4/repmgr/F-23/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/F-23/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/F-23/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.4.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         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 -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/EL-5/repmgr.init b/rpm/redhat/9.5/repmgr/EL-5/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/EL-5/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/EL-5/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/EL-5/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/EL-5/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/EL-5/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/EL-6/repmgr.init b/rpm/redhat/9.5/repmgr/EL-6/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/EL-6/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/EL-6/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/EL-6/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/EL-7/repmgr.init b/rpm/redhat/9.5/repmgr/EL-7/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/EL-7/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/EL-7/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/EL-7/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/EL-7/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/EL-7/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/F-20/repmgr.init b/rpm/redhat/9.5/repmgr/F-20/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/F-20/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/F-20/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/F-20/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/F-20/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/F-20/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/F-21/repmgr.init b/rpm/redhat/9.5/repmgr/F-21/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/F-21/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/F-21/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/F-21/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/F-21/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/F-21/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/F-22/repmgr.init b/rpm/redhat/9.5/repmgr/F-22/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/F-22/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/F-22/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/F-22/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/F-22/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/F-22/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
diff --git a/rpm/redhat/9.5/repmgr/F-23/repmgr.init b/rpm/redhat/9.5/repmgr/F-23/repmgr.init
index b52ce41..f9b402d 100644
--- a/rpm/redhat/9.5/repmgr/F-23/repmgr.init
+++ b/rpm/redhat/9.5/repmgr/F-23/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
 prog=repmgrd
 pidfile=/var/run/repmgr/repmgrd-9.5.pid
 lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
 REPMGRDCONF=/etc/repmgr/9.5/repmgr.conf
 REPMGRDLOG=/var/log/repmgr/repmgrd-9.5.log
 
 # Get config.
 . /etc/sysconfig/network
 
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+    [Yy]*)
+	break
+	;;
+    *)
+	exit 0
+	;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+    echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+    exit 0
+fi
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 6
 start(){
         [ -x $exec ] || exit 5
-        [ -f "$REPMGRDCONF" ] || exit 6
+        [ -f "${REPMGRDCONF}" ] || exit 6
         echo -n "Starting $prog: "
 
         # Make sure startup-time log file is valid
-        if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+        if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
         then
-                touch "$REPMGRDLOG" || exit 1
-                chown $user: "$REPMGRDLOG"
-                chmod go-rwx "$REPMGRDLOG"
-                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+                touch "${REPMGRDLOG}" || exit 1
+                chown $user: "${REPMGRDLOG}"
+                chmod go-rwx "${REPMGRDLOG}"
+                [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
         fi
 
         mkdir -p $(dirname $pidfile)
         chown $user: $(dirname $pidfile)
 
-	su -l $user -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+	${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+	sleep 2
         retval=$?
 	[ $retval -eq 0 ] && success 
         echo
diff --git a/rpm/redhat/9.5/repmgr/F-23/repmgrd.sysconfig b/rpm/redhat/9.5/repmgr/F-23/repmgrd.sysconfig
new file mode 100644
index 0000000..e9c5aa9
--- /dev/null
+++ b/rpm/redhat/9.5/repmgr/F-23/repmgrd.sysconfig
@@ -0,0 +1,24 @@
+# default settings for repmgrd. This file is source by /bin/sh from
+# /etc/init.d/repmgrd
+
+# disable repmgrd by default so it won't get started upon installation
+# valid values: yes/no
+REPMGRD_ENABLED=no
+
+# Repmgr conf file
+REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
+
+# Options for repmgrd (required)
+#REPMGRD_OPTS="--verbose -d "
+
+# User to run repmgrd as
+#REPMGRD_USER=postgres
+
+# repmgrd binary
+#REPMGRD_BIN=/usr/bin/repmgrd
+
+# pid file
+#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
+
+# log file
+#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
-- 
2.5.0



view thread (16+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: repmgr.service
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox