1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/scripts/cmirrord_init_red_hat.in

111 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

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