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


PATH="/sbin:/bin"

[ -f /proc/ksyms ] || exit 0
#
# XXX:
#
# Don't recalc module dependencies on TS-7000's since it unnecessarily wears
# down flash, takes a long time, and will cause all sorts of problems when the
# 'touch' command below is executed on a board without RTC.   Subsequent
# 'modprobe' commands complain loudly if /etc/conf.modules is newer than
# modules.dep which it will be if there is no RTC and the system thinks its
# 1970.  --JO
#
#[ -e /sbin/depmod ] || exit 0
#
#if touch /lib/modules/$(uname -r)/modules.dep 2>/dev/null; then
#	echo -n "Calculating module dependencies... "
#	depmod -a -q
#	echo "done."
#else
#	echo "Not calculating module dependencies: /lib/modules/$(uname -r) is read only."
#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
		\#*|"") 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

exit 0

