#!/bin/sh

export LD_LIBRARY_PATH=/tmp/lib:$LD_LIBRARY_PATH:

cd /tmp/

chmod 777 web/images/*
chmod 777 web/css/*
chmod 777 web/js/*
chmod 777 web/*
chmod 777 ko/extdrv/*
chmod 777 ko/*
chmod 777 lib/*
chmod 777 *
chmod 777 nginx/sbin/*

edid_config=$(cat /box/box.ini | grep 'edid_index:')
edid=${edid_config:11:1}
edid_size=`echo "$edid" | wc -c`
if [ "$edid_size" = "2" ]
then
	cp /tmp/edid/$edid.01.* /tmp/edid01.bin
	cp /tmp/edid/$edid.23.* /tmp/edid23.bin
	echo edid is index $edid
fi

#POWER
himm 0x11090400 0xff
himm 0x11090010 0

cd /tmp/ko
./load3531dv200 -i

telnetd&

#LED MUX GPIO1_2 GPIO1_3 GPIO0_0 ~ GPIO0_7

himm 0x10ff0068 0x1201
himm 0x10ff006c 0x1201

himm 0x102f0000 0x1200
himm 0x102f0004 0x1200
himm 0x102f0008 0x1200
himm 0x102f000c 0x1200
himm 0x102f0010 0x1200
himm 0x102f0014 0x1200
himm 0x102f0018 0x1200
himm 0x102f001c 0x1200

#LED DIR
himm 0x11091400 0x8c
himm 0x11090400 0xff

#LED OFF
himm 0x11091030 0x0c
himm 0x110903fc 0xff

#POWER
himm 0x11090010 0x0

#RESET
himm 0x102f00a0 0x1200

#RJ45 LED
himm 0x102903c4 0xd04
himm 0x102903c0 0x11011f
himm 0x102903c4 0x17b
himm 0x102903c0 0x110110

echo 20480000 > /proc/sys/net/core/wmem_default
echo 40960000 > /proc/sys/net/core/wmem_max

cd /tmp/
./reset &

ifconfig lo up

/tmp/nginx/sbin/nginx -p /tmp/nginx/

./box.x4dv200
