From owner-freebsd-stable@FreeBSD.ORG Tue Feb 1 14:28:54 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 EEBB81065774 for ; Tue, 1 Feb 2011 14:28:54 +0000 (UTC) (envelope-from ml@my.gd) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9B1C98FC0A for ; Tue, 1 Feb 2011 14:28:53 +0000 (UTC) Received: by wyf19 with SMTP id 19so6991023wyf.13 for ; Tue, 01 Feb 2011 06:28:52 -0800 (PST) Received: by 10.227.157.205 with SMTP id c13mr7678304wbx.136.1296570532117; Tue, 01 Feb 2011 06:28:52 -0800 (PST) Received: from dfleuriot.local ([83.167.62.196]) by mx.google.com with ESMTPS id f35sm16109158wbf.8.2011.02.01.06.28.51 (version=SSLv3 cipher=RC4-MD5); Tue, 01 Feb 2011 06:28:51 -0800 (PST) Message-ID: <4D4818A2.9030901@my.gd> Date: Tue, 01 Feb 2011 15:28:50 +0100 From: Damien Fleuriot User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: freebsd-stable@freebsd.org References: <20110201123506.GA97242@fbsd.t60.cpu> In-Reply-To: <20110201123506.GA97242@fbsd.t60.cpu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 14:28:55 -0000 On 2/1/11 1:35 PM, 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 > > My question is, how to achieve what I want? The simpler, the better :) > You may want to call an external script directly from rc.local instead, to avoid breaking stuff that parses rc.conf Never know ;) It's not like rc.conf is a totally critical file that will break your startup if you mess it up...