#!/bin/sh
#
# Module adapted system startup script.
#
# Written by Bjorn Ekwall <bj0rn@blox.se> with ideas
# from Markus Gutschke <gutschk@uni-muenster.de>
#
#
# This is how the basic system startup mostly looks like.
# Add to, and tune, this script to fit your environment.
#

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

# enable swapping
/sbin/swapon -a

# Start update.
/sbin/update &

#
# Now, start kerneld as soon as possible, so that any disk
# driver modules can be loaded "automagically"
if [ -x /sbin/kerneld ]
then
	/sbin/kerneld
fi

#
# Here one normally puts a fsck of all filesystems in /etc/fstab
#
/sbin/fsck -A -a
#
# Add some error handling code here, in case fsck failed!!!
#

#
# If everything went well, we remount the root filesystem read/write
#
echo "Re-mounting root file system read-write"
/sbin/mount -w -n -o remount /

#
# Then do some standard clean-up:
#
rm -f /etc/mtab~ /etc/fastboot /etc/nologin
cat /dev/null > /var/adm/utmp
# You might need this:
#cat /dev/null > /etc/mtab

# The code from here, down to "#=========" can be put in a separate script
#
# Create a generic link to the modules for the current kernel
#
# You can have generic symbolic links in /lib/modules/boot
# if you create links to: "../current/subsystem/module.o"
#
ln -snf /lib/modules/`uname -r` /lib/modules/current
# If you have an old "ln", replace the above line with:
#	rm -f /lib/modules/current
#	ln -sf /lib/modules/`uname -r` /lib/modules/current

if [ \! -r /lib/modules/current/modules.dep ]
then
	echo "Creating module dependencies"
	/sbin/depmod -a
fi

#
# Load the boot modules
#
if [ -x /sbin/kerneld ]
then
	if find /lib/modules/boot -type f -o type l > /dev/null 2>&1
	then
		echo "Loading boot-time modules"
		/sbin/modprobe -a -t boot \*
	fi
else
	echo "Loading modules"
	/sbin/modprobe -a \*
fi

#
# If you have any extra kerneld-type daemons, start them here
#
if [ -x /sbin/kdsound ]
then
	echo "Starting sound daemon"
	/sbin/kdsound &
fi
#=========

#
# Mount all file systems named in /etc/fstab (except NFS)
#
/sbin/mount -avt nonfs

#
# Continue with whatever currently seems to be the "Right Thing"...
#
