From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-934972-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C579C139694 for <garchives@archives.gentoo.org>; Mon, 27 Feb 2017 00:58:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC09FE0C7A; Mon, 27 Feb 2017 00:58:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B575FE0C7A for <gentoo-commits@lists.gentoo.org>; Mon, 27 Feb 2017 00:58:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 68AEE340C97 for <gentoo-commits@lists.gentoo.org>; Mon, 27 Feb 2017 00:58:03 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 33C4655D1 for <gentoo-commits@lists.gentoo.org>; Mon, 27 Feb 2017 00:58:00 +0000 (UTC) From: "William Hubbs" <williamh@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" <williamh@gentoo.org> Message-ID: <1488138710.d4d0f25a4844ecaed43de913e8b729e7a2e894db.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: conf.d/, init.d/ X-VCS-Repository: proj/openrc X-VCS-Files: conf.d/net-online init.d/net-online.in X-VCS-Directories: conf.d/ init.d/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: d4d0f25a4844ecaed43de913e8b729e7a2e894db X-VCS-Branch: master Date: Mon, 27 Feb 2017 00:58:00 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 759dc9fb-b2f4-4545-9b10-91fc92f5963f X-Archives-Hash: 17322d389d33ab30177c739cfb07f118 commit: d4d0f25a4844ecaed43de913e8b729e7a2e894db Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> AuthorDate: Sun Feb 26 19:51:50 2017 +0000 Commit: William Hubbs <williamh <AT> gentoo <DOT> org> CommitDate: Sun Feb 26 19:51:50 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d4d0f25a 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. conf.d/net-online | 11 +++++++---- init.d/net-online.in | 27 ++++++++++----------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/conf.d/net-online b/conf.d/net-online index aa2c76ba..9abe9ea4 100644 --- a/conf.d/net-online +++ b/conf.d/net-online @@ -3,10 +3,13 @@ # default is all interfaces that support ethernet. #interfaces="" -# This setting controls whether a ping to the default gateway is -# included in the test for network connectivity after all interfaces -# are active. -#ping_default_gateway=no +# This setting controls whether a ping test is included in the test for +# network connectivity after all interfaces are active. +#include_ping_test=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 # for the network to be configured. 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"