Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Oct 2002 16:03:00 -0500 (CDT)
From:      "Scot W. Hetzel" <hetzels@westbend.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/43671: RC_NG script for net/openldap2
Message-ID:  <200210042103.g94L30d2030726@WBIw009.westbend.net>

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

>Number:         43671
>Category:       ports
>Synopsis:       RC_NG script for net/openldap2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 04 14:10:04 PDT 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 #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:
>Unformatted:

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




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