From 1b9496716d6c8b542db3304a742378cddb1b7c48 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 8 Sep 2014 11:18:27 +0000 Subject: MFH (r270392, r270676, r270679, r270698): add support for subdirectories in rc.conf.d Approved by: re (glebius) --- etc/mtree/BSD.root.dist | 2 ++ etc/rc.subr | 21 ++++++++++++++++----- share/man/man5/rc.conf.5 | 23 +++++++++++++++++++++-- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index e3ca074..19409ce 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -58,6 +58,8 @@ .. ppp .. + rc.conf.d + .. rc.d .. security diff --git a/etc/rc.subr b/etc/rc.subr index b6172db..ff4e898 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1270,7 +1270,7 @@ run_rc_script() # load_rc_config() { - local _name _rcvar_val _var _defval _v _msg _new + local _name _rcvar_val _var _defval _v _msg _new _d _name=$1 if [ -z "$_name" ]; then err 3 'USAGE: load_rc_config name' @@ -1289,10 +1289,21 @@ load_rc_config() fi _rc_conf_loaded=true fi - if [ -f /etc/rc.conf.d/"$_name" ]; then - debug "Sourcing /etc/rc.conf.d/${_name}" - . /etc/rc.conf.d/"$_name" - fi + + for _d in /etc ${local_startup%*/rc.d}; do + if [ -f ${_d}/rc.conf.d/"$_name" ]; then + debug "Sourcing ${_d}/rc.conf.d/$_name" + . ${_d}/rc.conf.d/"$_name" + elif [ -d ${_d}/rc.conf.d/"$_name" ] ; then + local _rc + for _rc in ${_d}/rc.conf.d/"$_name"/* ; do + if [ -f "$_rc" ] ; then + debug "Sourcing $_rc" + . "$_rc" + fi + done + fi + done # Set defaults if defined. for _var in $rcvar; do diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index e05291d..ce1230e 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 15, 2014 +.Dd August 27, 2014 .Dt RC.CONF 5 .Os .Sh NAME @@ -63,18 +63,37 @@ The file is used to override settings in .Pa /etc/rc.conf for historical reasons. +.Pp In addition to .Pa /etc/rc.conf.local you can also place smaller configuration files for each .Xr rc 8 script in the .Pa /etc/rc.conf.d -directory, which will be included by the +directory or +.Ao Ar dir Ac Ns Pa /rc.conf.d +directories specified in +.Va local_startup , +which will be included by the .Va load_rc_config function. For jail configurations you could use the file .Pa /etc/rc.conf.d/jail to store jail specific configuration options. +If +.Va local_startup +contains +.Pa /usr/local/etc/rc.d +and +.Pa /opt/conf , +.Pa /usr/local/rc.conf.d/jail +and +.Pa /opt/conf/rc.conf.d/jail +will be loaded. +If +.Ao Ar dir Ac Ns Pa /rc.conf.d/ Ns Ao Ar name Ac +is a directory, +all of files in the directory will be loaded. Also see the .Va rc_conf_files variable below. -- cgit v1.1