]>
Commit | Line | Data |
---|---|---|
595eaf92 AK |
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, | |
11 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 | |
0c29b5cb | 24 | # Provides: lvm2-monitor |
595eaf92 AK |
25 | # Required-Start: $local_fs |
26 | # Required-Stop: $local_fs | |
27 | # Default-Start: 1 2 3 4 5 | |
28 | # Default-Stop: 0 6 | |
7a8fa6aa | 29 | # Short-Description: Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling |
595eaf92 AK |
30 | ### END INIT INFO |
31 | ||
32 | . /etc/init.d/functions | |
33 | ||
81182ac0 | 34 | DAEMON=lvm2-monitor |
595eaf92 AK |
35 | |
36 | exec_prefix=@exec_prefix@ | |
37 | sbindir=@sbindir@ | |
38 | ||
39 | VGCHANGE=${sbindir}/vgchange | |
40 | VGS=${sbindir}/vgs | |
41 | ||
42 | LOCK_FILE="/var/lock/subsys/$DAEMON" | |
43 | ||
44 | WARN=1 | |
d183554c | 45 | export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1 |
595eaf92 AK |
46 | |
47 | start() | |
48 | { | |
49 | ret=0 | |
50 | # TODO do we want to separate out already active groups only? | |
0644371f | 51 | VGSLIST=`$VGS --noheadings -o name --config 'log{command_names=0 prefix=" "}' 2> /dev/null` |
595eaf92 AK |
52 | for vg in $VGSLIST |
53 | do | |
32e53e50 | 54 | action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --config 'log{command_names=0 prefix=" "}' $vg || ret=$? |
595eaf92 AK |
55 | done |
56 | ||
57 | return $ret | |
58 | } | |
59 | ||
60 | ||
61 | stop() | |
62 | { | |
63 | ret=0 | |
64 | # TODO do we want to separate out already active groups only? | |
65 | if test "$WARN" = "1"; then | |
66 | echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override." | |
67 | return 1 | |
68 | fi | |
0644371f | 69 | VGSLIST=`$VGS --noheadings -o name --config 'log{command_names=0 prefix=" "}' 2> /dev/null` |
595eaf92 AK |
70 | for vg in $VGSLIST |
71 | do | |
32e53e50 | 72 | action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --config 'log{command_names=0 prefix=" "}' $vg || ret=$? |
595eaf92 AK |
73 | done |
74 | return $ret | |
75 | } | |
76 | ||
77 | rtrn=1 | |
78 | ||
79 | # See how we were called. | |
80 | case "$1" in | |
81 | start) | |
82 | start | |
83 | rtrn=$? | |
84 | [ $rtrn = 0 ] && touch $LOCK_FILE | |
85 | ;; | |
86 | ||
87 | force-stop) | |
88 | WARN=0 | |
89 | stop | |
90 | rtrn=$? | |
91 | [ $rtrn = 0 ] && rm -f $LOCK_FILE | |
92 | ;; | |
93 | ||
94 | stop) | |
95 | test "$runlevel" = "0" && WARN=0 | |
96 | test "$runlevel" = "6" && WARN=0 | |
97 | stop | |
98 | rtrn=$? | |
99 | [ $rtrn = 0 ] && rm -f $LOCK_FILE | |
100 | ;; | |
101 | ||
102 | restart) | |
103 | WARN=0 | |
104 | if stop | |
105 | then | |
106 | start | |
107 | fi | |
108 | rtrn=$? | |
109 | ;; | |
110 | ||
111 | status) | |
112 | # TODO anyone with an idea how to dump monitored volumes? | |
113 | ;; | |
114 | ||
115 | *) | |
116 | echo $"Usage: $0 {start|stop|restart|status|force-stop}" | |
117 | ;; | |
118 | esac | |
119 | ||
120 | exit $rtrn |