aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorzi <zi@FreeBSD.org>2013-11-09 08:23:44 +0800
committerzi <zi@FreeBSD.org>2013-11-09 08:23:44 +0800
commitcee9850b97aaa164705784830fee0d8694f68606 (patch)
tree31491d9fd543dd05db2d0829ee9686c06d25f2f5 /net
parentf00b7ec1ac93b5fbb3bbd6c7a5b030734553ba12 (diff)
downloadfreebsd-ports-gnome-cee9850b97aaa164705784830fee0d8694f68606.tar.gz
freebsd-ports-gnome-cee9850b97aaa164705784830fee0d8694f68606.tar.zst
freebsd-ports-gnome-cee9850b97aaa164705784830fee0d8694f68606.zip
- Add supervision support
- Bump PORTREVISION
Diffstat (limited to 'net')
-rw-r--r--net/nss-pam-ldapd/Makefile1
-rw-r--r--net/nss-pam-ldapd/files/nslcd.in80
-rw-r--r--net/nss-pam-ldapd/files/pkg-message.in5
3 files changed, 67 insertions, 19 deletions
diff --git a/net/nss-pam-ldapd/Makefile b/net/nss-pam-ldapd/Makefile
index fcb6a46c2815..c835b7ffb047 100644
--- a/net/nss-pam-ldapd/Makefile
+++ b/net/nss-pam-ldapd/Makefile
@@ -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/
diff --git a/net/nss-pam-ldapd/files/nslcd.in b/net/nss-pam-ldapd/files/nslcd.in
index dffad8c63cf2..a46c8073482c 100644
--- a/net/nss-pam-ldapd/files/nslcd.in
+++ b/net/nss-pam-ldapd/files/nslcd.in
@@ -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
+}
-command="%%PREFIX%%/sbin/${name}"
-pidfile="/var/run/${name}.pid"
-start_precmd="nslcd_prestart"
-start_postcmd="nslcd_poststart"
+nslcd_start()
+{
+ nslcd_findpid
+ if [ ! ${mypid} = '' ]; then
+ echo "${name} is running with PID ${mypid}.";
+ else
+ echo "Starting ${name}."
+ ${command} ${command_args}
+ fi
+}
-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"
diff --git a/net/nss-pam-ldapd/files/pkg-message.in b/net/nss-pam-ldapd/files/pkg-message.in
index 1ee966771a3a..dbde6dcf7290 100644
--- a/net/nss-pam-ldapd/files/pkg-message.in
+++ b/net/nss-pam-ldapd/files/pkg-message.in
@@ -8,5 +8,10 @@ To start nslcd add nslcd_enable="YES" to /etc/rc.conf and run:
# 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.
=====================================================================