On Tue, Apr 27, 2010 at 09:48:41AM +1000, Phil wrote:
> Jeremy, 
> A good proposal to improve start-up robustness. If I may suggest, 
> waitnetwork_ip should include a short list of alternate IP's in 
> the event of a local network outage, or DOS, etc.  Something like:
> waitnetwork_ip="IP1 IP2 IP3"
> 
> Having multiple target IP's will improve the likelihood of timely 
> booting when silly/nasty things happen on the wider network.
> 
> Good idea to have incorporated into the base system.

Phil,

I brought this point up in my post on -rc and -net, actually.  I've
since extended the script to support multiple IPs in $waitnetwork_ip
(wasn't that hard).  The logic is that if any of the IPs pass the ping
test, then the network connection is considered usable.

Attached is the modified script.  I'll be updating the version on my
server (HTTP) momentarily.

-- 
| Jeremy Chadwick                                   j...@parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |


#!/bin/sh
#
# $FreeBSD: $
#

# PROVIDE: waitnetwork
# REQUIRE: NETWORKING
# BEFORE: mountcritremote
# KEYWORD: nojail

# XXX - Once/if committed to base, it's better to have mountcritremote
# XXX - REQUIRE waitnetwork, rather than use the above BEFORE line.

. /etc/rc.subr

name="waitnetwork"
rc_var=`set_rcvar`

start_cmd="waitnetwork_start"
stop_cmd=":"

# XXX - Once/if committed to base, the following defaults should
# XXX - be placed into src/etc/defaults/rc.conf instead of here
# XXX - Also be sure to keep waitnetwork_ip="" commented out!

waitnetwork_enable="NO"         # Wait for network availability before
                                # continuing with NETWORKING rc scripts
#waitnetwork_ip=""              # IP address to ping
waitnetwork_count="5"           # ping count (see ping(8) -c flag)
waitnetwork_timeout="60"        # ping timeout (see ping(8) -t flag)

waitnetwork_start()
{
        local ip rc success

        success=0

        if [ -z "${waitnetwork_ip}" ]; then
                warn "You must define one or more IP addresses in 
waitnetwork_ip"
                return
        fi

        for ip in ${waitnetwork_ip}; do
                echo "Waiting for ${ip} to respond to ICMP..."

                if [ -z "${waitnetwork_timeout}" ]; then
                        /sbin/ping -c ${waitnetwork_count} ${ip} >/dev/null 2>&1
                        rc=$?
                else
                        info "Using timeout of ${waitnetwork_timeout} seconds"
                        /sbin/ping -t ${waitnetwork_timeout} -c 
${waitnetwork_count} ${ip} >/dev/null 2>&1
                        rc=$?
                fi

                if [ $rc -eq 0 ]; then
                        echo "Host reachable; network considered available."
                        return
                else
                        echo "No response from host."
                fi
        done

        echo "Exhausted IP list.  Continuing with startup, but be aware you may"
        echo "not have a fully functional networking layer at this point."
}

load_rc_config $name
run_rc_command "$1"
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to