#!/bin/sh

#ifconfig eth0 192.168.0.2 netmask 255.255.0.0
#route add default gw 192.168.0.1
#mount -t nfs -o nolock 192.168.0.1:/nfs/rootfs /mnt

dd if=/Test.fat of=/dev/rd/0
mount -t vfat /dev/rd/0 /mnt/rd
swapon /mnt/rd/swap.img

#/sbin/modprobe sata_mars & 

#irfake
/sbin/insmod /usr/local/etc/irfake/venus_ir_new.ko
echo 1 > /sys/devices/platform/VenusIR/bypass
/usr/local/etc/irfake/irfake4 -r -f /usr/local/etc/irfake/irfake.conf&

#rm -f /usr/local/etc/dvdplayer/VenusSetup.dat 

if [ -f /usr/local/etc/sata_port1 ]; then
      echo @@@@load sata1@@@@
      rm /usr/local/etc/libata.ko
      rm /usr/local/etc/sata_mars.ko
      ln -s  /usr/bin/libata_1.ko /usr/local/etc/libata.ko
      ln -s  /usr/bin/sata_mars_1.ko /usr/local/etc/sata_mars.ko
else
      echo @@@@load sata by default@@@@
fi

   insmod /usr/local/etc/libata.ko
   insmod /usr/local/etc/sata_mars.ko &

   
ln -s /dev/cdroms/cdrom0 /dev/cdrom0
ln -s /dev/cdrom0 /dev/dvd
ln -s /mnt/dvdvr /dev/dvdvr

# This variable tells DvdPlayer the firmware URL for internet updating
LIVEUPDATE_URL=
DEFAULT_AP_DIR=/usr/local/bin
#/usr/sbin/httpd -p 1024 -h /www

CHIPSET="RTD1283"
if [ $CHIPSET = "RTD1183" ]; then
	echo "RTD1183 sleep 3"
	sleep 3
fi

if [ -f $DEFAULT_AP_DIR/DvdPlayer ] && [ -x $DEFAULT_AP_DIR/DvdPlayer ]; then
    touch /tmp/ir
    cd $DEFAULT_AP_DIR
    if [ -f $DEFAULT_AP_DIR/RootApp ] && [ -x $DEFAULT_AP_DIR/RootApp ]; then
	echo Running dvdplayer with RootApp
	tail -f /tmp/ir | ./RootApp DvdPlayer&
    else
        echo Running dvdplayer
        tail -f /tmp/ir | ./DvdPlayer&
    fi
else
    /etc/dvdplayer/script/run_tail
fi


#Nand doesn't have signature
#SIGNATURE=`dd if=/dev/mtdblock/0 bs=8 count=1`
#if [ "$SIGNATURE" != "VERONA__" ]; then
#	echo This is not the first time booting up. No need to write the magic into flash
#	let size="0x"`grep mtd3 /proc/mtd | cut -d " " -f2`
#	let size=size-0x120000
#	let size=size+130816
#	let size=size/4
#	MAGIC=`dd if=/dev/mtdblock/3 bs=4 skip=$size count=1`
#	if [ "$MAGIC" = "babe" ]; then
#		echo This is not the first time booting up. No need to write the magic into flash
#	else
#		dd if=/usr/local/etc/magic of=/dev/mtdblock/3 bs=4 seek=$size count=1
#		echo This is the first time booting up. Write the magic into flash
#	fi
#fi

echo 2 /tmp/hdd/volumes/HDD1/ > /sys/realtek_boards/misc_operations

sh /usr/local/etc/myS > /dev/console&