From owner-freebsd-questions@FreeBSD.ORG Sat Dec 6 03:06:46 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D0BC1065672 for ; Sat, 6 Dec 2008 03:06:46 +0000 (UTC) (envelope-from fbsd06+4L=b1d1037e@mlists.homeunix.com) Received: from fallback-in1.mxes.net (fallback-out1.mxes.net [216.86.168.190]) by mx1.freebsd.org (Postfix) with ESMTP id CCE408FC0A for ; Sat, 6 Dec 2008 03:06:45 +0000 (UTC) (envelope-from fbsd06+4L=b1d1037e@mlists.homeunix.com) Received: from mxout-03.mxes.net (mxout-03.mxes.net [216.86.168.178]) by fallback-in1.mxes.net (Postfix) with ESMTP id 39230164883 for ; Fri, 5 Dec 2008 21:50:41 -0500 (EST) Received: from gumby.homeunix.com (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id 6427B23E3F7 for ; Fri, 5 Dec 2008 21:50:39 -0500 (EST) Date: Sat, 6 Dec 2008 02:50:36 +0000 From: RW To: freebsd-questions@freebsd.org Message-ID: <20081206025036.3ceba57b@gumby.homeunix.com> In-Reply-To: <4939C33A.8070108@cordula.ws> References: <560f92640811211647q551daccnaec4e8085bb8e042@mail.gmail.com> <20081205190703.0dfb952d@gumby.homeunix.com> <4939C33A.8070108@cordula.ws> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.11; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: named and ntpd start order in rc.d X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2008 03:06:46 -0000 On Sat, 06 Dec 2008 01:11:38 +0100 cpghost wrote: > RW wrote: > > I have a similar issue with PPP not having connected by the time > > ntpdate runs , so I just have a script that runs between named and > > ntpdate, and blocks waiting for access. > > > Those timing / start-order issues are getting more and more > annoying, IMHO. On my PPPoE / mpd5 connected systems, > it's the same problem: > * openntpd (from ports) can't start, because named is not ready > * pf can't parse /etc/pf.conf because the ng0 interface is not yet > there etc, etc, etc... > > Isn't there a generic way to delay some scripts from starting > until a specific subset is ready (say: networking fully up, > and named ready to reply)? Perhaps some keyword or class > to add to a startup script would be nice to have! I don't think there's a generic solution, but I've pasted my own script below, I think if you set "networkwait_ping_hosts" to a name, rather than IP addresses, it might solve both your problems. You'll be polling on dns, and then resyncing the pf rules. $ cat /usr/local/etc/rc.d/networkwait #!/bin/sh # # PROVIDE: networkwait # REQUIRE: named # BEFORE: ntpdate . /etc/rc.subr networkwait_enable=${networkwait_enable:-"NO"} name="networkwait" rcvar=`set_rcvar` stop_cmd=":" start_cmd="networkwait_start" networkwait_start(){ if [ "$networkwait_ping_hosts" ] ; then host_list="${networkwait_ping_hosts}" else # No hosts supplied - use external nameservers host_list=`awk '/^ *nameserver/ {print $2} '< /etc/resolv.conf | grep -E -v '^127\.0+\.0+\.0*1'` fi echo -n "Waiting for network access ... " while true ; do for inet_host in $host_list ; do if ping -nc1 $inet_host 2>&1 > /dev/null ; then echo "ping to ${inet_host} succeeded." # Re-Sync ipfilter and pf in case # they had failed DNS lookups /etc/rc.d/ipfilter resync /etc/rc.d/pf resync exit 0 fi done sleep 5 done } load_rc_config ${name} run_rc_command "$1"