Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Nov 2013 00:23:45 +0000 (UTC)
From:      Ryan Steinmetz <zi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r333272 - in head/net/nss-pam-ldapd: . files
Message-ID:  <201311090023.rA90NjIY020672@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zi
Date: Sat Nov  9 00:23:44 2013
New Revision: 333272
URL: http://svnweb.freebsd.org/changeset/ports/333272

Log:
  - Add supervision support
  - Bump PORTREVISION

Modified:
  head/net/nss-pam-ldapd/Makefile
  head/net/nss-pam-ldapd/files/nslcd.in   (contents, props changed)
  head/net/nss-pam-ldapd/files/pkg-message.in   (contents, props changed)

Modified: head/net/nss-pam-ldapd/Makefile
==============================================================================
--- head/net/nss-pam-ldapd/Makefile	Sat Nov  9 00:11:00 2013	(r333271)
+++ head/net/nss-pam-ldapd/Makefile	Sat Nov  9 00:23:44 2013	(r333272)
@@ -3,6 +3,7 @@
 
 PORTNAME=		nss-pam-ldapd
 PORTVERSION=		0.8.13
+PORTREVISION=		1
 CATEGORIES=		net
 MASTER_SITES=		http://arthurdejong.org/nss-pam-ldapd/ \
     			http://mirrors.rit.edu/zi/

Modified: head/net/nss-pam-ldapd/files/nslcd.in
==============================================================================
--- head/net/nss-pam-ldapd/files/nslcd.in	Sat Nov  9 00:11:00 2013	(r333271)
+++ head/net/nss-pam-ldapd/files/nslcd.in	Sat Nov  9 00:23:44 2013	(r333272)
@@ -3,16 +3,14 @@
 # $FreeBSD$
 #
 # PROVIDE: nslcd
-# REQUIRE: ldconfig resolv
+# REQUIRE: NETWORKING ldconfig resolv
 # BEFORE: syslogd
+# KEYWORD: shutdown
 #
 # Add the following line to /etc/rc.conf to enable the nslcd daemon:
 #
 # nslcd_enable="YES"
 #
-# Optional:
-# nslcd_debug="NO" - start nslcd in debugging mode (does not daemonize).
-#
 
 . /etc/rc.subr
 
@@ -21,27 +19,71 @@ rcvar=nslcd_enable
 
 load_rc_config ${name}
 
-: ${nslcd_enable="NO"}
-: ${nslcd_debug="NO"}
+: ${nslcd_enable:=NO}
+: ${nslcd_supervisor=NO}
+
+command="/usr/sbin/daemon";
+start_precmd=nslcd_prestart
+start_cmd=nslcd_start
+status_cmd=nslcd_status
+stop_cmd=nslcd_stop
+
+nslcd_prestart()
+{
+	if checkyesno nslcd_supervisor ; then
+	    	notsupported=$(${command} -r 3>&1 1>&2 2>&3 | grep -c illegal)
+		if [ ${notsupported} -eq 0 ]; then
+			command_args="-f -r %%PREFIX%%/sbin/nslcd -d"
+		else
+		    	echo "Your FreeBSD version's daemon(8) does not support supervision.";
+			echo "${name} was not started.";
+			exit 1
+		fi
+	else
+		command_args="-f %%PREFIX%%/sbin/nslcd -d"
+	fi
+}
+
+nslcd_start()
+{
+	nslcd_findpid
+	if [ ! ${mypid} = '' ]; then
+		echo "${name} is running with PID ${mypid}.";
+	else
+		echo "Starting ${name}."
+		${command} ${command_args}
+	fi
+}
 
-command="%%PREFIX%%/sbin/${name}"
-pidfile="/var/run/${name}.pid"
-start_precmd="nslcd_prestart"
-start_postcmd="nslcd_poststart"
-
-nslcd_prestart () {
-	if checkyesno nslcd_debug
-	then
-		command_args="-d"
+nslcd_status()
+{
+	nslcd_findpid
+	if [ ! ${mypid} = '' ]; then
+		echo "${name} is running with PID ${mypid}.";
+	else
+		echo "${name} not running?";
 	fi
 }
 
-nslcd_poststart () {
-       until $(%%PREFIX%%/sbin/${name} -c); do
-               echo " Waiting for nslcd to start"
-               sleep 1
-       done
+nslcd_stop()
+{
+	nslcd_findpid
+	if [ ! ${mypid} = '' ]; then
+		echo "Stopping ${name}.";
+		kill -TERM ${mypid};
+		wait_for_pids ${mypid};
+	else
+		echo "${name} not running?";
+	fi
 }
 
+nslcd_findpid()
+{
+	if ! checkyesno nslcd_supervisor && $(%%PREFIX%%/sbin/nslcd -c && pgrep -F /var/run/nslcd.pid > /dev/null); then
+		mypid=$(cat /var/run/nslcd.pid) 
+	else
+		mypid=$(pgrep -f "daemon: %%PREFIX%%/sbin/nslcd")
+	fi
+}
 
 run_rc_command "$1"

Modified: head/net/nss-pam-ldapd/files/pkg-message.in
==============================================================================
--- head/net/nss-pam-ldapd/files/pkg-message.in	Sat Nov  9 00:11:00 2013	(r333271)
+++ head/net/nss-pam-ldapd/files/pkg-message.in	Sat Nov  9 00:23:44 2013	(r333272)
@@ -8,5 +8,10 @@ To start nslcd add nslcd_enable="YES" to
 
   # service nslcd start
 
+If you also want to supervise the nslcd daemon
+add nslcd_supervisor="YES" to rc.conf as well.
+
+NOTE: supervision requires FreeBSD 9.1 or greater.
+
 See the comments in %%PREFIX%%/etc/rc.d/nslcd for additional tunables.
 =====================================================================



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