rc(8) script -- waiting for the network to become usable
Doug Barton
dougb at FreeBSD.org
Sat Jun 5 04:19:52 UTC 2010
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/
-------------- next part --------------
--- 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
More information about the freebsd-rc
mailing list