From owner-freebsd-stable@FreeBSD.ORG Tue Feb 1 12:57:17 2011 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 2A4E71065673 for ; Tue, 1 Feb 2011 12:57:17 +0000 (UTC) (envelope-from freebsd@psconsult.nl) Received: from mx1.psconsult.nl (unknown [IPv6:2001:7b8:30f:e0::5059:ee8a]) by mx1.freebsd.org (Postfix) with ESMTP id D37428FC12 for ; Tue, 1 Feb 2011 12:57:16 +0000 (UTC) Received: from mx1.psconsult.nl (psc11.adsl.iaf.nl [80.89.238.138]) by mx1.psconsult.nl (8.14.4/8.14.4) with ESMTP id p11CvAvT081459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 1 Feb 2011 13:57:15 +0100 (CET) (envelope-from freebsd@psconsult.nl) Received: (from paul@localhost) by mx1.psconsult.nl (8.14.4/8.14.4/Submit) id p11CvAmd081458 for freebsd-stable@freebsd.org; Tue, 1 Feb 2011 13:57:10 +0100 (CET) (envelope-from freebsd@psconsult.nl) X-Authentication-Warning: mx1.psconsult.nl: paul set sender to freebsd@psconsult.nl using -f Date: Tue, 1 Feb 2011 13:57:10 +0100 From: Paul Schenkeveld To: freebsd-stable@freebsd.org Message-ID: <20110201125710.GA81081@psconsult.nl> References: <20110201123506.GA97242@fbsd.t60.cpu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110201123506.GA97242@fbsd.t60.cpu> User-Agent: Mutt/1.5.19 (2009-01-05) Subject: Re: Is /etc/rc.conf scriptable? 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, 01 Feb 2011 12:57:17 -0000 On Tue, Feb 01, 2011 at 08:35:06PM +0800, Yue Wu wrote: > Hi list, > > I'm trying to do something to make rc.conf can act conditionally > > What I want is: > > 1. List the wireless access points, > > grep if there is one which bssid is 'bb:bb:bb:bb:bb:bb', > > if there is, then set ifconfig_wlan0 to the value: > > "inet 192.168.1.111 netmask 255.255.255.0 WPA" > > 2. check if bitlbee has been installed, if so, then let bitlbee > service start. > > > So I tried with following settings in rc.conf, but all of them failed, > i.e., the networking can't be connected and bitlbee service doesn't > run. > > /etc/rc.conf > > if ifconfig wlan0 list scan 2>/dev/null | grep -q 'bb:bb:bb:bb:bb:bb' >/dev/null 2>&1; then > ifconfig_wlan0="inet 192.168.1.111 netmask 255.255.255.0 WPA" > fi > if [ -x /usr/local/sbin/bitlbee ]; then > bitlbee_enable="YES" > fi /etc/rc.conf is scriptable (unless you are also using a dashboard or other software that wants to interpret/update /etc/rc.conf). Your problem here is that rc.conf is read (and executed) before wlan0 gets created. After creation of an interface, /etc/start_if. is called, perhaps you could use that but keep in mind it's run just after creation of the interface so if you use it for wlan0 and need the output of a station scan you should use ifconfig wlan0 scan instead of ifconfig wlan0 list scan. This may take some time during which your boot process is stalled. > My question is, how to achieve what I want? The simpler, the better :) Otherwise, perhaps devd could help you to run your script asynchronously after wlan0 is created. Regards, Paul Schenkeveld