#!/bin/sh

module="seaio_driver"
module_name="SeaIO"
module_FIFO_name="SeaIO_FIFO"
device="dio"
device_FIFO="diod"
group="root"
mode="666"

# load the modules
#
if [ -f /etc/seaio.conf ] ; then
	. /etc/seaio.conf
	insmod ${module} $* ${seaio_options} || exit 1
else
	echo
	echo "ALERT:"
	echo "I've noticed you don't have an /etc/seaio.conf"
	echo "I will assume you are using modutils, and have set up the proper aliases in"
	echo "/etc/modules.conf (or /etc/conf.modules, depending on your version)"
	echo "You may, at your option, remove this annoying message from the seaio-load"
	echo "script, now that you know =)"
	echo
	modprobe ${module} || exit 1
fi

# remove stale node
rm -f /dev/${device}[0-3]
rm -f /dev/${device_FIFO}[0-3]

# create device special files using the dynamically
# assigned device major number. device minor numbers
# start at 0. If you need more than 4 devices then
# copy the lines below and increment the file name
# numbers and the device minor numbers.
major=`cat /proc/devices | awk "\\$2==\"$module_name\" {print \\$1}"`
major_FIFO=`cat /proc/devices | awk "\\$2==\"$module_FIFO_name\" {print \\$1}"`
mknod /dev/${device}0 c $major 0
mknod /dev/${device}1 c $major 1
mknod /dev/${device}2 c $major 2
mknod /dev/${device}3 c $major 3
# If you have enabled experimental interrupt support, you need to uncomment the
# next four lines.
#mknod /dev/${device_FIFO}0 c $major_FIFO 0
#mknod /dev/${device_FIFO}1 c $major_FIFO 1
#mknod /dev/${device_FIFO}2 c $major_FIFO 2
#mknod /dev/${device_FIFO}3 c $major_FIFO 3

#give appropriate group/permissions
chgrp ${group} /dev/${device}[0-3]
chmod ${mode}  /dev/${device}[0-3]
# If you have enabled experimental interrupt support, you need to uncomment the
# next two lines.
#chgrp ${group} /dev/${device_FIFO}[0-3]
#chmod ${mode}  /dev/${device_FIFO}[0-3]
