#!/bin/sh
echo "Executing Mercury demo /linuxrc..."

export PATH=/bin:/sbin

echo "Loading floating point emulator..."
/sbin/insmod nwfpe

echo "Mounting /proc"
mount -n /proc

echo "Loading Unix socket support"
/sbin/insmod unix

echo "Setting up RAMFS, please wait... "
/sbin/insmod ramfs
mount /mnt/ramfs
tar xfpz .ramfs.tar.gz -C /mnt/ramfs > /dev/null 2>&1

if [ ! -s /etc/inittab ]
then
    echo "You are attemping to boot an incomplete system, starting a shell..."
    mkdir /mnt/ramfs/tmp
    cd /tmp
    exec /bin/sh
fi

echo "Setting up some devices"
if [ -c /dev/touchscreen/0 ] ; then
  ln -s /dev/touchscreen/0 /dev/h3600_ts
  ln -s /dev/touchscreen/0raw /dev/h3600_tsraw
else
  mknod /dev/h3600_ts c 254 0
  mknod /dev/h3600_tsraw c 254 1
fi
if [ -c /dev/vc/0 ]; then
  ln -s /dev/vc/0 /dev/tty0
  ln -s /dev/vc/1 /dev/tty1
  ln -s /dev/vc/2 /dev/tty2
  ln -s /dev/vc/3 /dev/tty3
  ln -s /dev/vc/4 /dev/tty4
  ln -s /dev/vc/5 /dev/tty5
fi
if [ -c /dev/fb/0 ] ; then
  ln -s /dev/fb/0 /dev/fb0
fi
if [ -c /dev/tts/0 ] ; then
  ln -s /dev/tts/0 /dev/ttySA0
  ln -s /dev/tts/1 /dev/ttySA1
  ln -s /dev/tts/2 /dev/ttySA2
fi

/sbin/modprobe sa1100-uda1341

if [ ! -c /dev/dsp ] ; then
  ln -s /dev/sound/dsp /dev/dsp
  ln -s /dev/sound/mixer /dev/mixer
fi

if [ -c /dev/v4l/video0 ] ; then
  ln -s /dev/v4l/video0 /dev/video0
  ln -s /dev/v4l/video0 /dev/video
fi


echo "Setting Date/Time from previous settings"
/bin/date -s "`/bin/cat /etc/lastdate`"

echo "Executing /sbin/init..."
exec /sbin/init
