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