mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 08:56:29 +00:00
Updated RHEL files.
This commit is contained in:
@@ -1,89 +1,114 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# repmgrd Start up the repmgrd daemon
|
# chkconfig: - 75 16
|
||||||
# repmrgd (replication manager daemon)
|
# description: Enable repmgrd replication management and monitoring daemon for PostgreSQL
|
||||||
#
|
# processname: repmgrd
|
||||||
# chkconfig: - 75 16
|
# pidfile="/var/run/${NAME}.pid"
|
||||||
# description: repmgrd is the repliation manager daemon \
|
|
||||||
# The repmgrd replication management and monitoring daemon for PostgreSQL.
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: repmgrd
|
|
||||||
# Required-Start: $local_fs $remote_fs $network $syslog postgresql
|
|
||||||
# Required-Stop: $local_fs $remote_fs $network $syslog postgresql
|
|
||||||
# Should-Start: $syslog postgresql-9.3
|
|
||||||
# Should-Stop: $syslog postgresql-9.3
|
|
||||||
# Short-Description: start and stop repmrgd
|
|
||||||
# Description: Enable repmgrd replication management and monitoring daemon for PostgreSQL
|
|
||||||
# this is used to monitor a postgresql cluster.
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/init.d/functions
|
INITD=/etc/rc.d/init.d
|
||||||
|
. $INITD/functions
|
||||||
|
|
||||||
# Source networking configuration.
|
# Get function listing for cross-distribution logic.
|
||||||
|
TYPESET=`typeset -f|grep "declare"`
|
||||||
|
|
||||||
|
# Get network config.
|
||||||
. /etc/sysconfig/network
|
. /etc/sysconfig/network
|
||||||
|
|
||||||
prog=repmgrd
|
DESC="PostgreSQL replication management and monitoring daemon"
|
||||||
REPMGRD_ENABLED=yes
|
NAME=repmgrd
|
||||||
|
|
||||||
|
REPMGRD_ENABLED=no
|
||||||
REPMGRD_OPTS=
|
REPMGRD_OPTS=
|
||||||
REPMGRD_USER=postgres
|
REPMGRD_USER=postgres
|
||||||
DAEMONIZE="-d"
|
REPMGRD_BIN=/usr/pgsql-9.3/bin/repmgrd
|
||||||
|
REPMGRD_PIDFILE=/var/run/repmgrd.pid
|
||||||
|
REPMGRD_LOCK=/var/lock/subsys/${NAME}
|
||||||
|
REPMGRD_LOG=/var/lib/pgsql/9.3/data/pg_log/repmgrd.log
|
||||||
|
|
||||||
# pull in sysconfig settings
|
# Read configuration variable file if it is present
|
||||||
[ -f /etc/sysconfig/repmgrd ] && . /etc/sysconfig/repmgrd
|
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
|
||||||
|
|
||||||
LOCKFILE=/var/lock/subsys/$prog
|
# For SELinux we need to use 'runuser' not 'su'
|
||||||
RETVAL=0
|
if [ -x /sbin/runuser ]
|
||||||
|
then
|
||||||
|
SU=runuser
|
||||||
|
else
|
||||||
|
SU=su
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -x $REPMGRD_BIN || exit 0
|
||||||
|
|
||||||
case "$REPMGRD_ENABLED" in
|
case "$REPMGRD_ENABLED" in
|
||||||
[Yy]*)
|
[Yy]*)
|
||||||
#nothing to do here
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 2
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$REPMGRD_OPTS" ]
|
if [ -z "${REPMGRD_OPTS}" ]
|
||||||
then
|
then
|
||||||
echo "Not starting $prog, REPMGRD_OPTS not set in /etc/sysconfig/$prog"
|
echo "Not starting ${NAME}, REPMGRD_OPTS not set in /etc/sysconfig/${NAME}"
|
||||||
exit 2
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start() {
|
start()
|
||||||
[ "$EUID" != "0" ] && exit 4
|
{
|
||||||
[ "$NETWORKING" = "no" ] && exit 1
|
REPMGRD_START=$"Starting ${NAME} service: "
|
||||||
|
|
||||||
# Start daemons.
|
# Make sure startup-time log file is valid
|
||||||
echo -n $"Starting $prog: "
|
if [ ! -e "${REPMGRD_LOG}" -a ! -h "${REPMGRD_LOG}" ]
|
||||||
daemon --user $REPMGRD_USER $prog $DAEMONIZE $REPMGRD_OPTS
|
then
|
||||||
RETVAL=$?
|
touch "${REPMGRD_LOG}" || exit 1
|
||||||
|
chown ${REPMGRD_USER}:postgres "${REPMGRD_LOG}"
|
||||||
|
chmod go-rwx "${REPMGRD_LOG}"
|
||||||
|
[ -x /sbin/restorecon ] && /sbin/restorecon "${REPMGRD_LOG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "${REPMGRD_START}"
|
||||||
|
$SU -l $REPMGRD_USER -c "${REPMGRD_BIN} ${REPMGRD_OPTS} -p ${REPMGRD_PIDFILE} &" >> "${REPMGRD_LOG}" 2>&1 < /dev/null
|
||||||
|
sleep 2
|
||||||
|
pid=`head -n 1 "${REPMGRD_PIDFILE}" 2>/dev/null`
|
||||||
|
if [ "x${pid}" != "x" ]
|
||||||
|
then
|
||||||
|
success "${REPMGRD_START}"
|
||||||
|
touch "${REPMGRD_LOCK}"
|
||||||
|
echo $pid > "${REPMGRD_PIDFILE}"
|
||||||
echo
|
echo
|
||||||
[ $RETVAL -eq 0 ] && touch $LOCKFILE
|
else
|
||||||
return $RETVAL
|
failure "${REPMGRD_START}"
|
||||||
|
echo
|
||||||
|
script_result=1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop()
|
||||||
[ "$EUID" != "0" ] && exit 4
|
{
|
||||||
echo -n $"Shutting down $prog: "
|
echo -n $"Stopping ${NAME} service: "
|
||||||
killproc $prog
|
if [ -e "${REPMGRD_LOCK}" ]
|
||||||
RETVAL=$?
|
then
|
||||||
echo
|
killproc ${NAME}
|
||||||
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
|
ret=$?
|
||||||
return $RETVAL
|
if [ $ret -eq 0 ]
|
||||||
}
|
then
|
||||||
status() {
|
echo_success
|
||||||
if [ -f "$LOCKFILE" ]; then
|
rm -f "${REPMGRD_PIDFILE}"
|
||||||
echo "$prog is running"
|
rm -f "${REPMGRD_LOCK}"
|
||||||
else
|
else
|
||||||
RETVAL=3
|
echo_failure
|
||||||
echo "$prog is stopped"
|
script_result=1
|
||||||
fi
|
fi
|
||||||
return $RETVAL
|
else
|
||||||
|
# not running; per LSB standards this is "ok"
|
||||||
|
echo_success
|
||||||
|
fi
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# See how we were called.
|
# See how we were called.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
@@ -93,22 +118,16 @@ case "$1" in
|
|||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status $prog
|
status -p $REPMGRD_PIDFILE $NAME
|
||||||
|
script_result=$?
|
||||||
;;
|
;;
|
||||||
restart|force-reload)
|
restart)
|
||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
;;
|
|
||||||
try-restart|condrestart)
|
|
||||||
if status $prog > /dev/null; then
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
exit 3
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
|
echo $"Usage: $0 {start|stop|status|restart}"
|
||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
exit $script_result
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
#default sysconfig file for repmrgd
|
# default settings for repmgrd. This file is source by /bin/sh from
|
||||||
#custom overrides can be placed here
|
# /etc/init.d/repmgrd
|
||||||
|
|
||||||
REPMGRD_OPTS="-f /etc/repmgr/repmgr.conf"
|
# disable repmgrd by default so it won't get started upon installation
|
||||||
|
# valid values: yes/no
|
||||||
|
REPMGRD_ENABLED=no
|
||||||
|
|
||||||
|
# Options for repmgrd (required)
|
||||||
|
#REPMGRD_OPTS="--verbose -d -f /var/lib/pgsql/repmgr/repmgr.conf"
|
||||||
|
|
||||||
|
# User to run repmgrd as
|
||||||
|
#REPMGRD_USER=postgres
|
||||||
|
|
||||||
|
# repmgrd binary
|
||||||
|
#REPMGRD_BIN=/usr/bin/repmgr
|
||||||
|
|
||||||
|
# pid file
|
||||||
|
#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
|
||||||
|
|
||||||
|
# log file
|
||||||
|
#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
|
||||||
|
|||||||
Reference in New Issue
Block a user