#!/bin/sh
#
# Copyright (C) 2004-2015 QVidium Technologies, Inc. All rights reserved.

# If booting, wait until rcS script finishes
tries=0
pidof rcS > /dev/null
while [ $? = 0 -a $tries -lt 60 ] ; do
    sleep 1
    tries=`expr $tries + 1`
    pidof rcS > /dev/null
done
            
[ ! -c /dev/mtd3 ] && mknod /dev/mtd3 c 90 6
cd /tmp
mtd_char_op read mtd3 0 nandenv.txt > /dev/null

cp nandenv.txt /disk

sed 's/eth0_reset_pin=.*/eth0_reset_pin=2/' nandenv.txt > /tmp/env.rom

mtd_char_op erase mtd3
mtd_char_op write mtd3 /tmp/env.rom

rm -f nandenv.txt /dev/mtd3

mv $0 $0.eth0_reset_pin.sh

reboot

exit 0
