2004-12-21 18:07:15 +00:00
#!/bin/bash
#
2006-11-01 18:25:26 +00:00
# chkconfig: - 24 76
2004-12-21 18:07:15 +00:00
# description: Starts and stops clvmd
#
#
### BEGIN INIT INFO
# Provides:
### END INIT INFO
. /etc/init.d/functions
2005-02-08 17:20:24 +00:00
LVDISPLAY="/usr/sbin/lvdisplay"
VGCHANGE="/usr/sbin/vgchange"
VGSCAN="/usr/sbin/vgscan"
2005-05-11 15:21:44 +00:00
VGDISPLAY="/usr/sbin/vgdisplay"
VGS="/usr/sbin/vgs"
2006-11-30 10:16:48 +00:00
CLVMDOPTS="-T20"
2005-02-08 17:20:24 +00:00
2004-12-21 18:07:15 +00:00
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
LOCK_FILE="/var/lock/subsys/clvmd"
start()
{
for rtrn in 0
do
if ! pidof clvmd > /dev/null
then
2005-05-10 20:14:33 +00:00
echo -n "Starting clvmd: "
2006-11-30 10:16:48 +00:00
daemon clvmd $CLVMDOPTS
2004-12-21 18:07:15 +00:00
rtrn=$?
2005-05-10 20:14:33 +00:00
echo
if [ $rtrn -ne 0 ]
2004-12-21 18:07:15 +00:00
then
break
fi
2005-05-10 20:14:33 +00:00
fi
2005-01-20 22:16:55 +00:00
# refresh cache
2005-02-08 17:20:24 +00:00
$VGSCAN > /dev/null 2>&1
2005-01-20 22:16:55 +00:00
2004-12-21 18:07:15 +00:00
if [ -n "$LVM_VGS" ]
then
for vg in $LVM_VGS
do
2007-03-16 17:15:36 +00:00
action "Activating VG $vg:" $VGCHANGE -ayl $vg || rtrn=$?
2004-12-21 18:07:15 +00:00
done
else
2007-03-16 17:15:36 +00:00
action "Activating VGs:" $VGCHANGE -ayl || rtrn=$?
2004-12-21 18:07:15 +00:00
fi
done
return $rtrn
}
stop()
{
for rtrn in 0
do
if [ -n "$LVM_VGS" ]
then
for vg in $LVM_VGS
do
2007-03-16 17:15:36 +00:00
action "Deactivating VG $vg:" $VGCHANGE -anl $vg || rtrn=$?
2004-12-21 18:07:15 +00:00
done
else
2005-05-11 15:21:44 +00:00
# Hack to only deactivate clustered volumes
2006-11-21 17:44:46 +00:00
clustervgs=`$VGDISPLAY 2> /dev/null | awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'`
2005-05-11 15:21:44 +00:00
for vg in $clustervgs; do
2007-03-16 17:15:36 +00:00
action "Deactivating VG $vg:" $VGCHANGE -anl $vg || rtrn=$?
2005-05-11 15:21:44 +00:00
done
2004-12-21 18:07:15 +00:00
fi
[ $rtrn -ne 0 ] && break
echo -n "Stopping clvm:"
2005-05-10 20:14:33 +00:00
killproc clvmd -TERM
rtrn=$?
echo
2004-12-21 18:07:15 +00:00
done
return $rtrn
}
2006-10-04 08:42:14 +00:00
wait_for_finish()
{
count=0
while [ "$count" -le 10 -a -n "`pidof clvmd`" ]
do
sleep 1
count=$((count + 1))
done
if [ `pidof clvmd` ]
then
return 1
else
return 0
fi
}
2004-12-21 18:07:15 +00:00
rtrn=1
# See how we were called.
case "$1" in
start)
start
rtrn=$?
[ $rtrn = 0 ] && touch $LOCK_FILE
;;
stop)
stop
rtrn=$?
[ $rtrn = 0 ] && rm -f $LOCK_FILE
;;
restart)
2005-05-10 20:14:33 +00:00
if stop
then
2006-10-04 08:42:14 +00:00
wait_for_finish
2005-05-10 20:14:33 +00:00
start
fi
2004-12-21 18:07:15 +00:00
rtrn=$?
;;
status)
status clvmd
2006-07-19 18:55:58 +00:00
rtrn=$?
2005-02-08 17:20:24 +00:00
vols=$( $LVDISPLAY -C --nohead 2> /dev/null | awk '($3 ~ /....a./) {print $1}' )
2004-12-21 18:07:15 +00:00
echo active volumes: ${vols:-"(none)"}
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
;;
esac
exit $rtrn