net-online: updates to make the service more usable
- switch from attempting to ping the default gateway to a host outside the local network, defaulting to google.com. - along with this, change the name of the variable that requests a ping test to include_ping_test so the meaning is more clear.
This commit is contained in:
parent
1cb44092fc
commit
d4d0f25a48
@ -3,10 +3,13 @@
|
|||||||
# default is all interfaces that support ethernet.
|
# default is all interfaces that support ethernet.
|
||||||
#interfaces=""
|
#interfaces=""
|
||||||
|
|
||||||
# This setting controls whether a ping to the default gateway is
|
# This setting controls whether a ping test is included in the test for
|
||||||
# included in the test for network connectivity after all interfaces
|
# network connectivity after all interfaces are active.
|
||||||
# are active.
|
#include_ping_test=no
|
||||||
#ping_default_gateway=no
|
|
||||||
|
# This setting is the host to attempt to ping if the above is yes.
|
||||||
|
# The default is google.com.
|
||||||
|
#ping_test_host=some.host.name
|
||||||
|
|
||||||
# The timeout setting controls how long the net-online service waits
|
# The timeout setting controls how long the net-online service waits
|
||||||
# for the network to be configured.
|
# for the network to be configured.
|
||||||
|
@ -15,6 +15,7 @@ depend()
|
|||||||
{
|
{
|
||||||
after modules
|
after modules
|
||||||
need sysfs
|
need sysfs
|
||||||
|
provide network-online
|
||||||
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
|
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,19 +28,6 @@ get_interfaces()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_default_gateway()
|
|
||||||
{
|
|
||||||
local cmd gateway
|
|
||||||
if command -v ip > /dev/null 2>&1; then
|
|
||||||
cmd="ip route show"
|
|
||||||
else
|
|
||||||
cmd=route
|
|
||||||
fi
|
|
||||||
set -- $($cmd | grep default)
|
|
||||||
[ "$2" != via ] && gateway="$2" || gateway="$3"
|
|
||||||
printf "%s" $gateway
|
|
||||||
}
|
|
||||||
|
|
||||||
start ()
|
start ()
|
||||||
{
|
{
|
||||||
local carriers configured dev gateway ifcount infinite
|
local carriers configured dev gateway ifcount infinite
|
||||||
@ -66,10 +54,15 @@ start ()
|
|||||||
: $((timeout -= 1))
|
: $((timeout -= 1))
|
||||||
done
|
done
|
||||||
! $infinite && [ $timeout -eq 0 ] && rc=1
|
! $infinite && [ $timeout -eq 0 ] && rc=1
|
||||||
if [ $rc -eq 0 ] && yesno ${ping_default_gateway:-no}; then
|
include_ping_test=${include_ping_test:-${ping_default_gateway}}
|
||||||
gateway="$(get_default_gateway)"
|
if [ -n "${ping_default_gateway}" ]; then
|
||||||
if [ -n "$gateway" ] && ! ping -c 1 $gateway > /dev/null 2>&1; then
|
ewarn "ping_default_gateway is deprecated, please use include_ping_test'
|
||||||
rc=1
|
fi
|
||||||
|
if [ $rc -eq 0 ] && yesno ${include_ping_test:-no}; then
|
||||||
|
ping_test_host="${ping_test_host:-google.com}"
|
||||||
|
if [ -n "$ping_test_host" ]; then
|
||||||
|
ping -c 1 $ping_test_host > /dev/null 2>&1
|
||||||
|
rc=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
eend $rc "The network is offline"
|
eend $rc "The network is offline"
|
||||||
|
Loading…
Reference in New Issue
Block a user