ldapdock/start-slapd.sh
2025-10-26 14:49:26 -04:00

24 lines
817 B
Bash

#!/bin/bash
# --- 1. Start slapd in the background (This is the critical part you asked about) ---
echo "Starting slapd service..."
# The user's desired slapd command, running in the background (&)
/usr/sbin/slapd -h "ldap:/// ldapi:///" -g openldap -u openldap -F /etc/ldap/slapd.d &
# Wait briefly for the service to start
sleep 3
# Check if slapd started successfully
SLAPD_PID=$!
if kill -0 $SLAPD_PID 2>/dev/null; then
echo "OpenLDAP slapd service started successfully with PID: $SLAPD_PID"
else
echo "OpenLDAP slapd already running with PID: $SLAPD_PID"
fi
# --- 2. Execute the command passed to the container ---
# 'exec' replaces the script process with the command (e.g., /bin/bash),
# ensuring the container stays alive as long as that command runs interactively.
echo "Executing: $@"
exec "$@"