From owner-freebsd-current@FreeBSD.ORG Sun Nov 4 17:41:10 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E4BD16A419 for ; Sun, 4 Nov 2007 17:41:10 +0000 (UTC) (envelope-from askbill@conducive.net) Received: from conducive.net (conducive.net [203.194.153.81]) by mx1.freebsd.org (Postfix) with ESMTP id 350E913C4B7 for ; Sun, 4 Nov 2007 17:41:10 +0000 (UTC) (envelope-from askbill@conducive.net) Received: from cm218-253-81-177.hkcable.com.hk ([218.253.81.177]:60347 helo=pb.local) by conducive.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1IojSp-000LCr-AE for freebsd-current@freebsd.org; Sun, 04 Nov 2007 17:40:47 +0000 Message-ID: <472E041D.3090801@conducive.net> Date: Sun, 04 Nov 2007 12:40:45 -0500 From: =?UTF-8?B?6Z+T5a625qiZIEJpbGwgSGFja2Vy?= User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.2) Gecko/20070221 SeaMonkey/1.1.1 MIME-Version: 1.0 To: freebsd-current@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] Overriding rc.conf in loader X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Nov 2007 17:41:10 -0000 Marcin Wisnicki wrote: > Hi > > I thought it would be nice if there was a way to override rc.conf > variables during boot. Proposed patch implements this using kenv. > > With it, you can override any rc variable from loader.conf by prefixing > its name with 'rc.', some useful examples: > > # disable gdm > set rc.gdm_enable=no > > # start only base scripts > set rc.local_startup= > > # alternative rc.conf > set rc.rc_conf_files=/etc/rc.conf.safe > > I find it often more convenient than booting into single-user, remounting > rw and editing conf files. > > If it's worth committing I can try to update rc.conf(5) & loader(8) manuals. > Pardon my stupidity... but does this over-ride over rides with other over rides... or what? ..and if so, ISTR there may be a better way already... > > --- rc.subr.orig 2007-11-03 22:36:43.000000000 +0100 > +++ rc.subr 2007-11-04 16:19:46.000000000 +0100 > @@ -901,6 +901,7 @@ > # > load_rc_config() > { > + local kvar > _name=$1 > if [ -z "$_name" ]; then > err 3 'USAGE: load_rc_config name' > @@ -912,6 +913,10 @@ > if [ -r /etc/defaults/rc.conf ]; then > debug "Sourcing /etc/defaults/rc.conf" > . /etc/defaults/rc.conf > + debug "Trying to override rc_conf_files with kenv" > + if kenv -q rc.rc_conf_files > /dev/null; then > + rc_conf_files="$(kenv rc.rc_conf_files)" > + fi > source_rc_confs > elif [ -r /etc/rc.conf ]; then > debug "Sourcing /etc/rc.conf (/etc/defaults/rc.conf doesn't exist)." > @@ -923,6 +928,17 @@ > debug "Sourcing /etc/rc.conf.d/${_name}" > . /etc/rc.conf.d/"$_name" > fi > + debug "Applying boot-time overrides of rc.conf" > + _IFS=$IFS > + IFS=${IFS#??} > + for kvar in $(kenv); do > + case "$kvar" in > + rc.*) > + eval "${kvar#rc.}" > + ;; > + esac > + done > + IFS=$_IFS > } > > # > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >