#!/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

#/sbin/modprobe ide-cd
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&

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

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

if [ -f $DEFAULT_AP_DIR/DvdPlayer ] && [ -x $DEFAULT_AP_DIR/DvdPlayer ]; then
	cd $DEFAULT_AP_DIR
	if [ -f $DEFAULT_AP_DIR/RootApp ] && [ -x $DEFAULT_AP_DIR/RootApp ]; then
		echo Running dvdplayer with RootApp
		./RootApp DvdPlayer&
	else
		echo Running dvdplayer
		./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

