#!/bin/sh /etc/rc.common

START=15
STOP=91

SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1


start() {
	[ -e /proc/sys/kernel/core_pattern ] && {
		ulimit -c 0
	}
	
	wdev=$(swconfig dev switch0 get wan_dev_name)
	[ -z "$wdev" ] && {
		#swconfig dev switch0 load vlan
		wan_dev_name=$(uci get network.global.wan_device)
		swconfig dev switch0 set wan_dev_name "${wan_dev_name}"
	}

	#/etc/init.d/zone start
	service_start /sbin/netifd
}

restart() {
	stop
	start
}

shutdown() {
	stop
}

stop() {
	local pid=$(pidof netifd)

	ifdown -a
	sleep 10
	if [ x"$pid" != x ]; then
		sleep 1
	fi

	service_stop /sbin/netifd
}

reload() {
    #/etc/init.d/zone restart
	ubus call network reload
}

boot() {
	#fix bug 722261 Enable the ignore_routes_with_linkdown switch to disable linkdown routes
	#Note If the phy port is changed, the corresponding NIC parameters must be modified
	echo 1 > /proc/sys/net/ipv4/conf/default/ignore_routes_with_linkdown
	start
}
