From owner-freebsd-stable@FreeBSD.ORG Tue Apr 27 13:54:47 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E9811065670 for ; Tue, 27 Apr 2010 13:54:47 +0000 (UTC) (envelope-from jamesbrandongooch@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 40DC58FC08 for ; Tue, 27 Apr 2010 13:54:47 +0000 (UTC) Received: by pwi9 with SMTP id 9so9537003pwi.13 for ; Tue, 27 Apr 2010 06:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=pPLL2L91TS8x90+0DdSv4WvrhuaMmTdjck5QoihSgcY=; b=R9tJMumhDFBrBKAOWohSnTdaVo6hEA8g8xAKs5TGxYoVXL8g7hvM1NAF09RIqtGOUX 06JkzRaSN1P/Z9GPC8+HnOryC8jZYa0wN6qoQ3yFMzdUogoLBJPcXu35Qo1iBsvxwif5 A34csj4OL1lu2toXlBF3yJf3fxE4fceC4mPEA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=jwyvws0IraLbXojuQZtoFgiIHL4ixrgy6cqX+N/m7Rp9HcKFTfn7iFtyc4vWaJ+SPP 0GEysrieCyXS+KXB+9NCPaGRugF9fWYytOITHKj0ZctDcUrtq2mFoufe6eviO1PssAkH jI/RSd5xpQCQ9ORaUnZIP1hQmQTQq/nfIKsM0= MIME-Version: 1.0 Received: by 10.114.18.4 with SMTP id 4mr6636941war.186.1272376478642; Tue, 27 Apr 2010 06:54:38 -0700 (PDT) Received: by 10.231.113.36 with HTTP; Tue, 27 Apr 2010 06:54:38 -0700 (PDT) In-Reply-To: <20100427030244.GA70237@icarus.home.lan> References: <20100418213727.GA98129@icarus.home.lan> <20100427030244.GA70237@icarus.home.lan> Date: Tue, 27 Apr 2010 08:54:38 -0500 Message-ID: From: Brandon Gooch To: Jeremy Chadwick Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-stable@freebsd.org, Phil Subject: Re: rc(8) script -- waiting for the network to become usable X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 13:54:47 -0000 On Mon, Apr 26, 2010 at 10:02 PM, Jeremy Chadwick wrote: > 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. =A0Something like: >> waitnetwork_ip=3D"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. =A0I've > since extended the script to support multiple IPs in $waitnetwork_ip > (wasn't that hard). =A0The logic is that if any of the IPs pass the ping > test, then the network connection is considered usable. > > Attached is the modified script. =A0I'll be updating the version on my > server (HTTP) momentarily. > > -- > | Jeremy Chadwick =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 jdc@parodius.com | > | Parodius Networking =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 http://= www.parodius.com/ | > | UNIX Systems Administrator =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Mountain = View, CA, USA | > | Making life hard for others since 1977. =A0 =A0 =A0 =A0 =A0 =A0 =A0PGP:= 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=3D"waitnetwork" > rc_var=3D`set_rcvar` > > start_cmd=3D"waitnetwork_start" > stop_cmd=3D":" > > # 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=3D"" commented out! > > waitnetwork_enable=3D"NO" =A0 =A0 =A0 =A0 # Wait for network availability= before > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# continui= ng with NETWORKING rc scripts > #waitnetwork_ip=3D"" =A0 =A0 =A0 =A0 =A0 =A0 =A0# IP address to ping > waitnetwork_count=3D"5" =A0 =A0 =A0 =A0 =A0 # ping count (see ping(8) -c = flag) > waitnetwork_timeout=3D"60" =A0 =A0 =A0 =A0# ping timeout (see ping(8) -t = flag) > > waitnetwork_start() > { > =A0 =A0 =A0 =A0local ip rc success > > =A0 =A0 =A0 =A0success=3D0 > > =A0 =A0 =A0 =A0if [ -z "${waitnetwork_ip}" ]; then > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0warn "You must define one or more IP addre= sses in waitnetwork_ip" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return > =A0 =A0 =A0 =A0fi > > =A0 =A0 =A0 =A0for ip in ${waitnetwork_ip}; do > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo "Waiting for ${ip} to respond to ICMP= ..." > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if [ -z "${waitnetwork_timeout}" ]; then > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/sbin/ping -c ${waitnetwor= k_count} ${ip} >/dev/null 2>&1 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rc=3D$? > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0info "Using timeout of ${w= aitnetwork_timeout} seconds" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/sbin/ping -t ${waitnetwor= k_timeout} -c ${waitnetwork_count} ${ip} >/dev/null 2>&1 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rc=3D$? > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fi > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if [ $rc -eq 0 ]; then > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo "Host reachable; netw= ork considered available." > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo "No response from hos= t." > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fi > =A0 =A0 =A0 =A0done > > =A0 =A0 =A0 =A0echo "Exhausted IP list. =A0Continuing with startup, but b= e aware you may" > =A0 =A0 =A0 =A0echo "not have a fully functional networking layer at this= point." > } > > load_rc_config $name > run_rc_command "$1" Not to hijack the thread, but this type of clean, quality work (even though some consider it a hack), really helps a lot of people out. I wonder, has anyone ever brought up the idea of an "rc repository" or something similar, for rc scripts and/or configs that may help many, but for whatever reason, will not be included in the base system? I'm thinking of something more "official", hosted at the freebsd.org domain. Maybe in the same vein as: http://www.sun.com/bigadmin/home/index.jsp Shields up, -Brandon