#!/bin/sh

DAEMON2=/usr/bin/ssh-keygen
CONF=/etc/ssh/ssh_host_key
CONFR=/etc/ssh/ssh_host_rsa_key
CONFD=/etc/ssh/ssh_host_dsa_key

check_privsep_dir() 
{
        # Create the PrivSep empty dir if necessary
        if [ ! -d /var/run/sshd ]; then
                mkdir /var/run/sshd
                chmod 0755 /var/run/sshd
        fi
}

echo "LET'S GO FOR A NEW SCRIPT!!!"
#/sbin/loadkmap < /usr/share/kbd/be-latin1.map

if [ -d /sys/class/net/usb0 ];
then
  ETH=usb0
fi
if [ -d /sys/class/net/eth0 ];
then
  ETH=eth0
fi

if [ $ETH ];
then
  echo "Ethernet interface" $ETH "detected"
#  /usr/local/bin/mii-tool $ETH --force=10baseT-FD
  udhcpc -i $ETH
  /usr/sbin/telnetd -l /bin/login
fi


#GATEWAY="192.168.1.1"

# To use DHCP instead of a static IP, set this value to "yes" (unless you boot
# from an NFS root with TCP/IP already set up via DHCP within the kernel):
# [GRR 20011102:  now set via environment variable and config-files/Makefile]
#DHCP="no"              # Use DHCP ("yes" or "no")

# If there is a gateway defined, then set it up:
/bin/rm -f /etc/resolv.conf
if [ ! "$GATEWAY" = "" ]; then
  /sbin/route add default gw ${GATEWAY} netmask 0.0.0.0 metric 1
  echo "nameserver $GATEWAY" > /etc/resolv.conf
fi

#Comment the following line if you want your ap to start automatically
/bin/login root

#Uncomment the following lines if you want your app to start automatically
#/philips/tools/htload -i /home/tmtv520avAtscInstanceTmApp.mi
#/home/tv520avi.elf

################################
# Prepare and start ssh stuff...
################################

check_privsep_dir

[ -s $CONF ] || $DAEMON2 -b 1024 -f $CONF -N "" -t rsa1
[ -s $CONFR ] || $DAEMON2 -d -f $CONFR -N "" -t rsa
[ -s $CONFD ] || $DAEMON2 -d -f $CONFD -N "" -t dsa

/usr/sbin/sshd 
