Created
October 5, 2010 19:48
-
-
Save mbbx6spp/612203 to your computer and use it in GitHub Desktop.
Script to cleanup screwed up OpenLDAP installation. Seems to work after seeing following errors: bdb_db_open: database "dc=yourdomain,dc=local": db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2). backend_startup_one (type=bdb, suf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Appears to fix the following errors when running slaptest: | |
# bdb_db_open: database "dc=yourdomain,dc=local": db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2). | |
# backend_startup_one (type=bdb, suffix="dc=yourdomain,dc=local"): bi_db_open failed! (2) | |
# Assumes you have customized the following configuration files: | |
# - /etc/openldap/slapd.conf | |
# - /etc/openldap/ldap.conf | |
# Default settings are work on Red Hat based distros currently: | |
SERVICE_NAME=slapd | |
LDAP_LIB_DIR=/var/lib/ldap | |
LDAP_RUN_DIR=/var/run/openldap | |
LDAP_PID_FILE=${LDAP_RUN_DIR}/${SERVICE_NAME}.pid | |
LDAP_ARG_FILE=${LDAP_RUN_DIR}/${SERVICE_NAME}.args | |
LDAP_DATA_FILES="__db.001 __db.002 __db.003 __db.004 __db.005 __db.006 alock" | |
LDAP_USER=ldap | |
LDAP_GROUP=ldap | |
SYS_RUN_DIR=/var/run | |
SYS_PID_FILE=${SYS_RUN_DIR}/${SERVICE_NAME}.pid | |
# Start of execution flow | |
sudo service ${SERVICE_NAME} stop | |
# In case PID and args files aren't cleaned up by init script | |
if [ -f ${LDAP_PID_FILE} ]; then sudo -u ${LDAP_USER} rm ${LDAP_PID_FILE}; fi | |
if [ -f ${LDAP_ARG_FILE} ]; then sudo -u ${LDAP_USER} rm ${LDAP_ARG_FILE}; fi | |
if [ -f ${SYS_PID_FILE} ]; then sudo -u ${LDAP_USER} rm ${SYS_PID_FILE}; fi | |
# Remove screwed up BDB files from OpenLDAP data directory | |
for f in ${LDAP_DATA_FILES}; { | |
path=${LDAP_LIB_DIR}/${f}; | |
[ -f ${path} ]; sudo -u ${LDAP_USER} rm ${path}; | |
} | |
# Make sure the DB_CONFIG file and any log files remaining have the correct ownership | |
sudo chown -R ${LDAP_USER}:${LDAP_GROUP} ${LDAP_LIB_DIR} | |
sudo service ${SERVICE_NAME} start |
Thanks so much!
You are the man!! You saved me.
Thanks for the script it allowed me to stop banging my head against a wall trying to figure out why my OpenLDAP proxy kept failing the 'slaptest ' command. One thing I did need to change is for some reason 'ldap' for my user and group did not work. I set LDAP_USER & LDAP_GROUP to 'openldap' in your script. May be caused by an update to the OpenLDAP installer.
Few more keywords for context are permissions issues and 'bi_db_open failed'.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man.. it saved my almost half day... :)