#!/bin/sh

moddir=/lib/modules
sbindir=`dirname $0`

if test -f $sbindir/umd_phone ; then
	if test ! -f /proc/isapnp ; then insmod isapnp ; fi
	if test -z `pidof umd` ; then exec $sbindir/umd_phone $* ; fi
	if test ! -c /dev/phone0 ; then mknod -m 0600 /dev/phone0 c 100 0 ; fi
	ixj=`lsmod | grep ixj`
	if test -z "$ixj" ; then
		insmod -f `find $moddir | grep ixj\.o` ; fi
	echo "*** umd already started or failed" >&2
	exit -1
fi

if test -f $sbindir/umd_pika ; then
	if test -d /usr/pika/Release ; then
		moddir=/usr/pika/Release
	fi 
	if test ! -c /dev/pikacti0 ; then mknod -m 0600 /dev/pikacti0 c 70 0 ; fi
	if test ! -c /dev/pikadsp0 ; then mknod -m 0600 /dev/pikadsp0 c 71 0 ; fi
	pikacti=`lsmod | grep pikacti`
	pikadsp=`lsmod | grep pikadsp`
	if test -z "$pikacti" ; then 
		insmod -f `find $moddir | grep pikacti\.o` ; fi
	if test -z "$pikadsp" ; then 
		insmod -f `find $moddir | grep pikadsp\.o` ; fi
	if test -z "$PIKA_REGISTRY" ; then
		if test -f /etc/pika.conf ; then
			export PIKA_REGISTRY=/etc/pika.conf
		fi
	fi
	if test -z "$PIKA_DIR" ; then
		if test -f /usr/pika ; then
			export PIKA_DIR=/usr/pika
		fi
	fi
	if test -z `pidof umd` ; then exec $sbindir/umd_pika $* ; fi
	echo "*** umd already started or failed" >&2
	exit -1
fi


if test -f $sbindir/umd_vpb ; then
	vpb=`lsmod | grep vpb`
	if test -z "$vpb" ; then
		insmod `find /lib/modules | grep vpb\.o` ; fi
	exec $sbindir/umd_vpb $*
fi

echo "***: no hardware specific server installed"
exit -1

