#!/bin/sh
#
# This will prepare and begin operation of the "application" program(s).
#

# Splash.
#
logfile=/var/log/app.startup.log
echo "Executing default /app/scripts/startup..." > $logfile

# Not running anything...
# echo "Not initializing network or applications..." >> $logfile
# exit 0

# Source the port pin setup. This will be determined by hardware type.
# Any initialization specific to the hardware should be done there.
#
. /app/scripts/gpio-setup

# Setup MAC address first as config-loader application needs it.
EP93XX_MAC=$(getmac)
/sbin/ifconfig eth0 down
/sbin/ifconfig eth0 hw ether $EP93XX_MAC
/sbin/ifconfig eth0 up
/app/bin/config-loader

# Bring up the network interface.
/scripts/network_up

# Disable promiscuous mode
macreg 0 0x73401

# Start inetd.
inetd

# Start telnetd.
telnetd

# Not running applications...
# echo "NOT running application" >> $logfile
# exit 0

# Start remote command line interface; active for 60 seconds.
#
/app/bin/rcli 60 &

###########################
# Start other applications.
###########################

insmod /app/bin/mstp.ko
#grep mstp /proc/kallsyms|sort > /data/config/mstp.map
/app/bin/bas-rt &

# Remove the current boa marker file if it exists
if [ -e /var/run/boa.pid ]
then
	rm /var/run/boa.pid
fi
	
# Start web server
/app/bin/lighttpd -m /usr/lib/lighttpd -f /etc/lighttpd/lighttpd.conf &

# Monitor settings change
/app/scripts/settingsChange &

# Monitor Default Switch
/app/scripts/resetIP.sh &

# And exit.
exit 0
