#!/bin/sh

ifconfig eth0
mpoint="none"
nfsconf="none"
xfree86=no
RC=-1

if [ $mpoint = "/var/mnt/usb" ] ; then
	[ -e /dev/scsi/host0/bus0/target0/lun0/disc -a ! -e /dev/scsi/host0/bus0/target0/lun0/part1 ] && mount /dev/scsi/host0/bus0/target0/lun0/disc $mpoint
fi

if [ $mpoint = "/var/mnt/cf" ] ; then
	umount /hdd
	mount /dev/ide/host0/bus0/target0/lun0/part1 $mpoint
	[ "$?" = "1" ] && mount /dev/ide/host0/bus0/target0/lun0/disc $mpoint
fi

if [ $mpoint = "/var/mnt/nfs" ] ; then
	mount -t nfs -o rw,nolock $nfsconf $mpoint
fi

if [ -e $mpoint/tools/lcdmenu ] ; then
	$mpoint/tools/lcdmenu $mpoint
	RC=$?
else
	exit 0
fi

[ $RC -eq 0 ] && echo $mpoint > /tmp/org && exit 0

let RC=$RC-1
[ ! $xfree86 = "no" ] && let RC=$RC-1

#alte Prozesse beenden
killall -9 rcS
killall -9 init
killall -9 smbd
killall -9 nmbd
killall -9 inetd

if [ ! $mpoint = "/hdd" ] && [ ! $xfree86 = "/hdd" ]; then
	umount /hdd
fi

if [ $RC -eq -1 ] ; then
	$mpoint/tools/chroot $xfree86/dreamX ../go
else
	$mpoint/tools/chroot $mpoint/image/$RC ../go
fi
