#!/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/*
chmod 777 mdnsd/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.* /tmp/edid.bin
	echo edid is index $edid
fi

cd /tmp/ko
./load3521a -i

telnetd&

#GPIO0_0 LED        
#GPIO0_3 RESET     

#GPIO0_DIR
himm 0x12150400 1

#GPIO0_0 HIGH
himm 0x12150004 1

#UART1_RXD/GPIO6_5
#UART1_TXD/GPIO6_7
himm 0x120F00F8 1
himm 0x120F00FC 1

#UART2_RXD/GPIO11_4
#UART2_TXD/GPIO11_5
himm 0x120F0100 1
himm 0x120F0104 1

echo 20480000 > /proc/sys/net/core/wmem_default
echo 40960000 > /proc/sys/net/core/wmem_max
#sysctl -w net.ipv4.tcp_wmem="4096 16384 2080768"

ifconfig lo up

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

cd /tmp/
cp ./passwd /etc/
./reset &
./box.v300
