2008-06-05 17:26:47 +00:00
|
|
|
#!/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()
|
|
|
|
{
|
2009-02-02 15:33:22 +00:00
|
|
|
local output carrier nocarrier
|
|
|
|
|
|
|
|
# Return without waiting if we don't have dhcp interfaces or
|
|
|
|
# if none of the dhcp interfaces is plugged in.
|
|
|
|
dhcp_interfaces=`list_net_interfaces dhcp`
|
|
|
|
[ -z "${dhcp_interfaces}" ] && return
|
|
|
|
carrier=false
|
|
|
|
for _if in ${dhcp_interfaces}; do
|
|
|
|
output=`/sbin/ifconfig ${_if}`
|
|
|
|
nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'`
|
|
|
|
[ -z "${nocarrier}" ] && carrier=true
|
|
|
|
done
|
|
|
|
if ! ${carrier}; then
|
|
|
|
return
|
|
|
|
fi
|
2008-06-05 17:26:47 +00:00
|
|
|
|
|
|
|
# Wait for a default route
|
2009-02-17 11:55:50 +00:00
|
|
|
delay=${defaultroute_delay}
|
2008-06-05 17:26:47 +00:00
|
|
|
while [ ${delay} -gt 0 ]; do
|
|
|
|
defif=`get_default_if -inet`
|
|
|
|
if [ -n "${defif}" ]; then
|
2009-02-17 11:55:50 +00:00
|
|
|
if [ ${delay} -ne ${defaultroute_delay} ]; then
|
2008-12-17 17:35:14 +00:00
|
|
|
echo -n "($defif)"
|
2008-06-05 17:26:47 +00:00
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
2009-02-17 11:55:50 +00:00
|
|
|
if [ ${delay} -eq ${defaultroute_delay} ]; then
|
2009-02-11 09:18:09 +00:00
|
|
|
echo -n "Waiting ${delay}s for the default route interface: "
|
2008-06-05 17:26:47 +00:00
|
|
|
else
|
|
|
|
echo -n .
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
delay=`expr $delay - 1`
|
|
|
|
done
|
2008-12-17 17:35:14 +00:00
|
|
|
|
|
|
|
echo
|
2008-06-05 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|