From owner-freebsd-bugs Thu Oct 31 16:30: 7 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 170D437B401 for ; Thu, 31 Oct 2002 16:30:03 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08D0843E7B for ; Thu, 31 Oct 2002 16:30:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gA10U1x3087927 for ; Thu, 31 Oct 2002 16:30:01 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gA10U1em087926; Thu, 31 Oct 2002 16:30:01 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 689B037B401; Thu, 31 Oct 2002 16:21:22 -0800 (PST) Received: from mail.westbend.net (ns1.westbend.net [216.47.253.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C2A243E8A; Thu, 31 Oct 2002 16:21:21 -0800 (PST) (envelope-from hetzels@WBIw009.westbend.net) Received: from WBIw009.westbend.net (wbiw009 [216.47.253.29]) by mail.westbend.net (8.12.5/8.12.5) with ESMTP id gA10L71U086725; Thu, 31 Oct 2002 18:21:08 -0600 (CST) (envelope-from hetzels@WBIw009.westbend.net) Received: from WBIw009.westbend.net (localhost [127.0.0.1]) by WBIw009.westbend.net (8.12.6/8.12.6) with ESMTP id gA10L743007900; Thu, 31 Oct 2002 18:21:07 -0600 (CST) (envelope-from hetzels@WBIw009.westbend.net) Received: (from root@localhost) by WBIw009.westbend.net (8.12.6/8.12.6/Submit) id gA10L6vR007899; Thu, 31 Oct 2002 18:21:06 -0600 (CST) Message-Id: <200211010021.gA10L6vR007899@WBIw009.westbend.net> Date: Thu, 31 Oct 2002 18:21:06 -0600 (CST) From: "Scot W. Hetzel" Reply-To: "Scot W. Hetzel" To: FreeBSD-gnats-submit@FreeBSD.org Cc: Gordon X-Send-Pr-Version: 3.113 Subject: conf/44800: RC_NG for local rc scripts Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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/ /etc/default/rc.conf /etc/rc.conf /etc/rc.conf.d/ 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/. >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