summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-fs/lvm2/files/clvmd.rc')
-rwxr-xr-xsys-fs/lvm2/files/clvmd.rc148
1 files changed, 148 insertions, 0 deletions
diff --git a/sys-fs/lvm2/files/clvmd.rc b/sys-fs/lvm2/files/clvmd.rc
new file mode 100755
index 000000000000..08bea5c91e38
--- /dev/null
+++ b/sys-fs/lvm2/files/clvmd.rc
@@ -0,0 +1,148 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/lvm2/files/clvmd.rc,v 1.1 2006/02/01 00:10:01 rocket Exp $
+
+depend() {
+ use dns logger
+ use net
+ need cluster-manager cluster-locking-manager fenced
+}
+
+exefile=/sbin/clvmd
+
+load_modules() {
+ local module modules
+ modules=$1
+
+ for module in ${modules}; do
+ ebegin "Loading ${module} kernel module"
+ modprobe ${module}
+ eend $? "Failed to load ${module} kernel module"
+ done
+}
+
+unload_modules() {
+ local module modules
+ modules=$1
+
+ for module in ${modules}; do
+ ebegin "Unloading ${module} kernel module"
+ modprobe -r ${module}
+ eend $? "Failed to unload ${module} kernel module"
+ done
+}
+
+umount_gfs_filesystems() {
+ local sig retry
+ local remaining="$(awk '$3 == "gfs" { print $2 }' /proc/mounts | sort -r)"
+
+ if [ -n "${remaining}" ]
+ then
+ sig=
+ retry=3
+ while [ -n "${remaining}" -a "${retry}" -gt 0 ]
+ do
+ if [ "${retry}" -lt 3 ]
+ then
+ ebegin "Unmounting GFS filesystems (retry)"
+ umount ${remaining} &>/dev/null
+ eend $? "Failed to unmount GFS filesystems this retry"
+ else
+ ebegin "Unmounting GFS filesystems"
+ umount ${remaining} &>/dev/null
+ eend $? "Failed to unmount GFS filesystems"
+ fi
+ remaining="$(awk '$3 == "gfs" { print $2 }' /proc/mounts | sort -r)"
+ [ -z "${remaining}" ] && break
+ /bin/fuser -k -m ${sig} ${remaining} &>/dev/null
+ sleep 5
+ retry=$((${retry} -1))
+ sig=-9
+ done
+ fi
+}
+
+
+
+start() {
+
+ local module=$(awk '$1 == "dm_mod" { print $1 }' /proc/modules)
+ if [ -z "${module}" ]; then
+ load_modules dm-mod
+ sleep 1s
+ fi
+
+ ebegin "Scanning LVM volumes"
+ /sbin/vgscan &>/dev/null
+ eend $?
+
+ if [ "$?" -eq 0 ] && [ -x /sbin/vgchange ] && [ -f /etc/lvmtab -o -d /etc/lvm ]
+ then
+ ebegin "Setting up the Logical Volume Manager"
+ /sbin/vgchange -aly >/dev/null
+ eend $? "Failed to setup the LVM"
+
+ if [ "$?" -eq 0 ]; then
+ ebegin "Starting clvmd"
+ start-stop-daemon --start --quiet --exec ${exefile}
+ eend $?
+ fi
+ fi
+
+}
+
+stop() {
+
+ # umount GFS filesystems
+ umount_gfs_filesystems
+
+ einfo "Shutting down the Logical Volume Manager"
+
+ LOGICAL_VOLUMES=`lvdisplay |grep "LV Name"|awk '{print $3}'|sort|xargs echo`
+ VOLUME_GROUPS=`vgdisplay |grep "VG Name"|awk '{print $3}'|sort|xargs echo`
+ for x in ${LOGICAL_VOLUMES}
+ do
+ LV_IS_ACTIVE=`lvdisplay ${x}|grep "# open"|awk '{print $3}'`
+ if [ "${LV_IS_ACTIVE}" = 0 ]
+ then
+ ebegin " Shutting Down logical volume: ${x} "
+ lvchange -an --ignorelockingfailure -P ${x} >/dev/null
+ eend $?
+ fi
+ done
+
+ for x in ${VOLUME_GROUPS}
+ do
+ VG_HAS_ACTIVE_LV=`vgdisplay ${x}|grep "Open LV"|awk '{print $3}'|xargs echo`
+ if [ "${VG_HAS_ACTIVE_LV}" = 0 ]
+ then
+ ebegin " Shutting Down volume group: ${x} "
+ vgchange -an --ignorelockingfailure -P ${x} >/dev/null
+ eend
+ fi
+ done
+
+ for x in ${LOGICAL_VOLUMES}
+ do
+ LV_IS_ACTIVE=`lvdisplay ${x}|grep "# open"|awk '{print $3}'`
+ if [ "${LV_IS_ACTIVE}" = 1 ]
+ then
+
+ ROOT_DEVICE=`mount|grep " / "|awk '{print $1}'`
+ if [ ! ${ROOT_DEVICE} = ${x} ]
+ then
+ ewarn " Unable to shutdown: ${x} "
+ fi
+ fi
+ done
+ einfo "Finished Shutting down the Logical Volume Manager"
+
+ ebegin "Stopping clvmd"
+ start-stop-daemon --stop --quiet --exec ${exefile}
+ eend $?
+
+ if [ "$?" -eq 0 ]; then
+ unload_modules dm-mod
+ fi
+}