From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-990134-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 9FF80138806
	for <garchives@archives.gentoo.org>; Tue, 12 Dec 2017 22:59:46 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A5AC8E0E87;
	Tue, 12 Dec 2017 22:59:45 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 81CDFE0E87
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Dec 2017 22:59:45 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id E563533BDE1
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Dec 2017 22:59:43 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 595884C92
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Dec 2017 22:59:41 +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: <1513117774.14938c29cefe869872b987f8e606da72024fa8bb.williamh@OpenRC>
Subject: [gentoo-commits] proj/openrc:master commit in: init.d/
X-VCS-Repository: proj/openrc
X-VCS-Files: init.d/net-online.in
X-VCS-Directories: init.d/
X-VCS-Committer: williamh
X-VCS-Committer-Name: William Hubbs
X-VCS-Revision: 14938c29cefe869872b987f8e606da72024fa8bb
X-VCS-Branch: master
Date: Tue, 12 Dec 2017 22:59:41 +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: 06acbb1c-59a4-4173-942f-dce1f94e91c9
X-Archives-Hash: 5e070e08ef44ebfd74dd0dc4e3b8b5f4

commit:     14938c29cefe869872b987f8e606da72024fa8bb
Author:     bell07 <web.alexander <AT> web <DOT> de>
AuthorDate: Tue Dec 12 20:51:55 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Dec 12 22:29:34 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=14938c29

net-online: wait for ping_test_host

The script should wait till the ping host is available or timeout reached
Closes : #179
Closes : #191

 init.d/net-online.in | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/init.d/net-online.in b/init.d/net-online.in
index 5ea6bf64..1175f29c 100644
--- a/init.d/net-online.in
+++ b/init.d/net-online.in
@@ -63,8 +63,12 @@ start ()
  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=$?
+		while $infinite || [ $timeout -gt 0 ]; do
+			ping -c 1 $ping_test_host > /dev/null 2>&1
+			rc=$?
+			[ $rc -eq 0 ] && break
+			: $((timeout -= 1))
+		done
 	fi
  fi
  eend $rc "The network is offline"