#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/dlm/files/dlm.rc,v 1.3 2005/03/25 02:14:00 xmerlin Exp $

depend() {
	use net
	need cman
	provide cluster-locking-manager
}

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
}

start() {
	ebegin "Loading dlm module"
	load_modules dlm
	eend $?
}

stop() {

	local modules

	if [ -d /proc/cluster/lock_dlm ]; then
		modules="${modules} lock_dlm"
	fi
	if [ -d /proc/cluster/config/dlm ]; then
		modules="${modules} dlm"
	fi
	unload_modules ${modules}

}

