#!/bin/bash # already INSIDE the container # 1. Start slapd in the background echo "Starting slapd service..." # slapd start 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 "$@"