#! /bin/sh
# /etc/init.d/modules: loads the appropriate modules in `boot'.

PATH="/sbin:/bin:/usr/sbin:/usr/bin"

# See if we have any modules.
if [ \! -d /lib/modules/`uname -r` ]
then
	echo "WARNING: no modules present for this kernel"
	exit 0
fi

#
# If you want to re-calculate the dependencies everytime you boot
# remove the if from the following statement:
#
if [ \! -r /lib/modules/`uname -r`/modules.dep ]
then
	echo -n "Calculating module dependencies..."
	depmod -a > /dev/null
	echo "done."
fi

startkerneld=0;
# Loop over every line in /etc/modules.
echo -n 'Loading modules: '
(cat /etc/modules; echo) | # make sure there is a LF at the end
while read module args
do
	case "$module" in
		auto)	[ ${startkerneld} -eq 0 -a -x /sbin/kerneld ] && \
			echo && /etc/init.d/kerneld start && startkerneld=1;
			continue ;;
		noauto) continue ;;
		\#*|"") continue ;;
	esac
	echo -n "$module "
	modprobe $module $args
done

echo

#
# Just in case a sysadmin prefers generic symbolic links in
# /lib/modules/boot for boot time modules we will load these modules
#
if [ -n "`modprobe -l -t boot`" ]
then
        modprobe -a -t boot \*
fi
