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