#!/bin/sh
console=`dirname $0`/iceconsole
runvnc=`dirname $0`/runfbVnc
ipaddr=`hostname -i`
runsu=`which su`
export HOME=/home/root
while [ 0 != 1 ]; do
echo "Running low-SWaP IceOS at ipaddr=$ipaddr, VNC at :1, HTTP at :8080"
echo "Use Alt-F1 for the system console, and Alt-F5 thru Alt-F8 for login TTYs"
echo "Use ssh to root@<ipaddr> and run 'iceconsole' to access console remotely"
echo "Hit Enter to run the IceOS Console as root on this captive TTY3 (Alt-F3)"
echo "Type vnc + Enter to use this display as a vncviewer at :1 on this devIce"
read ans
if [ "$ans" = "" ]; then
  echo "Login as root to run ICE Console"
  $runsu -c $console
elif [[ $ans == vnc@* ]]; then
  addr=`echo $ans | sed 's/vnc@/192.168.0./'`
  $runvnc $addr
elif [ "$ans" = "vnc" ]; then
  $runvnc
fi
done
