2010-01-15 20:47:52 +00:00
#!/bin/bash
#
# chkconfig: - 22 78
2010-01-19 02:04:33 +00:00
# description: Starts and stops cmirrord
2013-06-07 14:07:56 +02:00
# pidfile: @CMIRRORD_PIDFILE@
2010-01-15 20:47:52 +00:00
#
2010-01-19 02:04:33 +00:00
# For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
2010-01-15 20:47:52 +00:00
#
### BEGIN INIT INFO
# Provides: cmirrord
2010-01-19 02:04:33 +00:00
# Required-Start: $network $time $local_fs
# Required-Stop: $network $time $local_fs
2010-01-15 20:47:52 +00:00
# Short-Description: Starts and stops cmirrord
2010-01-19 02:04:33 +00:00
# Description: Starts and stops the cluster mirror log daemon
2010-01-15 20:47:52 +00:00
### END INIT INFO
. /etc/init.d/functions
2010-01-19 02:04:33 +00:00
DAEMON=cmirrord
2017-10-25 17:08:00 +02:00
usrsbindir="@USRSBINDIR@"
LOCK_FILE="@DEFAULT_SYS_LOCK_DIR@/subsys/$DAEMON"
2010-01-15 20:47:52 +00:00
start()
{
2011-01-04 21:16:54 +00:00
rtrn=0
2017-10-25 17:02:31 +02:00
if ! pidof "$DAEMON" > /dev/null
then
2010-01-19 02:04:33 +00:00
echo -n "Starting $DAEMON: "
2017-10-25 17:08:00 +02:00
daemon "$usrsbindir/$DAEMON"
2010-01-19 02:04:33 +00:00
rtrn=$?
echo
2010-01-22 16:19:38 +00:00
fi
2010-01-15 20:47:52 +00:00
2010-01-19 02:04:33 +00:00
return $rtrn
}
stop()
{
echo -n "Stopping $DAEMON:"
2017-10-25 17:02:31 +02:00
killproc "$DAEMON" -TERM
2010-01-15 20:47:52 +00:00
rtrn=$?
2010-01-22 16:19:38 +00:00
echo
2010-01-15 21:48:03 +00:00
return $rtrn
2010-01-15 20:47:52 +00:00
}
2010-01-19 02:04:33 +00:00
wait_for_finish()
2010-01-15 20:47:52 +00:00
{
2010-01-19 02:04:33 +00:00
count=0
while [ "$count" -le 10 -a -n "`pidof $DAEMON`" ]
do
2010-01-15 21:48:03 +00:00
sleep 1
2010-01-19 02:04:33 +00:00
count=$((count + 1))
2010-01-15 20:47:52 +00:00
done
2017-10-25 17:02:31 +02:00
if [ "$(pidof "$DAEMON")" ]
2010-01-19 02:04:33 +00:00
then
2010-01-15 21:48:03 +00:00
return 1
2010-01-15 20:47:52 +00:00
else
2010-01-19 02:04:33 +00:00
return 0
2010-01-15 20:47:52 +00:00
fi
}
cmirror_status()
{
2017-10-25 17:02:31 +02:00
status "$DAEMON"
2010-01-15 20:47:52 +00:00
}
rtrn=1
# See how we were called.
case "$1" in
2010-01-15 21:48:03 +00:00
start)
start
rtrn=$?
2017-10-25 17:02:31 +02:00
[ "$rtrn" = 0 ] && touch "$LOCK_FILE"
2010-01-15 21:48:03 +00:00
;;
stop)
stop
rtrn=$?
2017-10-25 17:02:31 +02:00
[ "$rtrn" = 0 ] && rm -f "$LOCK_FILE"
2010-01-15 21:48:03 +00:00
;;
restart)
2010-01-19 02:04:33 +00:00
if stop
then
wait_for_finish
start
fi
2010-01-15 21:48:03 +00:00
rtrn=$?
;;
status)
cmirror_status
rtrn=$?
2017-10-25 17:02:31 +02:00
if [ "$rtrn" -eq 0 ]; then
2010-01-15 21:48:03 +00:00
echo "cmirror is running."
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
;;
2010-01-15 20:47:52 +00:00
esac
exit $rtrn