Skip to content

Commit

Permalink
Prevent failure due to -e flag used
Browse files Browse the repository at this point in the history
Call get_ldap_base_dn to detect failure very early
  • Loading branch information
obourdon committed Jul 29, 2019
1 parent b00902e commit afb920c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ if [ ! -e "$FIRST_START_DONE" ]; then
fi
# Check that LDAP_BASE_DN and LDAP_DOMAIN are in sync
domain_from_base_dn=$(echo $LDAP_BASE_DN | tr ',' '\n' | sed -e 's/^.*=//' | tr '\n' '.' | sed -e 's/\.$//')
set +e
echo "$domain_from_base_dn" | egrep -q ".*$LDAP_DOMAIN\$"
if [ $? -ne 0 ]; then
log-helper error "Error: domain $domain_from_base_dn derived from LDAP_BASE_DN $LDAP_BASE_DN does not match LDAP_DOMAIN $LDAP_DOMAIN"
exit 1
fi
set -e
}

function is_new_schema() {
Expand Down Expand Up @@ -102,6 +104,7 @@ if [ ! -e "$FIRST_START_DONE" ]; then
log-helper info "Database and config directory are empty..."
log-helper info "Init new ldap server..."

get_ldap_base_dn
cat <<EOF | debconf-set-selections
slapd slapd/internal/generated_adminpw password ${LDAP_ADMIN_PASSWORD}
slapd slapd/internal/adminpw password ${LDAP_ADMIN_PASSWORD}
Expand Down

0 comments on commit afb920c

Please sign in to comment.