From owner-freebsd-stable@FreeBSD.ORG Thu Feb 3 13:30:07 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 C8658106566C for ; Thu, 3 Feb 2011 13:30:07 +0000 (UTC) (envelope-from vanopen@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8644B8FC08 for ; Thu, 3 Feb 2011 13:30:07 +0000 (UTC) Received: by iyb26 with SMTP id 26so1066177iyb.13 for ; Thu, 03 Feb 2011 05:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :organization:x-operating-system:user-agent; bh=NHu+qZRLc+BditkIzQUL1UJGC0mhuc1RvxQ+Wj42Ioc=; b=kchqZ4ozWBT5COeDc8SAoUp2eAHMW+jvb5srTJOxCQwg6k2jS524niJLTyokqJRxn3 8tDE34m8/Di9NSmNJiaRJYCCzecb28GkpTgRGej9sAzNkvENd4UNqDNEdAboZMr6kETw V5p4Lwf7vw3Y36oERzjff35efh/oV3GOqHMjE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:organization :x-operating-system:user-agent; b=XZtF5gXLH3J5xLSk4uAaLWb6jrFShm7ee7H+z2X/wWKmG5rX/PPM2mcjr0JAN+1/nv VMW5fBjOg5zaHWX+Z7FqROhv3EB8iH+On6e5oErJf7gdDi16o4nT6GLsVTu/di6HqUlo WqhdBhDrl0nWiiOoiTpSdr7rBqMrJqLUXpRg8= Received: by 10.42.167.6 with SMTP id q6mr12519472icy.466.1296739806929; Thu, 03 Feb 2011 05:30:06 -0800 (PST) Received: from fbsd.t60.cpu ([180.137.65.72]) by mx.google.com with ESMTPS id ca7sm646357icb.0.2011.02.03.05.30.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 05:30:06 -0800 (PST) Date: Thu, 3 Feb 2011 21:29:53 +0800 From: Yue Wu To: freebsd-stable@freebsd.org Message-ID: <20110203132953.GA47155@fbsd.t60.cpu> References: <20110201123506.GA97242@fbsd.t60.cpu> <20110201125710.GA81081@psconsult.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110201125710.GA81081@psconsult.nl> Organization: China Pharmaceutical University, Nanjing, China X-Operating-System: FreeBSD 8.2-PRERELEASE i386 User-Agent: Mutt/1.5.21 (2010-09-15) 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: Thu, 03 Feb 2011 13:30:08 -0000 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. > 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