1 |
commit: d4d0f25a4844ecaed43de913e8b729e7a2e894db |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Sun Feb 26 19:51:50 2017 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 26 19:51:50 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d4d0f25a |
7 |
|
8 |
net-online: updates to make the service more usable |
9 |
|
10 |
- switch from attempting to ping the default gateway to a host outside |
11 |
the local network, defaulting to google.com. |
12 |
- along with this, change the name of the variable that requests a ping |
13 |
test to include_ping_test so the meaning is more clear. |
14 |
|
15 |
conf.d/net-online | 11 +++++++---- |
16 |
init.d/net-online.in | 27 ++++++++++----------------- |
17 |
2 files changed, 17 insertions(+), 21 deletions(-) |
18 |
|
19 |
diff --git a/conf.d/net-online b/conf.d/net-online |
20 |
index aa2c76ba..9abe9ea4 100644 |
21 |
--- a/conf.d/net-online |
22 |
+++ b/conf.d/net-online |
23 |
@@ -3,10 +3,13 @@ |
24 |
# default is all interfaces that support ethernet. |
25 |
#interfaces="" |
26 |
|
27 |
-# This setting controls whether a ping to the default gateway is |
28 |
-# included in the test for network connectivity after all interfaces |
29 |
-# are active. |
30 |
-#ping_default_gateway=no |
31 |
+# This setting controls whether a ping test is included in the test for |
32 |
+# network connectivity after all interfaces are active. |
33 |
+#include_ping_test=no |
34 |
+ |
35 |
+# This setting is the host to attempt to ping if the above is yes. |
36 |
+# The default is google.com. |
37 |
+#ping_test_host=some.host.name |
38 |
|
39 |
# The timeout setting controls how long the net-online service waits |
40 |
# for the network to be configured. |
41 |
|
42 |
diff --git a/init.d/net-online.in b/init.d/net-online.in |
43 |
index dd3548d6..31af4dd1 100644 |
44 |
--- a/init.d/net-online.in |
45 |
+++ b/init.d/net-online.in |
46 |
@@ -15,6 +15,7 @@ depend() |
47 |
{ |
48 |
after modules |
49 |
need sysfs |
50 |
+ provide network-online |
51 |
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver |
52 |
} |
53 |
|
54 |
@@ -27,19 +28,6 @@ get_interfaces() |
55 |
done |
56 |
} |
57 |
|
58 |
-get_default_gateway() |
59 |
-{ |
60 |
- local cmd gateway |
61 |
- if command -v ip > /dev/null 2>&1; then |
62 |
- cmd="ip route show" |
63 |
- else |
64 |
- cmd=route |
65 |
- fi |
66 |
- set -- $($cmd | grep default) |
67 |
- [ "$2" != via ] && gateway="$2" || gateway="$3" |
68 |
- printf "%s" $gateway |
69 |
-} |
70 |
- |
71 |
start () |
72 |
{ |
73 |
local carriers configured dev gateway ifcount infinite |
74 |
@@ -66,10 +54,15 @@ start () |
75 |
: $((timeout -= 1)) |
76 |
done |
77 |
! $infinite && [ $timeout -eq 0 ] && rc=1 |
78 |
- if [ $rc -eq 0 ] && yesno ${ping_default_gateway:-no}; then |
79 |
- gateway="$(get_default_gateway)" |
80 |
- if [ -n "$gateway" ] && ! ping -c 1 $gateway > /dev/null 2>&1; then |
81 |
- rc=1 |
82 |
+ include_ping_test=${include_ping_test:-${ping_default_gateway}} |
83 |
+ if [ -n "${ping_default_gateway}" ]; then |
84 |
+ ewarn "ping_default_gateway is deprecated, please use include_ping_test' |
85 |
+ fi |
86 |
+ if [ $rc -eq 0 ] && yesno ${include_ping_test:-no}; then |
87 |
+ ping_test_host="${ping_test_host:-google.com}" |
88 |
+ if [ -n "$ping_test_host" ]; then |
89 |
+ ping -c 1 $ping_test_host > /dev/null 2>&1 |
90 |
+ rc=$? |
91 |
fi |
92 |
fi |
93 |
eend $rc "The network is offline" |