Subversion Repositories configs

Rev

Rev 34 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/bash
2
#
3
# Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
4
#
5
# This copyrighted material is made available to anyone wishing to use,
6
# modify, copy, or redistribute it subject to the terms and conditions
7
# of the GNU General Public License v.2.
8
#
9
# You should have received a copy of the GNU General Public License
10
# along with this program; if not, write to the Free Software Foundation,
58 - 11
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4 - 12
#
13
# This file is part of LVM2.
14
# It is required for the proper handling of failures of LVM2 mirror
15
# devices that were created using the -m option of lvcreate.
16
#
17
#
18
# chkconfig: 12345 02 99
19
# description: Starts and stops dmeventd monitoring for lvm2
20
#
21
# For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
22
#
23
### BEGIN INIT INFO
24
# Provides: lvm2-monitor
25
# Required-Start: $local_fs
26
# Required-Stop: $local_fs
27
# Default-Start: 1 2 3 4 5
28
# Default-Stop: 0 6
29
# Short-Description: Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
30
### END INIT INFO
31
 
32
. /etc/init.d/functions
33
 
34
DAEMON=lvm2-monitor
34 - 35
DMEVENTD_DAEMON=dmeventd
4 - 36
 
37
exec_prefix=
38
sbindir=/sbin
39
 
40
VGCHANGE=${sbindir}/vgchange
41
VGS=${sbindir}/vgs
34 - 42
LVS=${sbindir}/lvs
4 - 43
 
44
LOCK_FILE="/var/lock/subsys/$DAEMON"
34 - 45
PID_FILE="/var/run/dmeventd.pid"
4 - 46
 
47
WARN=1
48
export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
49
 
34 - 50
rh_status() {
51
	status -p $PID_FILE $DMEVENTD_DAEMON
52
}
53
 
54
rh_status_q() {
55
	rh_status >/dev/null 2>&1
56
}
4 - 57
start()
58
{
59
	ret=0
60
	# TODO do we want to separate out already active groups only?
9 - 61
	VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
4 - 62
	for vg in $VGSLIST
63
	do
9 - 64
	    action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
4 - 65
	done
66
 
67
	return $ret
68
}
69
 
70
 
71
stop()
72
{
73
	ret=0
74
	# TODO do we want to separate out already active groups only?
75
	if test "$WARN" = "1"; then
76
	   echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
77
	   return 1
78
	fi
9 - 79
	VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
4 - 80
	for vg in $VGSLIST
81
	do
9 - 82
	    action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
4 - 83
	done
84
	return $ret
85
}
86
 
87
rtrn=1
88
 
89
# See how we were called.
90
case "$1" in
91
  start)
34 - 92
	rh_status_q && exit 0
4 - 93
	start
94
	rtrn=$?
95
	[ $rtrn = 0 ] && touch $LOCK_FILE
96
	;;
97
 
98
  force-stop)
34 - 99
	rh_status_q || exit 0
4 - 100
	WARN=0
101
	stop
102
	rtrn=$?
103
	[ $rtrn = 0 ] && rm -f $LOCK_FILE
104
	;;
105
 
106
  stop)
34 - 107
	rh_status_q || exit 0
4 - 108
	test "$runlevel" = "0" && WARN=0
109
	test "$runlevel" = "6" && WARN=0
110
	stop
111
	rtrn=$?
112
	[ $rtrn = 0 ] && rm -f $LOCK_FILE
113
	;;
114
 
115
  restart)
116
	WARN=0
117
	if stop
118
	then
119
		start
120
	fi
121
	rtrn=$?
122
	;;
123
 
124
  status)
34 - 125
	rh_status
126
	rtrn=$?
127
	[ $rtrn = 0 ] && $LVS -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
4 - 128
	;;
129
 
130
  *)
131
	echo $"Usage: $0 {start|stop|restart|status|force-stop}"
132
	;;
133
esac
134
 
135
exit $rtrn