Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 04 Jun 2010 21:19:46 -0700
From:      Doug Barton <dougb@FreeBSD.org>
To:        Jeremy Chadwick <freebsd@jdc.parodius.com>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: rc(8) script -- waiting for the network to become usable
Message-ID:  <4C09D062.1010706@FreeBSD.org>
In-Reply-To: <20100603093357.GA1849@icarus.home.lan>
References:  <20100603020444.GL1875@rwpc12.mby.riverwillow.net.au> <20100603044530.GA93342@icarus.home.lan> <4C074C11.20807@FreeBSD.org> <20100603093357.GA1849@icarus.home.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C09D062.1010706>