#! /bin/sh # # This is an init script for openembedded # Copy it to /etc/init.d/openldap and type # > update-rc.d openldap defaults 60 # slapd=%LIBEXEC%/slapd test -x "$slapd" || exit 0 src_data_dir=/etc/openldap/ data_dir=%LDAP_DATADIR% pidfile=%LDAP_DATADIR%/slapd.pid start() { need_init=0 if [ ! -e $data_dir/DB_CONFIG ]; then mkdir -p $data_dir cp $src_data_dir/DB_CONFIG.example $data_dir/DB_CONFIG need_init=1 fi echo -n "Starting OpenLDAP: " start-stop-daemon --start --quiet --exec $slapd echo "." if [ $need_init -eq 1 ]; then sleep 1 ldapadd -x -D "cn=Manager,%DEFAULT_DN%" -w secret -f /etc/openldap/ops-base.ldif -c fi } stop() { echo -n "Stopping OpenLDAP: " start-stop-daemon --stop --quiet --pidfile $pidfile echo "." } case "$1" in start) start ;; stop) stop ;; reset) stop sleep 1 rm $data_dir/* start ;; restart) stop start ;; *) echo "Usage: /etc/init.d/openldap {start|stop|reset|restart|reset}" exit 1 esac exit 0