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