integ/ldap/openldap-config/files/initscript
slin14 822420e2d3 refactor openldap
Package openldap-config is added to config customized config file
of openldap.

Here is the customized change in slapd.service:
"
-After=syslog.target network-online.target
+Before=rsyncd.service
+After=network.target syslog-ng.target

-PIDFile=/var/run/openldap/slapd.pid
+PIDFile=/var/run/slapd.pid

-ExecStart=/usr/sbin/slapd -u ldap -h ${SLAPD_URLS} $SLAPD_OPTIONS
+ExecStart=/etc/init.d/openldap start
+ExecStop=/etc/init.d/openldap stop
+ExecReload=/etc/init.d/openldap restart
+RemainAfterExit=yes
"
Here is the customized change in slapd.sysconfig:
"
-#SLAPD_OPTIONS=""
+SLAPD_OPTIONS=""
"

Test:
Pass build and multi node deploy test. Confirmed related config
file is the same as before in deploy node.

Story: 2003768
Task: 26462
Depends-On: https://review.openstack.org/618440

Change-Id: I2559a8e43619449d6179ed913181052d653fa91d
Signed-off-by: slin14 <shuicheng.lin@intel.com>
2018-11-19 23:29:42 +08:00

101 lines
2.3 KiB
Bash
Executable File

#! /bin/sh
#
# This is an init script for openembedded
# Copy it to /etc/init.d/openldap and type
# > update-rc.d openldap defaults 60
#
. /etc/init.d/functions
################################################################################
# Wait for a process to stop running.
#
################################################################################
function wait_for_proc_stop()
{
PROGNAME=$1
TIMEOUT=${2:-"5"}
for I in $(seq 1 $TIMEOUT); do
PID=$(pidof $PROGNAME 2> /dev/null)
if [ $? -ne 0 ]; then
## already dead
return 0
fi
sleep 1
done
return 1
}
slapd=/usr/sbin/slapd
test -x "$slapd" || exit 0
RETVAL=0
case "$1" in
start)
echo -n "Starting SLAPD: "
if [ -f /etc/openldap/schema/cn=config.ldif ]; then
start-stop-daemon --start --oknodo --quiet --exec $slapd \
-- -F /etc/openldap/schema/
RETVAL=$?
else
start-stop-daemon --start --oknodo --quiet --exec $slapd
RETVAL=$?
fi
if [ $RETVAL -ne 0 ]; then
echo "Failed to start SLAPD."
exit $RETVAL
fi
# we need to start nscd service as part of this openldap
# init.d script since SM manages this as a service and both
# daemons should be running on a controller host
systemctl status nscd.service
if [ $? -ne 0 ]; then
echo -n "Starting NSCD: "
systemctl start nscd.service
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo "Failed to start NSCD."
exit $RETVAL
fi
fi
echo "."
;;
stop)
echo -n "Stopping NSCD: "
systemctl stop nscd.service
rm -f /var/run/nscd/nscd.pid
echo -n "Stopping SLAPD: "
start-stop-daemon --retry 60 --stop --oknodo --quiet --pidfile /var/run/slapd.pid
RETVAL=$?
wait_for_proc_stop $slapd 10
WRETVAL=$?
while [ $WRETVAL -eq 1 ]; do
killproc $slapd
wait_for_proc_stop $slapd 10
WRETVAL=$?
done
rm -f /var/run/slapd.pid
echo "."
;;
status)
status $slapd
[ $? -eq 0 ] || exit $?
systemctl status nscd.service
[ $? -eq 0 ] || exit $?
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/openldap {start|stop|status|restart}"
exit 1
esac
exit $RETVAL