From e4d4b1695c0e04610edde5767a23bdd014b80066 Mon Sep 17 00:00:00 2001
From: Martin <martin@2ndquadrant.com>
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

