#!/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.

. /ts7800.subr
TMP=`peekpoke 32 0xf1050460`
TMP=$((TMP&1))

if test "$TMP" = "1"; then
  led0 1
  TMP=0
  while test $TMP -lt 15 -a ! -b /dev/sda1; do 
    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
  led0 0
fi

