From d656cd46500c774d33df7f4e54189b158ed80bd3 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 26 Oct 2015 15:20:45 +0000 Subject: [PATCH] MFH (r275359, r290007): make load_rc_config's name argument optional git-svn-id: svn://svn.freebsd.org/base/stable/10@290009 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/rc.subr | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/etc/rc.subr b/etc/rc.subr index 6534f6858..37ca95ea2 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1308,16 +1308,15 @@ run_rc_script() } # -# load_rc_config name -# Source in the configuration file for a given name. +# load_rc_config [service] +# Source in the configuration file(s) for a given service. +# If no service is specified, only the global configuration +# file(s) will be loaded. # load_rc_config() { local _name _rcvar_val _var _defval _v _msg _new _d _name=$1 - if [ -z "$_name" ]; then - err 3 'USAGE: load_rc_config name' - fi if ${_rc_conf_loaded:-false}; then : @@ -1333,20 +1332,24 @@ load_rc_config() _rc_conf_loaded=true 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 + # If a service name was specified, attempt to load + # service-specific configuration + if [ -n "$_name" ] ; then + 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 + fi # Set defaults if defined. for _var in $rcvar $rcvars; do -- 2.45.0