#!/bin/sh

. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

modem_settings()
{
	local board="$1"

	case $board in
	HC,HC-G80)
		add_ipv4_config "1_1_1" 2 1
		add_ipv4_config "1_1_4" 2 1
		add_ipv4_config "2_1" 1 1
		uci commit qmodem_mwan
		;;
	ailf,gs2410)
		add_ipv4_config "5g0"  1 1
		add_ipv4_config "5g1" 1 1
		add_ipv4_config "4g0" 30 1
		add_ipv4_config "4g1" 30 1
		add_ipv4_config "4g2" 30 1
		add_ipv4_config "4g3" 30 1
		uci commit qmodem_mwan
		;;
	huasifei,ws3006)
		add_ipv4_config "5g0"  10 1
		add_ipv4_config "5g1" 10 1
		add_ipv4_config "4g0" 10 1
		add_ipv4_config "4g1" 10 1
		add_ipv4_config "4g2" 10 1
		add_ipv4_config "4g3" 10 1
		uci commit qmodem_mwan
		;;
	
	esac
}


add_ipv4_config(){
	local interface_name="$1"
	cfg=$(uci add qmodem_mwan ipv4)
uci batch<<-EOF >/dev/null
set qmodem_mwan.$cfg.member_interface=$interface_name
set qmodem_mwan.$cfg.member_priority=$2
set qmodem_mwan.$cfg.member_weight=$3
add_list qmodem_mwan.$cfg.member_track_ip='119.29.29.29'
add_list qmodem_mwan.$cfg.member_track_ip='taobao.com'
add_list qmodem_mwan.$cfg.member_track_ip='baidu.com'
EOF
}




board=$(board_name)
modem_settings $board
exit 0
