2007-01-25 02:43:27 +03:00
#!/bin/bash
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# This file is part of LVM2.
# It is required for the proper handling of failures of LVM2 mirror
# devices that were created using the -m option of lvcreate.
#
#
# chkconfig: 12345 02 99
# description: Starts and stops dmeventd monitoring for lvm2
#
### BEGIN INIT INFO
# Provides:
### END INIT INFO
. /etc/init.d/functions
VGCHANGE="/usr/sbin/vgchange"
2007-01-30 21:02:15 +03:00
WARN=1
2007-01-25 02:43:27 +03:00
start()
{
2007-01-30 21:02:15 +03:00
ret=0
2007-01-25 02:43:27 +03:00
# TODO do we want to separate out already active groups only?
2007-06-28 21:33:44 +04:00
VGS=`vgs --noheadings -o name 2> /dev/null`
2007-01-25 02:43:27 +03:00
for vg in $VGS
do
2007-03-16 20:15:36 +03:00
action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg || ret=$?
2007-01-25 02:43:27 +03:00
done
2007-01-30 21:02:15 +03:00
return $ret
2007-01-25 02:43:27 +03:00
}
stop()
{
2007-01-30 21:02:15 +03:00
ret=0
2007-01-25 02:43:27 +03:00
# TODO do we want to separate out already active groups only?
2007-01-30 21:02:15 +03:00
if test "$WARN" = "1"; then
echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
return 1
fi
2007-06-28 21:33:44 +04:00
VGS=`vgs --noheadings -o name 2> /dev/null`
2007-01-25 02:43:27 +03:00
for vg in $VGS
do
2007-03-16 20:15:36 +03:00
action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg || ret=$?
2007-01-25 02:43:27 +03:00
done
2007-01-30 21:02:15 +03:00
return $ret
2007-01-25 02:43:27 +03:00
}
2007-01-30 21:02:15 +03:00
result=1
2007-01-25 02:43:27 +03:00
# See how we were called.
case "$1" in
start)
start
2007-01-30 21:02:15 +03:00
result=$?
;;
force-stop)
WARN=0
stop
result=$?
2007-01-25 02:43:27 +03:00
;;
stop)
2007-01-30 21:02:15 +03:00
test "$runlevel" = "0" && WARN=0
test "$runlevel" = "6" && WARN=0
2007-01-25 02:43:27 +03:00
stop
2007-01-30 21:02:15 +03:00
result=$?
2007-01-25 02:43:27 +03:00
;;
restart)
2007-01-30 21:02:15 +03:00
WARN=0
2007-01-25 02:43:27 +03:00
if stop
then
start
fi
2007-01-30 21:02:15 +03:00
result=$?
2007-01-25 02:43:27 +03:00
;;
status)
# TODO anyone with an idea how to dump monitored volumes?
;;
*)
2007-01-30 21:02:15 +03:00
echo $"Usage: $0 {start|stop|restart|status|force-stop}"
2007-01-25 02:43:27 +03:00
;;
esac
2007-01-30 21:02:15 +03:00
exit $result