#!/bin/sh

ENABLE_NETWORK=1
#ENABLE_MPLAYER=0

echo "Run boot_script"

#> Execute update script
cd /mnt/nand1-1/
./update.sh

#> Start up Ethernet
if [ "$ENABLE_NETWORK" -eq "1" ]; then
	ifconfig eth0 up
#	udhcpc
if [ ! -d "/dev/pts" ]; then
        mkdir /dev/pts
        mount -t devpts devpts /dev/pts
fi

#> Start TELNET service
	telnetd -l /bin/sh &
fi

#> Configure IP address
ifconfig eth0 10.2.192.0
ifconfig netmask 255.0.0.0
route add default gw 10.0.0.1

#ifconfig eth0 192.168.2.145
#ifconfig netmask 255.255.255.0
#route add default gw 192.168.2.142
#mount -o nolock -t nfs 10.0.0.200:/nfs /mnt/nfs
#mount -o nolock -t nfs 10.0.0.200:/nfs/lib /lib 
#mount -o nolock -t nfs 10.0.0.200:/nfs/etc /etc
#mount -o nolock -t nfs 10.0.0.200:/nfs/usr /usr

##### run user's boot procedure #####
#ls -l

#if [ "$ENABLE_MPLAYER" -eq "1" ]; then
#	./mplayer -quiet -loop 0 *.mp4 &
#fi

#> Start FTP server
cd /mnt/nand1-2/working/Resources/tools/
echo "current path is \""`pwd`"\""
./stupid-ftpd.Linux6 -f   ./stupid-ftpd.conf

#> Start Web server
cd /mnt/nand1-2/working/Resources/tools/boa/
./start_boa.sh

#> Load driver modules
cd /mnt/nand1-2/working/Resources/driver/
insmod ./gpio_ctrl_ko.ko
insmod ./fm1188_ko.ko
insmod ./card_reader_ko.ko
insmod ./vpost_refresh.ko
insmod ./gpio_ctrl_key_ko.ko

#> Start main app
cd /mnt/nand1-2/working/
./launcher

#insmod /usr/g_file_storage.ko file=/dev/sda5 stall=0 removable=1
rm -rf Recycled
rm -rf "\$RECYCLE.BIN"
rm -rf "System Volume Information"
