summaryrefslogtreecommitdiffstats
path: root/scripts/lvm2_monitoring_init_rhel4
blob: aded8d4022190bf34e7f11a409ccabbc7db9e83e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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"
WARN=1

start()
{
	ret=0
	# TODO do we want to separate out already active groups only?
	VGS=`vgs --noheadings -o name --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
	for vg in $VGS
	do
	    action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --config 'log{command_names=0 prefix="  "}' $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
	VGS=`vgs --noheadings -o name --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
	for vg in $VGS
	do
	    action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
	done
	return $ret
}

result=1

# See how we were called.
case "$1" in
  start)
	start
	result=$?
	;;

  force-stop)
	WARN=0
	stop
	result=$?
	;;

  stop)
	test "$runlevel" = "0" && WARN=0
	test "$runlevel" = "6" && WARN=0
	stop
	result=$?
	;;

  restart)
	WARN=0
	if stop
	then
		start
	fi 
	result=$?
	;;

  status)
	# TODO anyone with an idea how to dump monitored volumes?
	;;

  *)
	echo $"Usage: $0 {start|stop|restart|status|force-stop}"
	;;
esac

exit $result