Baptiste Daroussin <b...@freebsd.org> wrote
  in <201408262233.s7qmxyfd056...@svn.freebsd.org>:

ba> Author: bapt
ba> Date: Tue Aug 26 22:33:34 2014
ba> New Revision: 270676
ba> URL: http://svnweb.freebsd.org/changeset/base/270676
ba>
ba> Log:
ba>   Allow to configure services from ${LOCALBASE}/etc/rc.conf.d
ba>
ba>   Reviewed by:      bdrewery
ba>   MFC after:        1 week
ba>   Relnotes: yes
ba>
ba> Modified:
ba>   head/etc/rc.subr
ba>
ba> Modified: head/etc/rc.subr
ba> 
==============================================================================
ba> --- head/etc/rc.subr        Tue Aug 26 22:20:02 2014        (r270675)
ba> +++ head/etc/rc.subr        Tue Aug 26 22:33:34 2014        (r270676)
ba> @@ -1301,6 +1301,10 @@ load_rc_config()
ba>                     fi
ba>             done
ba>     fi
ba> +   if [ -f ${LOCALBASE:-/usr/local}/etc/rc.conf.d/"$_name" ]; then
ba> +           debug "Sourcing ${LOCALBASE:-/usr/local}/etc/rc.conf.d/${_name}"
ba> +           . ${LOCALBASE:-/usr/local}/etc/rc.conf.d/"$_name"
ba> +   fi

 This should hornor ${local_startup} instead of ${LOCALBASE} since it
 is not used in rc(8), and should be compatible with DES's commit in
 r270392.

 How about the attached patch?

-- Hiroki
Index: etc/rc.subr
===================================================================
--- etc/rc.subr	(revision 270695)
+++ etc/rc.subr	(working copy)
@@ -1270,7 +1270,7 @@
 #
 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,23 +1289,22 @@
 		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"
-	elif [ -d /etc/rc.conf.d/"$_name" ] ; then
-		local _rc
-		for _rc in /etc/rc.conf.d/"$_name"/* ; do
-			if [ -f "$_rc" ] ; then
-				debug "Sourcing $_rc"
-				. "$_rc"
-			fi
-		done
-	fi
-	if [ -f ${LOCALBASE:-/usr/local}/etc/rc.conf.d/"$_name" ]; then
-		debug "Sourcing ${LOCALBASE:-/usr/local}/etc/rc.conf.d/${_name}"
-		. ${LOCALBASE:-/usr/local}/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
 		eval _defval=\$${_var}_defval

Attachment: pgppoSn81jY_8.pgp
Description: PGP signature

Reply via email to