#!/bin/sh
# The following code detects if something is connected to USB port 0,
# and if so checks for a flash drive with /tsinit to execute.

. /ts7000.subr
usb_init
TMP=`usb_port_devexists 0`
if test "$TMP" = "1"; then
  led1 1
  sleep 3
  insmod /tssdcard.ko
  mdev -s
  mount -o ro /dev/tssdcarda4 /mnt/root
  modprobe ohci-hcd
  modprobe sd_mod
  modprobe usb-storage
  modprobe vfat
  modprobe ext3
  umount /mnt/root
  TMP=0
  while test $TMP -lt 15 -a ! -b /dev/sda1; do 
    let TMP=$TMP+1;
    mdev -s 
    sleep 1; 
  done
  if test -b /dev/sda1; then
    mount -o ro /dev/sda1 /mnt/root
    if test -x /mnt/root/tsinit; then
      /mnt/root/tsinit < $CONSOLE > $CONSOLE 2>&1
    fi
    umount /mnt/root
  fi
  led1 0
else
  usb_off
fi
