#! /bin/csh -f

#
# install kernel module
#
source scripts/aliases

	# now, it happens
	if ( ! $?grp ) set grp

	if ($hpux) then
		source $FWDIR/bin/hpux.kernel.inst
		goto dorc
	endif

	if ($aix) then
		/bin/rm -f /etc/drivers/fw.ext >& /dev/null
		ln -s $FWDIR/$module /etc/drivers/fw.ext
		goto dorc
	endif

	if ( $solaris2 == 0 ) goto dorc

	label "$product kernel module installation"


	/bin/rm -f /usr/kernel/drv/fw /usr/kernel/drv/fw.conf >& /dev/null
	if ($aix) then
		ln -fs $FWDIR/$module /usr/kernel/drv/fw
		ln -fs $FWDIR/modules/fw.conf /usr/kernel/drv/fw.conf
	else
		ln -s $FWDIR/$module /usr/kernel/drv/fw
		ln -s $FWDIR/modules/fw.conf /usr/kernel/drv/fw.conf
	endif

	set mode = "* 0660 root $grp"

	if ( "X$grp" == "X" ) set mode = '* 0600 root bin'
	E -n "installing FW-1 kernel module... "
	/usr/sbin/add_drv -m "$mode" fw
	if ($status != 0) then
		echo "FAILING TO INSTALL FW-1 kernel module (maybe already installed)"
	endif
 	sync

	cp /etc/devlink.tab /etc/devlink.tab.bak
	egrep -s 'name=fw[ 	]' /etc/devlink.tab
	if ($status == 0) then
		ex - /etc/devlink.tab << EOEX >& /dev/null
:g/name=fw[ 	]/d
w!
q
EOEX
	endif
	E "type=ddi_pseudo;name=fw	fw\A0" >> /etc/devlink.tab
	/usr/sbin/devlinks
	if ( ! -e /dev/fw0 ) then
		quit 'Failed to create /dev/fw0, contact your reseller for help'
	endif
	E "Done."

dorc:
	exit 0

last:
	exit 1

