Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Oct 2015 15:20:45 +0000 (UTC)
From:      =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r290009 - stable/10/etc
Message-ID:  <201510261520.t9QFKjjP010721@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: des
Date: Mon Oct 26 15:20:45 2015
New Revision: 290009
URL: https://svnweb.freebsd.org/changeset/base/290009

Log:
  MFH (r275359, r290007): make load_rc_config's name argument optional

Modified:
  stable/10/etc/rc.subr
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/rc.subr
==============================================================================
--- stable/10/etc/rc.subr	Mon Oct 26 15:16:27 2015	(r290008)
+++ stable/10/etc/rc.subr	Mon Oct 26 15:20:45 2015	(r290009)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510261520.t9QFKjjP010721>