[PATCH] Overriding rc.conf in loader
韓家標 Bill Hacker
askbill at conducive.net
Sun Nov 4 09:41:10 PST 2007
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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
>
More information about the freebsd-current
mailing list