Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Feb 2011 21:29:53 +0800
From:      Yue Wu <vanopen@gmail.com>
To:        freebsd-stable@freebsd.org
Subject:   Re: Is /etc/rc.conf scriptable?
Message-ID:  <20110203132953.GA47155@fbsd.t60.cpu>
In-Reply-To: <20110201125710.GA81081@psconsult.nl>
References:  <20110201123506.GA97242@fbsd.t60.cpu> <20110201125710.GA81081@psconsult.nl>

index | next in thread | previous in thread | raw e-mail

Sorry for late reply. Thank you for all kindly and useful help!

On Tue, Feb 01, 2011 at 01:57:10PM +0100, Paul Schenkeveld wrote:
> 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.<interface>
> 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.

Thanks for detailed explanation, I get it, I think I should learn more
to get familiar with BSD's boot process before trying to do such
things by myself.

> 
> > 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,
Yue Wu

Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University
No.24, Tongjia Xiang Street, Nanjing 210009, China


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110203132953.GA47155>