summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2015-10-26 15:20:45 +0000
committerdes <des@FreeBSD.org>2015-10-26 15:20:45 +0000
commit582d35681a4d2ceee539e894e0183d3b4552aecf (patch)
treec571c4188b26f35bbebb2603851ea8830eab872f /etc
parentc62812877398840dae0ba74b03e9e6a43cc56fc5 (diff)
downloadFreeBSD-src-582d35681a4d2ceee539e894e0183d3b4552aecf.zip
FreeBSD-src-582d35681a4d2ceee539e894e0183d3b4552aecf.tar.gz
MFH (r275359, r290007): make load_rc_config's name argument optional
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.subr41
1 files changed, 22 insertions, 19 deletions
diff --git a/etc/rc.subr b/etc/rc.subr
index 6534f68..37ca95e 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
OpenPOWER on IntegriCloud