]> sourceware.org Git - lvm2.git/blob - scripts/lvm2_monitoring_init_red_hat.in
95e4125a09d407fa5f025f4891e1e408f913c286
[lvm2.git] / scripts / lvm2_monitoring_init_red_hat.in
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
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
35 DMEVENTD_DAEMON=dmeventd
36
37 sbindir=@SBINDIR@
38
39 VGCHANGE="$sbindir/vgchange"
40 VGS="$sbindir/vgs"
41 LVS="$sbindir/lvs"
42
43 LOCK_FILE="@DEFAULT_SYS_LOCK_DIR@/subsys/$DAEMON"
44 PID_FILE="@DMEVENTD_PIDFILE@"
45
46 WARN=1
47 export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
48
49 rh_status() {
50 status -p "$PID_FILE" "$DMEVENTD_DAEMON"
51 }
52
53 rh_status_q() {
54 rh_status >/dev/null 2>&1
55 }
56 start()
57 {
58 ret=0
59 # TODO do we want to separate out already active groups only?
60 VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
61 for vg in $VGSLIST
62 do
63 action "Starting monitoring for VG $vg:" "$VGCHANGE" --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
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
78 VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
79 for vg in $VGSLIST
80 do
81 action "Stopping monitoring for VG $vg:" "$VGCHANGE" --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
82 done
83 return $ret
84 }
85
86 rtrn=1
87
88 # See how we were called.
89 case "$1" in
90 start)
91 rh_status_q && exit 0
92 start
93 rtrn=$?
94 [ "$rtrn" = 0 ] && touch "$LOCK_FILE"
95 ;;
96
97 force-stop)
98 rh_status_q || exit 0
99 WARN=0
100 stop
101 rtrn=$?
102 [ "$rtrn" = 0 ] && rm -f "$LOCK_FILE"
103 ;;
104
105 stop)
106 rh_status_q || exit 0
107 test "$runlevel" = "0" && WARN=0
108 test "$runlevel" = "6" && WARN=0
109 stop
110 rtrn=$?
111 [ "$rtrn" = 0 ] && rm -f "$LOCK_FILE"
112 ;;
113
114 restart)
115 WARN=0
116 if stop
117 then
118 start
119 fi
120 rtrn=$?
121 ;;
122
123 status)
124 rh_status
125 rtrn=$?
126 [ "$rtrn" = 0 ] && "$LVS" -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
127 ;;
128
129 *)
130 echo $"Usage: $0 {start|stop|restart|status|force-stop}"
131 ;;
132 esac
133
134 exit $rtrn
This page took 0.050917 seconds and 6 git commands to generate.