Skip to content

Commit

Permalink
Added logic to process LDIF
Browse files Browse the repository at this point in the history
Added logic to process LDIF files at startup time.
  • Loading branch information
skoranda committed Jun 15, 2018
1 parent 30b9f79 commit e63a5bd
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions comanage-registry-slapd-base/comanage_ldap_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ EOF
# SLAPD_CERT_FILE
# SLAPD_PRIVKEY_FILE
# SLAPD_CHAIN_FILE
# OLC_ROOT_DN_PASSWORD
# OLC_ROOT_DN_PASSWORD_FILE
# OLC_ROOT_PW_FILE
# OLC_ROOT_PW
# Arguments:
Expand All @@ -395,6 +397,10 @@ function comanage_ldap_utils::copy_cert_and_secrets() {
if [[ -f "${OLC_ROOT_PW_FILE}" ]]; then
OLC_ROOT_PW=`cat ${OLC_ROOT_PW_FILE}`
fi

if [[ -f "${OLC_ROOT_DN_PASSWORD_FILE}" ]]; then
OLC_ROOT_DN_PASSWORD=`cat ${OLC_ROOT_DN_PASSWORD_FILE}`
fi
}

##########################################
Expand Down Expand Up @@ -440,6 +446,9 @@ function comanage_ldap_utils::exec_slapd() {
# Configure TLS.
comanage_ldap_utils::configure_tls

# Process input LDIF.
comanage_ldap_utils::process_ldif

# Stop slapd listening on UNIX socket.
comanage_ldap_utils::stop_slapd_socket

Expand Down Expand Up @@ -491,6 +500,31 @@ function comanage_ldap_utils::exec_slapd_proxy() {
exec "$@"
}

##########################################
# Process LDIF.
# Globals:
# CN_ADMIN_LDIF
# CN_CONFIG_LDIF
# OLC_ROOT_DN_PASSWORD
# Arguments:
# None
# Returns:
# None
##########################################
function comanage_ldap_utils::process_ldif() {
if [[ -f "${CN_ADMIN_LDIF}" && \
! -n "${OLC_ROOT_DN_PASSWORD}" ]]; then
ldapmodify -c -H ldapi:/// -D "${OLC_ROOT_DN}" -x \
-w "${OLC_ROOT_DN_PASSWORD}" \
-f "${CN_ADMIN_LDIF}" > /dev/null 2>&1
fi

if [[ -f "${CN_CONFIG_LDIF}" ]]; then
ldapmodify -c -Y EXTERNAL -H ldapi:/// \
-f "${CN_CONFIG_LDIF}" > /dev/null 2>&1
fi
}

##########################################
# Determine if TLS attribute already exists.
# Globals:
Expand Down

0 comments on commit e63a5bd

Please sign in to comment.