]>
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, | |
fcbef05a | 11 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
595eaf92 AK |
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 |
57e9e76d | 35 | DMEVENTD_DAEMON=dmeventd |
595eaf92 | 36 | |
34618c2d | 37 | sbindir=@SBINDIR@ |
595eaf92 | 38 | |
34618c2d ZK |
39 | VGCHANGE="$sbindir/vgchange" |
40 | VGS="$sbindir/vgs" | |
41 | LVS="$sbindir/lvs" | |
595eaf92 | 42 | |
34618c2d | 43 | LOCK_FILE="@DEFAULT_SYS_LOCK_DIR@/subsys/$DAEMON" |
e09f8a82 | 44 | PID_FILE="@DMEVENTD_PIDFILE@" |
595eaf92 AK |
45 | |
46 | WARN=1 | |
d183554c | 47 | export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1 |
595eaf92 | 48 | |
57e9e76d | 49 | rh_status() { |
35df4b10 | 50 | status -p "$PID_FILE" "$DMEVENTD_DAEMON" |
57e9e76d JC |
51 | } |
52 | ||
53 | rh_status_q() { | |
54 | rh_status >/dev/null 2>&1 | |
55 | } | |
595eaf92 AK |
56 | start() |
57 | { | |
58 | ret=0 | |
59 | # TODO do we want to separate out already active groups only? | |
f33a224e | 60 | VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null` |
595eaf92 AK |
61 | for vg in $VGSLIST |
62 | do | |
35df4b10 | 63 | action "Starting monitoring for VG $vg:" "$VGCHANGE" --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$? |
595eaf92 AK |
64 | done |
65 | ||
66 | return $ret | |
67 | } | |
68 | ||
69 | ||
70 | stop() | |
71 | { | |
72 | ret=0 | |
73 | # TODO do we want to separate out already active groups only? | |
74 | if test "$WARN" = "1"; then | |
75 | echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override." | |
76 | return 1 | |
77 | fi | |
f33a224e | 78 | VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null` |
595eaf92 AK |
79 | for vg in $VGSLIST |
80 | do | |
35df4b10 | 81 | action "Stopping monitoring for VG $vg:" "$VGCHANGE" --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$? |
595eaf92 AK |
82 | done |
83 | return $ret | |
84 | } | |
85 | ||
86 | rtrn=1 | |
87 | ||
88 | # See how we were called. | |
89 | case "$1" in | |
90 | start) | |
57e9e76d | 91 | rh_status_q && exit 0 |
595eaf92 AK |
92 | start |
93 | rtrn=$? | |
35df4b10 | 94 | [ "$rtrn" = 0 ] && touch "$LOCK_FILE" |
595eaf92 AK |
95 | ;; |
96 | ||
97 | force-stop) | |
57e9e76d | 98 | rh_status_q || exit 0 |
595eaf92 AK |
99 | WARN=0 |
100 | stop | |
101 | rtrn=$? | |
35df4b10 | 102 | [ "$rtrn" = 0 ] && rm -f "$LOCK_FILE" |
595eaf92 AK |
103 | ;; |
104 | ||
105 | stop) | |
57e9e76d | 106 | rh_status_q || exit 0 |
595eaf92 AK |
107 | test "$runlevel" = "0" && WARN=0 |
108 | test "$runlevel" = "6" && WARN=0 | |
109 | stop | |
110 | rtrn=$? | |
35df4b10 | 111 | [ "$rtrn" = 0 ] && rm -f "$LOCK_FILE" |
595eaf92 AK |
112 | ;; |
113 | ||
114 | restart) | |
115 | WARN=0 | |
116 | if stop | |
117 | then | |
118 | start | |
119 | fi | |
120 | rtrn=$? | |
121 | ;; | |
122 | ||
123 | status) | |
57e9e76d JC |
124 | rh_status |
125 | rtrn=$? | |
35df4b10 | 126 | [ "$rtrn" = 0 ] && "$LVS" -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor |
595eaf92 AK |
127 | ;; |
128 | ||
129 | *) | |
130 | echo $"Usage: $0 {start|stop|restart|status|force-stop}" | |
131 | ;; | |
132 | esac | |
133 | ||
134 | exit $rtrn |