#!/bin/sh
#
# Copyright (c) 1999-2002 by Sun Microsystems, Inc.
#
# /etc/rc2.d/S91jfbinit - UNIX initialization of JFB

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

JFBS="pci3d3d,1044|SUNW,XVR-1200|pci3d3d,1047|SUNW,XVR-600"


case $1 in 
'start')

	#
	# Find out how many JFB cards are installed on the system.
	# If there aren't any, exit.
	#
	jfb_count=`prtconf -vp | egrep -c "\'(${JFBS})\'"`

	devpath=/dev
	test -d /dev/fbs && devpath=/dev/fbs
	devs=`/bin/ls -1 $devpath | /bin/grep 'jfb[0-9]*[0-9]$'`

	if [ ${jfb_count} -eq 0 -o "$devs" = "" ]
	then
		exit 0
	fi

	#
	#  Download the microcode to each jfb.
	#
	for inst in $devs
	do
		/usr/sbin/jfbdaemon /dev/fbs/${inst} >/dev/console  2>&1 &
	done

	exit 0
	;;

'stop')
	pid=`/usr/bin/ps -eo pid,comm | /usr/bin/awk '{ if ($2 == "/usr/sbin/jfbdaemon") print $1 }'`
        if test "$pid"
        then
                kill $pid
        fi
        exit 0
        ;;

*)
        echo "Usage: /etc/init.d/jfbdaemon { start | stop }"
        ;;
esac
exit 0
