aboutsummaryrefslogtreecommitdiff
path: root/init.d/net-online.in
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-02-26 13:51:50 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-02-26 13:51:50 -0600
commitd4d0f25a4844ecaed43de913e8b729e7a2e894db (patch)
tree5f4c80f447862b3737d17d8bc825d38209a518ba /init.d/net-online.in
parent1cb44092fce298004ab4c4547c6fbcac29c5997f (diff)
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.
Diffstat (limited to 'init.d/net-online.in')
-rw-r--r--init.d/net-online.in27
1 files changed, 10 insertions, 17 deletions
diff --git a/init.d/net-online.in b/init.d/net-online.in
index dd3548d6..31af4dd1 100644
--- a/init.d/net-online.in
+++ b/init.d/net-online.in
@@ -15,6 +15,7 @@ depend()
{
after modules
need sysfs
+ provide network-online
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
}
@@ -27,19 +28,6 @@ get_interfaces()
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 ()
{
local carriers configured dev gateway ifcount infinite
@@ -66,10 +54,15 @@ start ()
: $((timeout -= 1))
done
! $infinite && [ $timeout -eq 0 ] && rc=1
- if [ $rc -eq 0 ] && yesno ${ping_default_gateway:-no}; then
- gateway="$(get_default_gateway)"
- if [ -n "$gateway" ] && ! ping -c 1 $gateway > /dev/null 2>&1; then
- rc=1
+ include_ping_test=${include_ping_test:-${ping_default_gateway}}
+ if [ -n "${ping_default_gateway}" ]; then
+ ewarn "ping_default_gateway is deprecated, please use include_ping_test'
+ 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
eend $rc "The network is offline"