integ/ldap/nss-pam-ldapd/files/nslcd.init

110 lines
3.4 KiB
Bash
Executable File

#! /bin/sh
# /etc/init.d/nslcd script for starting and stopping nslcd
# Copyright (C) 2006 West Consulting
# Copyright (C) 2006, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
### BEGIN INIT INFO
# Provides: nslcd
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog
# Should-Start: $named $network slapd
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: LDAP connection daemon
# Description: nslcd is a LDAP connection daemon that is used to
# do LDAP queries for the NSS and PAM modules.
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NSLCD_NAME=nslcd
NSLCD_BIN=/usr/sbin/$NSLCD_NAME
NSLCD_DESC="LDAP connection daemon"
NSLCD_CFG=/etc/nslcd.conf
NSLCD_STATEDIR=/var/run/nslcd
NSLCD_PIDFILE=$NSLCD_STATEDIR/nslcd.pid
[ -x "$NSLCD_BIN" ] || exit 0
[ -f "$NSLCD_CFG" ] || exit 0
. /lib/lsb/init-functions
# read defaults
[ -f /etc/default/$NSLCD_NAME ] && . /etc/default/$NSLCD_NAME
case "$1" in
start)
# set up state directory
[ -d "$NSLCD_STATEDIR" ] || ( mkdir -m 755 "$NSLCD_STATEDIR" ; \
chown nslcd:nslcd "$NSLCD_STATEDIR" )
# start nslcd
log_begin_msg "Starting $NSLCD_DESC" "$NSLCD_NAME"
# THIS IS ONLY TEMPORARY
create-cracklib-dict /usr/share/cracklib/cracklib-small > /dev/null 2>&1
start-stop-daemon --start --oknodo \
--pidfile $NSLCD_PIDFILE \
--startas $NSLCD_BIN
log_end_msg $?
;;
stop)
# stop nslcd
log_begin_msg "Stopping $NSLCD_DESC" "$NSLCD_NAME"
start-stop-daemon --stop --oknodo \
--pidfile $NSLCD_PIDFILE \
--name "$NSLCD_NAME"
log_end_msg $?
[ -n "$NSLCD_PIDFILE" ] && rm -f $NSLCD_PIDFILE
;;
restart|force-reload)
[ -d "$NSLCD_STATEDIR" ] || ( mkdir -m 755 "$NSLCD_STATEDIR" ; \
chown nslcd:nslcd "$NSLCD_STATEDIR" )
log_begin_msg "Restarting $NSLCD_DESC" "$NSLCD_NAME"
start-stop-daemon --stop --quiet --retry 10 \
--pidfile $NSLCD_PIDFILE \
--name "$NSLCD_NAME"
[ -n "$NSLCD_PIDFILE" ] && rm -f $NSLCD_PIDFILE
start-stop-daemon --start \
--pidfile $NSLCD_PIDFILE \
--startas $NSLCD_BIN
log_end_msg $?
;;
status)
if [ -f "$NSLCD_PIDFILE" ]
then
if $NSLCD_BIN --check
then
log_success_msg "$NSLCD_NAME running (pid `cat $NSLCD_PIDFILE`)"
exit 0
else
log_success_msg "$NSLCD_NAME stopped"
exit 1
fi
else
log_success_msg "$NSLCD_NAME stopped"
exit 3
fi
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0