From hetzels@WBIw009.westbend.net  Fri Oct  4 14:03:02 2002
Return-Path: <hetzels@WBIw009.westbend.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C282C37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  4 Oct 2002 14:03:02 -0700 (PDT)
Received: from mail.westbend.net (ns1.westbend.net [216.47.253.3])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 125A543E81
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  4 Oct 2002 14:03:02 -0700 (PDT)
	(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 g94L31rH057814
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 4 Oct 2002 16:03:01 -0500 (CDT)
	(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 g94L30J0030727
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 4 Oct 2002 16:03:00 -0500 (CDT)
	(envelope-from hetzels@WBIw009.westbend.net)
Received: (from root@localhost)
	by WBIw009.westbend.net (8.12.6/8.12.6/Submit) id g94L30d2030726;
	Fri, 4 Oct 2002 16:03:00 -0500 (CDT)
Message-Id: <200210042103.g94L30d2030726@WBIw009.westbend.net>
Date: Fri, 4 Oct 2002 16:03:00 -0500 (CDT)
From: "Scot W. Hetzel" <hetzels@westbend.net>
Reply-To: "Scot W. Hetzel" <hetzels@westbend.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: RC_NG script for net/openldap20
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         43671
>Category:       ports
>Synopsis:       RC_NG script for net/openldap20
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 04 14:10:04 PDT 2002
>Closed-Date:    Sat Aug 16 22:03:42 PDT 2003
>Last-Modified:  Sat Aug 16 22:03:42 PDT 2003
>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 #5: Tue Sep 24 11:27:41 CDT 2002 root@Current.westbend.net:/usr/obj/usr/src/srcC/sys/GENERIC-SMP i386

>Description:
	While looking at the RC_NG scripts on 5.0-CURRENT, I looked at converting the ports
	rc startup scripts to RC_NG.  I decided to start with cyrus-imapd and the ports that
	it depends on (cyrus-sasl, openldap, openldap2, mysql323-client).

	To ensure compatibility with previous FreeBSD Releases, the rc scripts contain both
	the new RC_NG and pre RC_NG scripts.

>How-To-Repeat:

>Fix:

	Changed Files:
	    files/slapd.sh - Convert to RC_NG

Index: files/slapd.sh
===================================================================
RCS file: /home/ncvs/ports/net/openldap2/files/slapd.sh,v
retrieving revision 1.3
diff -u -r1.3 slapd.sh
--- files/slapd.sh	19 Sep 2002 21:49:55 -0000	1.3
+++ files/slapd.sh	4 Oct 2002 20:47:38 -0000
@@ -2,46 +2,112 @@
 #
 # $FreeBSD: ports/net/openldap2/files/slapd.sh,v 1.3 2002/09/19 21:49:55 ijliao Exp $
 
-slapd_program=@@PREFIX@@/libexec/slapd
+# PROVIDE: slapd
+# REQUIRE: DAEMON
+# KEYWORD: FreeBSD shutdown
+#
+# NOTE for FreeBSD 5.0+:
+# If you want this script to start with the base rc scripts copy
+# slapd.sh.sample to /etc/rc.d/slapd, otherwise copy it to slapd.sh
 
-# Uncomment one of the following:
+# Define the following slapd_* variables in one of the following:
+#       /etc/rc.conf
+#       /etc/rc.conf.d/slapd
+#       ${prefix}/etc/rc.conf.d/slapd
+#
+#       slapd_enable  - Set to YES to enable slapd
+#
+#       slapd_program - Path to slapd program
+#                       Default: ${prefix}/libexec/slapd
+#
+#	slapd_flags    - Additional arguments to slapd
+#
+# Place one of these in to either rc.conf or ../rc.conf.d/slapd
 #
 # IPv4 Only
-#slapd_args='-h ldap://0.0.0.0;'
+#slapd_flags='-h "ldap://0.0.0.0";'
 #
 # IPv6 and IPv4
-#slapd_ags='-h "ldap://[::] ldap://0.0.0.0";'
+#slapd_flags='-h "ldap://[::] ldap://0.0.0.0";'
 #
 # IPv6 Only
-#slapd_args='-h ldap://[::];'
+#slapd_flags='-h "ldap://[::]";'
 #
 #
-slapd_args=
 
-pidfile=/var/run/slapd.pid
+prefix=@@PREFIX@@
+
+if [ -f /etc/rc.subr ]; then
+
+	. /etc/rc.subr
+
+	name="slapd"
+	rcvar=`set_rcvar`
+	command="${prefix}/libexec/slapd"
+	pidfile=/var/run/slapd.pid
+	required_files="${prefix}/etc/openldap/slapd.conf ${prefix}/etc/openldap/ldap.conf"
+
+	# The below may be removed when load_local_rc_config is added to rc.subr
+
+	if [ -f ${prefix}/etc/rc.conf.d/"$name" ]; then
+		debug "Sourcing ${prefix}/etc/rc.conf.d/${name}"
+		. ${prefix}/etc/rc.conf.d/"$name"
+	fi
+
+	load_rc_config $name
+
+	if [ -z "${slapd_enable}" ] ; then
+		slapd_enable=yes
+	fi
+
+	# The above may be removed when load_local_rc_config is added to rc.subr
+	#
+	# load_local_rc_config $name
+	run_rc_command "$1"
+else
+	# Suck in the configuration variables.
+        if [ -z "${source_rc_confs_defined}" ]; then
+                if [ -r /etc/defaults/rc.conf ]; then
+                        . /etc/defaults/rc.conf
+                        source_rc_confs
+                elif [ -r /etc/rc.conf ]; then
+                        . /etc/rc.conf
+                fi
+        fi
+
+        if [ -f ${prefix}/etc/rc.conf.d/slapd" ]; then
+                . ${prefix}/etc/rc.conf.d/slapd}"
+        fi
+
+	if [ -z "${slapd_program}" ]; then
+		slapd_program=${prefix}/libexec/slapd
+	fi
+
+	pidfile=/var/run/slapd.pid
+
+	case "$1" in
+	start)
+	    if [ -x $slapd ]; then
+		echo -n ' slapd'
+		${slapd_program} ${slapd_flags}
 
-case "$1" in
-start)
-    if [ -x $slapd ]; then
-	echo -n ' slapd'
-	${slapd_program} ${slapd_args}
-
-    fi
-    ;;
-stop)
-    if [ -f $pidfile ]; then
-	kill `cat $pidfile`
-	telnet localhost ldap </dev/null >/dev/null 2>&1
-	echo -n ' slapd'
-	rm $pidfile
-    else
-	echo ' slapd: not running'
-    fi
-    ;;
-*)
-    echo "Usage: `basename $0` {start|stop}" >&2
-    exit 64
-    ;;
-esac
+	    fi
+	    ;;
+	stop)
+	    if [ -f $pidfile ]; then
+		kill `cat $pidfile`
+		telnet localhost ldap </dev/null >/dev/null 2>&1
+		echo -n ' slapd'
+		rm $pidfile
+	    else
+		echo ' slapd: not running'
+	    fi
+	    ;;
+	*)
+	    echo "Usage: `basename $0` {start|stop}" >&2
+	    exit 64
+	    ;;
+	esac
 
-exit 0
+	exit 0
+fi
>Release-Note:
>Audit-Trail:

From: kuriyama@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org, hetzels@westbend.net,
	eikemeier@fillmore-labs.com
Cc:  
Subject: Re: ports/43671: RC_NG script for net/openldap20
Date: Sat, 16 Aug 2003 23:49:27 +0900 (JST)

 Hi Oliver,
 
 What do you think about this PR?

From: "Scot W. Hetzel" <hetzels@westbend.net>
To: <freebsd-gnats-submit@FreeBSD.org>,
	<eikemeier@fillmore-labs.com>, <kuriyama@FreeBSD.org>
Cc:  
Subject: Re: ports/43671: RC_NG script for net/openldap20
Date: Sat, 16 Aug 2003 15:55:50 -0500

 From: <kuriyama@FreeBSD.org>
 > Hi Oliver,
 >
 > What do you think about this PR?
 >
 
 The RC_NG script PR's can be closed.  I found a better way of converting our
 scripts to RC_NG, by providing a port for rc.subr to be used on older
 systems.  This allows us to fully convert all the start-up scripts to RC_NG,
 instead of using a combined RC_OLD/RC_NG script. When all the scripts are
 converted to RC_NG, FreeBSD 5.1+ can be converted to use rc_order to order
 the PREFIX/etc/rc.d scripts.
 
 See the following PR's
 
 PR 54116 - New port sysutils/rc_subr + cyrus-sasl fully converted to RC_NG.
 PR 54352 - Conversion of rc scripts to RC_NG (freeradius, openldap*,
 radiusd-cistron, samba*)
 
 The following PRs can be closed:
 
     PR 44800    RC_NG for local rc scripts
     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
 
 Scot
 
State-Changed-From-To: open->closed 
State-Changed-By: kuriyama 
State-Changed-When: Sat Aug 16 22:03:32 PDT 2003 
State-Changed-Why:  
Originator's request.  See ports/43671. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43671 
>Unformatted:
