#!/bin/sh /etc/rc.common
START=101
restart()
{
. /lib/functions/network.sh
config_cb(){
local type=$1
local name=$2
if [ "$1" = "interface" ] && [ "$2" != "loopback" ]&& [ "$2" != "lan" ]; then
gw=$(ubus call network.interface.$name status | grep nexthop | grep -oE '([0-9]{1,3}.){3}.[0-9]{1,3}')
metric=$(ubus call network.interface.$name status | grep -w "metric" | grep -oE '([0-9])')
if [ $gw ]; then
echo "my type is $1, my name is $2 ,my gw is $gw, my metric is $metric"
option_cb(){
if [ "$1" = "ifname" ] && [ $gw ]; then
route del default gw $gw dev $2
route add default gw $gw dev $2 metric $metric
fi
}
fi
fi
}
config_load 'network'
}