From owner-freebsd-current@FreeBSD.ORG Sun Nov 4 17:13:44 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 638BB16A41A for ; Sun, 4 Nov 2007 17:13:44 +0000 (UTC) (envelope-from freebsd-current@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id 1BC3D13C4A8 for ; Sun, 4 Nov 2007 17:13:43 +0000 (UTC) (envelope-from freebsd-current@m.gmane.org) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1Ioi30-0002ot-BX for freebsd-current@freebsd.org; Sun, 04 Nov 2007 16:10:02 +0000 Received: from xdsl-10260.wroclaw.dialog.net.pl ([84.40.242.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Nov 2007 16:10:02 +0000 Received: from mwisnicki+freebsd by xdsl-10260.wroclaw.dialog.net.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Nov 2007 16:10:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org From: Marcin Wisnicki Date: Sun, 4 Nov 2007 16:08:30 +0000 (UTC) Lines: 62 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: xdsl-10260.wroclaw.dialog.net.pl User-Agent: Pan/0.131 (Ghosts: First Variation) Sender: news Subject: [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:13:44 -0000 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. --- 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 } #