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


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

	echo -n "Calculating module dependencies... "
	depmod -a > /dev/null
	echo "done."

# First test if we have a kernel with kmod
if [ -f /proc/sys/kernel/modprobe ]; then
#	We have, so don't start kerneld
	startkerneld=1
else
	startkerneld=0;
fi

# 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

