Date: Sun, 04 Nov 2007 12:40:45 -0500 From: =?UTF-8?B?6Z+T5a625qiZIEJpbGwgSGFja2Vy?= <askbill@conducive.net> To: freebsd-current@freebsd.org Subject: Re: [PATCH] Overriding rc.conf in loader Message-ID: <472E041D.3090801@conducive.net> In-Reply-To: <fgkqpu$rhp$1@ger.gmane.org> References: <fgkqpu$rhp$1@ger.gmane.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?472E041D.3090801>