#!/bin/bash # # This file 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 . /etc/init.d/functions DAEMON=lvm2-monitor VGCHANGE=/sbin/vgchange VGS=/sbin/vgs LOCK_FILE="/var/lock/subsys/$DAEMON" WARN=1 start() { ret=0 # TODO do we want to separate out already active groups only? VGSLIST=`$VGS --noheadings -o name 2> /dev/null` for vg in $VGSLIST do action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg || ret=$? done return $ret } stop() { ret=0 # TODO do we want to separate out already active groups only? if test "$WARN" = "1"; then echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override." return 1 fi VGSLIST=`$VGS --noheadings -o name 2> /dev/null` for vg in $VGSLIST do action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg || ret=$? done return $ret } rtrn=1 # See how we were called. case "$1" in start) start rtrn=$? [ $rtrn = 0 ] && touch $LOCK_FILE ;; force-stop) WARN=0 stop rtrn=$? [ $rtrn = 0 ] && rm -f $LOCK_FILE ;; stop) test "$runlevel" = "0" && WARN=0 test "$runlevel" = "6" && WARN=0 stop rtrn=$? [ $rtrn = 0 ] && rm -f $LOCK_FILE ;; restart) WARN=0 if stop then start fi rtrn=$? ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; condreload) if [ -e "$LOCKFILE" ]; then reload fi ;; status) # TODO anyone with an idea how to dump monitored volumes? ;; *) echo $"Usage: $0 {start|stop|restart|status|force-stop|condstop|condrestart|condreload}" ;; esac exit $rtrn