#!/bin/sh
local do_if=""

# for fiber WAN
phy_type=$(uci -q get network.wan_phy_type -P /var/state || echo "8601")
if [ "$phy_type" == "8211" ]; then
    echo "write 1 5 0x0 0x103f4181" | armio
fi

now=$(cat /proc/uptime | awk 'FS="[.]+" {print $1}')

[ -n "$1" ] && {
	if [ "$1" == "-F" ]; then
		do_if="1"
	else
		do_if="$1"
	fi
}

if [ $now -ge 60 -o "$do_if" == "1" ]; then
	for iface in wan mngtwan iptvwan voipwan ; do 
		local wan_disable=$(uci -q get network.$iface.disable 2>/dev/null || echo 1)
		[ "$wan_disable" == "1" ] && continue
		logger "[WAN] ifup all wan..."
		ifup $iface
	done
	sleep 1
	sh /lib/firewall/user.sh &
else
	logger "booting ... skip ifup_allwan"
fi