summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/defaultroute
blob: 876d682b3f2800ff9930c1ab9bce9fa09ae53dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
#
# Wait for the default route to be up
#
# $FreeBSD$
#

# PROVIDE: defaultroute
# REQUIRE: devd netif network_ipv6
# KEYWORD: nojail

. /etc/rc.subr
. /etc/network.subr

name="defaultroute"
start_cmd="defaultroute_start"
stop_cmd=":"

defaultroute_start()
{
	# Return without waiting if we don't have dhcp interfaces.
	# Once we can test that the link is actually up, we should
	# remove this test and always wait.
	dhcp_interfaces=`list_net_interfaces dhcp`
	[ -z "`list_net_interfaces dhcp`" ] && return

	# Wait for a default route
	delay=${if_up_delay}
	while [ ${delay} -gt 0 ]; do
		defif=`get_default_if -inet`
		if [ -n "${defif}" ]; then
			if [ ${delay} -ne ${if_up_delay} ]; then
				echo "($defif)"
			fi
			break
		fi
		if [ ${delay} -eq ${if_up_delay} ]; then
			echo -n "Waiting ${delay}s for an interface to come up: "
		else
			echo -n .
		fi
		sleep 1
		delay=`expr $delay - 1`
	done
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud