Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2002 18:21:06 -0600 (CST)
From:      "Scot W. Hetzel" <hetzels@westbend.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Gordon <gordon@FreeBSD.org>
Subject:   conf/44800: RC_NG for local rc scripts
Message-ID:  <200211010021.gA10L6vR007899@WBIw009.westbend.net>

next in thread | raw e-mail | index | archive | help

>Number:         44800
>Category:       conf
>Synopsis:       RC_NG for local rc scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 31 16:30:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Scot W. Hetzel
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
West Bend Internet
>Environment:
System: FreeBSD Current.westbend.net 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Sat Oct 26 19:44:41 CDT 2002     root@Current.westbend.net:/usr/obj/usr/src/srcC/sys/GENERIC-SMP  i386

>Description:

I have converted several ports rc scripts to RC_NG, but I noticed
that load_rc_config could only read configuration files from /etc.
Attached is a patch that adds load_local_rc_config to /etc/rc.subr.
With this patch, ports scripts can read their configuration from
the following files and listed order:

    ${prefix}/etc/rc.conf.d/<name>
    /etc/default/rc.conf
    /etc/rc.conf
    /etc/rc.conf.d/<name>

I have submitted the folowing ports PRs with rc.d scripts that support
both 5.0-CURRENT and *-STABLE.

    PR 43667    mail/cyrus_imapd
    PR 43668    mail/cyrus_imapd2
    PR 43669    databases/mysql323-{server,client}
    PR 43670    net/openldap
    PR 43671    net/openldap2
    PR 43672    security/cyrus-sasl
    PR 43673    security/cyrus-sasl2
    PR 43681    www/apache13-fp

Currently, these rc.d scripts are using a different method to read their
configuration information from ${prefix}/etc/rc.conf.d/<name>.

>How-To-Repeat:
>Fix:

Attached are patchs for rc.subr and mtree/BSD.local.dist

NOTE: BSD.local.dist should be MFC'd to STABLE.

Index: rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.6
diff -u -r1.6 rc.subr
--- rc.subr	12 Sep 2002 17:27:36 -0000	1.6
+++ rc.subr	31 Oct 2002 22:12:13 -0000
@@ -833,6 +833,48 @@
 }
 
 #
+# load_local_rc_config
+# 	Source in the configuration file for a given local command.
+#
+#       The following globals are used:
+#
+#	Name		Needed	Purpose
+#	----		------	-------
+#	prefix		y	Base directory that script is located in (i.e /usr/local)
+#
+#	rcvar		n	Name of variable used to enable the service.
+#
+load_local_rc_config()
+{
+	_command=$1
+	if [ -z "$_command" ]; then
+		err 3 "USAGE: load_local_rc_config command"
+	fi
+
+	if [ -z "$prefix" ]; then
+		err 3 'load_local_rc_config: $prefix is not set.'
+	fi
+
+	if [ -f ${prefix}/etc/rc.conf.d/"$_command" ]; then
+                debug "Sourcing ${prefix}/etc/rc.conf.d/${_command}"
+                . ${prefix}/etc/rc.conf.d/"$_command"
+        fi
+
+	# Let either /etc/rc.conf or /etc/rc.conf.d/"$_command"
+	# override ${prefix}/etc/rc.conf.d/"$_command"
+	load_rc_config $_command
+
+	# Used for compatibilty with old behavior for local rc scripts.
+	if [ -n "$rcvar" ]; then
+		eval _value=\$${rcvar}
+		if [ -z "${_value}" ]; then
+			debug "load_local_rc_config: setting ${rcvar} to YES"
+			eval ${rcvar}=YES
+		fi
+	fi
+}
+
+#
 # rc_usage commands
 #	Print a usage string for $0, with `commands' being a list of
 #	valid commands.
Index: BSD.local.dist
===================================================================
RCS file: /home/ncvs/src/etc/mtree/BSD.local.dist,v
retrieving revision 1.92
diff -u -r1.92 BSD.local.dist
--- BSD.local.dist	25 Oct 2002 22:00:34 -0000	1.92
+++ BSD.local.dist	31 Oct 2002 19:51:06 -0000
@@ -10,6 +10,8 @@
     etc
         pam.d
         ..
+        rc.conf.d
+        ..
         rc.d
         ..
     ..
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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