#!/bin/sh

/bin/echo "Starting rcS..."

/bin/echo "++ Creating device points"
/bin/mkdir /dev/pts
/bin/mount -t devpts devpts /dev/pts

/bin/echo "++ Mounting filesystem"
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/bin/mount -t tmpfs none /tmp
/bin/mkdir /mnt/sd
/bin/mount -t vfat /dev/mmcblk0p1 /mnt/sd

/bin/echo "++ Loading system loggers"
/sbin/syslogd
/sbin/klogd

/bin/echo "++ Configure HFEX"
/usr/bin/proc-init.sh

/bin/echo "++ ETH0-2: Bring up"
/usr/bin/ethctl -i 0 -d b -e 1
/usr/bin/ethctl -i 1 -d b -e 1
/usr/bin/ethctl -i 2 -d b -e 1

/bin/echo "++ ETH3: Assign address 192.168.20.1 and bring up"
/sbin/ifconfig eth3 192.168.20.1 up

# /bin/echo "++ Starting telnet daemon"
# /usr/sbin/telnetd -l /bin/sh
#/usr/sbin/httpd
#/usr/sbin/ntpd
#/usr/sbin/inetd

/bin/echo "++ Start Dropbear SSH server"
/bin/cp -r /mnt/sd/dropbear /etc
/usr/bin/dropbear

/bin/echo "++ Start cccid"
/bin/cp /mnt/sd/cccid /usr/bin
/usr/bin/cccid -H 192.168.20.2 -P 21105 -i 13 &

/bin/hostname mb-distro
/bin/echo "rcS Complete"
# Light up the LEDs
/usr/bin/busio -w gpio -a 0x04 -d 0x00000000
/usr/bin/busio -w gpio -a 0x00 -d 0x00000000