#!/bin/sh

echo "uci settings"

ipv6_disable_nat() {
  NAT6=`uci -q get firewall.nat6.reload`
  if [ "$NAT6" = "1" ]; then
    uci -q delete network.wan6.sourcefilter
    uci -q delete firewall.nat6
    uci commit firewall
    /etc/init.d/firewall restart
  fi
}

ipv6_disable_nat

uci -q batch <<-EOF
	del dhcp.lan.ra
	del dhcp.lan.dhcpv6
	del dhcp.lan.ra_flags
	add_list dhcp.lan.ra_flags=none

	set network.wan.ipv6='0'
	del dhcp.wan.ra_flags
	add_list dhcp.wan.ra_flags=none

	set network.wan6.auto=0

	set dhcp.@dnsmasq[0].filter_aaaa='1'

	commit network
	commit dhcp
EOF

echo "reload_config"
reload_config
echo -n "wait for device online"
for i in `seq 10 -1 1`; do
	echo -n "."
	sleep 1
done
echo ""
echo "done"
