#!/bin/ash

#echo "${0}: disabling alive mechanism"
/philips/tools/disableamalive

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 "${0}: mounting stuff"
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /dev/shm
mount -t devpts devpts /dev/pts
mount -t usbfs none /proc/bus/usb

#echo "${0}: mounting home drive"
mount -t nfs -o bg,nolock,wsize=1024,rsize=1024,intr 134.27.217.225:/home/image/rootfs/home /home &


#echo "${0}: creating stuff for hotplug"
echo > /proc/sys/kernel/hotplug
echo "./philips/tools/hotplug" > /proc/sys/kernel/hotplug

#echo "${0}: sourcing loadmodules"
export PHILIPS=/philips
. $PHILIPS/scripts/loadmodules
#
# configure Natsemi ethernet driver
#
ifconfig eth1 hw ether 00:52:`ifconfig eth0 | grep HWaddr | tail -c 14`
ifconfig eth1 up
/sbin/udhcpc -i eth1 -s /dhcp/dhclient-script &

# ssh key check
echo "${0}: starting sshd"
check_privsep_dir

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

[ -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

echo "${0}: mounting jffs2 partitions in background"
# options for readonly (ro) or read-write (rw) mount need to be 
# provided manually per partition table info to avoid errors.
mount -t jffs2 /dev/mtdblock6 /mnt/jffs0 
mount -t jffs2 /dev/mtdblock7 /mnt/jffs1 

#echo "${0}: bye"

