#!/bin/sh

# 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

echo "Resetting Eth0 and Eth1 to Defaults" > /dev/console
cat <<EOF > /flash/conf/iflan
type=fixed
ip=192.168.1.23
nm=255.255.255.0
gw=192.168.1.1
gw_LAN=192.168.1.1
user=
pswd=
mtu=1500
USE_DHCP_DNS=0
EOF
echo "Eth0 now set to 192.168.1.23" > /dev/console

cat <<EOF > /flash/conf/iflan1
type=fixed
ip=192.168.10.23
nm=255.255.255.0
gw=
gw_LAN=
user=
pswd=
mtu=1500
USE_DHCP_DNS=0
EOF
echo "Eth1 now set to 192.168.10.23" > /dev/console


cat <<EOF > /flash/etc/rc.conf
#!/bin/sh
LAN=eth0

ntpc_enable=0
ntp_host_ip=0.0.0.0

upnp_enable=0

telnetd_enable=1

hostname="qvavc.qvidium.com"

mcast_dev=eth0
EOF
echo "Multicast set to Eth0" > /dev/console

ifconfig eth0 down
ifconfig eth1 down
cd /tmp
/etc/init.d/rc.network
echo "Network has been reset" > /dev/console

mv $0 $0.resetNetwork.sh
