Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / scripts / clvmd_init_red_hat.in
blobe7d3871ae92f44384ee6b466dabc3daa3faf5508
1 #!/bin/bash
3 # chkconfig: - 24 76
4 # description: Starts and stops clvmd
6 # For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
7 #
8 ### BEGIN INIT INFO
9 # Provides: clvmd
10 # Required-Start: $local_fs
11 # Required-Stop: $local_fs
12 # Default-Start:
13 # Default-Stop: 0 1 6
14 # Short-Description: Clustered LVM Daemon
15 ### END INIT INFO
17 . /etc/init.d/functions
19 DAEMON=clvmd
21 exec_prefix=@exec_prefix@
22 sbindir=@sbindir@
24 LVDISPLAY=${sbindir}/lvdisplay
25 VGCHANGE=${sbindir}/vgchange
26 VGSCAN=${sbindir}/vgscan
27 VGDISPLAY=${sbindir}/vgdisplay
28 VGS=${sbindir}/vgs
30 CLVMDOPTS="-T20"
32 [ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
34 [ -n "$CLVMD_CLUSTER_IFACE" ] && CLVMDOPTS="$CLVMDOPTS -I $CLVMD_CLUSTER_IFACE"
36 LOCK_FILE="/var/lock/subsys/$DAEMON"
38 start()
40 for rtrn in 0
42 if ! pidof $DAEMON > /dev/null
43 then
44 echo -n "Starting $DAEMON: "
45 daemon $DAEMON $CLVMDOPTS
46 rtrn=$?
47 echo
48 if [ $rtrn -ne 0 ]
49 then
50 break
52 fi
53 # refresh cache
54 $VGSCAN > /dev/null 2>&1
56 if [ -n "$LVM_VGS" ]
57 then
58 for vg in $LVM_VGS
60 action "Activating VG $vg:" $VGCHANGE -ayl $vg || rtrn=$?
61 done
62 else
63 action "Activating VGs:" $VGCHANGE -ayl || rtrn=$?
65 done
67 return $rtrn
70 stop()
72 for rtrn in 0
74 if [ -n "$LVM_VGS" ]
75 then
76 for vg in $LVM_VGS
78 action "Deactivating VG $vg:" $VGCHANGE -anl $vg || rtrn=$?
79 done
80 else
81 # Hack to only deactivate clustered volumes
82 clustervgs=`$VGDISPLAY 2> /dev/null | awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'`
83 for vg in $clustervgs; do
84 action "Deactivating VG $vg:" $VGCHANGE -anl $vg || rtrn=$?
85 done
88 [ $rtrn -ne 0 ] && break
90 echo -n "Stopping clvm:"
91 killproc $DAEMON -TERM
92 rtrn=$?
93 echo
94 done
96 return $rtrn
99 wait_for_finish()
101 count=0
103 while [ "$count" -le 10 -a -n "`pidof $DAEMON`" ]
105 sleep 1
106 count=$((count + 1))
107 done
109 if [ `pidof $DAEMON` ]
110 then
111 return 1
112 else
113 return 0
117 reload() {
118 $DAEMON -R
121 rh_status() {
122 status $DAEMON
125 rh_status_q() {
126 rh_status >/dev/null 2>&1
130 rtrn=1
132 # See how we were called.
133 case "$1" in
134 start)
135 start
136 rtrn=$?
137 [ $rtrn = 0 ] && touch $LOCK_FILE
140 stop)
141 stop
142 rtrn=$?
143 [ $rtrn = 0 ] && rm -f $LOCK_FILE
146 restart)
147 if stop
148 then
149 wait_for_finish
150 start
152 rtrn=$?
155 reload)
156 rh_status_q || exit 7
157 reload
160 status)
161 rh_status
162 rtrn=$?
163 vols=$( $LVDISPLAY -C --nohead 2> /dev/null | awk '($3 ~ /....a./) {print $1}' )
164 echo active volumes: ${vols:-"(none)"}
168 echo $"Usage: $0 {start|stop|restart|reload|status}"
170 esac
172 exit $rtrn