svn commit: r290009 - stable/10/etc

Dag-Erling Smørgrav des at FreeBSD.org
Mon Oct 26 15:20:46 UTC 2015


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


More information about the svn-src-all mailing list