From owner-freebsd-rc@FreeBSD.ORG Sat Jun 5 04:19:51 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2B451065673 for ; Sat, 5 Jun 2010 04:19:51 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 77F4B8FC17 for ; Sat, 5 Jun 2010 04:19:51 +0000 (UTC) Received: (qmail 31906 invoked by uid 399); 5 Jun 2010 04:19:49 -0000 Received: from localhost (HELO foreign.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 5 Jun 2010 04:19:49 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <4C09D062.1010706@FreeBSD.org> Date: Fri, 04 Jun 2010 21:19:46 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.1.9) Gecko/20100330 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jeremy Chadwick References: <20100603020444.GL1875@rwpc12.mby.riverwillow.net.au> <20100603044530.GA93342@icarus.home.lan> <4C074C11.20807@FreeBSD.org> <20100603093357.GA1849@icarus.home.lan> In-Reply-To: <20100603093357.GA1849@icarus.home.lan> X-Enigmail-Version: 1.0.1 OpenPGP: id=1A1ABC84 Content-Type: multipart/mixed; boundary="------------070506060802040508070901" Cc: freebsd-rc@freebsd.org Subject: Re: rc(8) script -- waiting for the network to become usable X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2010 04:19:52 -0000 This is a multi-part message in MIME format. --------------070506060802040508070901 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 06/03/10 02:33, Jeremy Chadwick wrote: > > As usual, thanks a ton, Doug! > > I've incorporated your changes (I understand them all) and agree with > your variable rename suggestion (iface --> if). Glad I could help. > I also removed some of > the echo statements that referenced /bin/date and so on -- those were > left in from the debugging session with aforementioned user. Oops. No worries, I expected that was the case. This should be the last patch, I've made it even less chatty, which brings it more in line to the usual way we do things (success is expected, errors need explanation). In testing I did come across one error condition that wasn't handled, an interface name is specified, but doesn't exist. So I added code for that, should be obvious. :) If these changes are Ok, and you (or someone) do the etc/defaults/rc.conf and rc.conf.5 patches, I'll be glad to review and commit when ready. Someone else already pointed out that this is too late for 8.1, which I agree with, but that's Ok, I likely wouldn't have MFC'ed it for 8.1 even if it had gone in a month ago. With these kinds of changes I really like them to have time to shake out first. Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ --------------070506060802040508070901 Content-Type: text/plain; name="netwait.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="netwait.diff" --- netwait 2010-06-04 20:53:45.000000000 -0700 +++ /usr/local/etc/rc.d/netwait 2010-06-04 21:10:25.000000000 -0700 @@ -60,15 +61,19 @@ trap break SIGINT if [ -n "${netwait_if}" ]; then - echo "Waiting for interface $netwait_if to have link..." + echo -n "Waiting for $netwait_if to have link" count=1 while [ ${count} -le ${netwait_if_timeout} ]; do - output=`/sbin/ifconfig ${netwait_if}` - link=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'` - if [ -z "${link}" ]; then - echo "Interface has link." - break + if output=`/sbin/ifconfig ${netwait_if} 2>/dev/null`; then + link=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'` + if [ -z "${link}" ]; then + echo '.' + break + fi + else + echo '' + err 1 "ifconfig ${netwait_if} failed" fi sleep 1 count=$((count+1)) @@ -77,6 +82,7 @@ # Restore default SIGINT handler trap - SIGINT + echo '' warn "Interface still has no link. Continuing with startup, but" warn "be aware you may not have a fully functional networking" warn "layer at this point." @@ -88,7 +94,7 @@ trap break SIGINT for ip in ${netwait_ip}; do - echo "Waiting for ${ip} to respond to ICMP..." + echo -n "Waiting for ${ip} to respond to ICMP" count=1 while [ ${count} -le ${netwait_timeout} ]; do @@ -99,12 +105,12 @@ # Restore default SIGINT handler trap - SIGINT - echo "Host reachable; network considered available." + echo '.' return fi count=$((count+1)) done - echo "No response from host." + echo ': No response from host.' done # Restore default SIGINT handler --------------070506060802040508070901--