Home | History | Annotate | Line # | Download | only in scripts
      1  1.1  haad #!/bin/bash
      2  1.1  haad #
      3  1.1  haad # Copyright (C) 2007 Red Hat, Inc. All rights reserved.
      4  1.1  haad #
      5  1.1  haad # This copyrighted material is made available to anyone wishing to use,
      6  1.1  haad # modify, copy, or redistribute it subject to the terms and conditions
      7  1.1  haad # of the GNU General Public License v.2.
      8  1.1  haad #
      9  1.1  haad # You should have received a copy of the GNU General Public License
     10  1.1  haad # along with this program; if not, write to the Free Software Foundation,
     11  1.1  haad # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     12  1.1  haad #
     13  1.1  haad # This file is part of LVM2.
     14  1.1  haad # It is required for the proper handling of failures of LVM2 mirror
     15  1.1  haad # devices that were created using the -m option of lvcreate.
     16  1.1  haad #
     17  1.1  haad #
     18  1.1  haad # chkconfig: 12345 02 99
     19  1.1  haad # description: Starts and stops dmeventd monitoring for lvm2
     20  1.1  haad #	       
     21  1.1  haad ### BEGIN INIT INFO
     22  1.1  haad # Provides: 
     23  1.1  haad ### END INIT INFO
     24  1.1  haad 
     25  1.1  haad . /etc/init.d/functions
     26  1.1  haad 
     27  1.1  haad VGCHANGE="/usr/sbin/vgchange"
     28  1.1  haad WARN=1
     29  1.1  haad 
     30  1.1  haad start()
     31  1.1  haad {
     32  1.1  haad 	ret=0
     33  1.1  haad 	# TODO do we want to separate out already active groups only?
     34  1.1  haad 	VGS=`vgs --noheadings -o name 2> /dev/null`
     35  1.1  haad 	for vg in $VGS
     36  1.1  haad 	do
     37  1.1  haad 	    action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg || ret=$?
     38  1.1  haad 	done
     39  1.1  haad 
     40  1.1  haad 	return $ret
     41  1.1  haad }
     42  1.1  haad 
     43  1.1  haad 
     44  1.1  haad stop()
     45  1.1  haad {
     46  1.1  haad 	ret=0
     47  1.1  haad 	# TODO do we want to separate out already active groups only?
     48  1.1  haad 	if test "$WARN" = "1"; then
     49  1.1  haad 	   echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
     50  1.1  haad 	   return 1
     51  1.1  haad 	fi
     52  1.1  haad 	VGS=`vgs --noheadings -o name 2> /dev/null`
     53  1.1  haad 	for vg in $VGS
     54  1.1  haad 	do
     55  1.1  haad 	    action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg || ret=$?
     56  1.1  haad 	done
     57  1.1  haad 	return $ret
     58  1.1  haad }
     59  1.1  haad 
     60  1.1  haad result=1
     61  1.1  haad 
     62  1.1  haad # See how we were called.
     63  1.1  haad case "$1" in
     64  1.1  haad   start)
     65  1.1  haad 	start
     66  1.1  haad 	result=$?
     67  1.1  haad 	;;
     68  1.1  haad 
     69  1.1  haad   force-stop)
     70  1.1  haad 	WARN=0
     71  1.1  haad 	stop
     72  1.1  haad 	result=$?
     73  1.1  haad 	;;
     74  1.1  haad 
     75  1.1  haad   stop)
     76  1.1  haad 	test "$runlevel" = "0" && WARN=0
     77  1.1  haad 	test "$runlevel" = "6" && WARN=0
     78  1.1  haad 	stop
     79  1.1  haad 	result=$?
     80  1.1  haad 	;;
     81  1.1  haad 
     82  1.1  haad   restart)
     83  1.1  haad 	WARN=0
     84  1.1  haad 	if stop
     85  1.1  haad 	then
     86  1.1  haad 		start
     87  1.1  haad 	fi 
     88  1.1  haad 	result=$?
     89  1.1  haad 	;;
     90  1.1  haad 
     91  1.1  haad   status)
     92  1.1  haad 	# TODO anyone with an idea how to dump monitored volumes?
     93  1.1  haad 	;;
     94  1.1  haad 
     95  1.1  haad   *)
     96  1.1  haad 	echo $"Usage: $0 {start|stop|restart|status|force-stop}"
     97  1.1  haad 	;;
     98  1.1  haad esac
     99  1.1  haad 
    100  1.1  haad exit $result
    101