2004-12-21 21:07:15 +03:00
#!/bin/bash
#
2005-01-12 01:00:36 +03:00
# chkconfig: 345 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
clustervgs=`$VGDISPLAY \`$VGS --noheadings -o name\` | awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'`
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
}
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
start
fi
2004-12-21 21:07:15 +03:00
rtrn=$?
;;
status)
status clvmd
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)"}
rtrn=0
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
;;
esac
exit $rtrn