Sfoglia il codice sorgente

Prevent failure due to -e flag used

Call get_ldap_base_dn to detect failure very early
Olivier Bourdon 6 anni fa
parent
commit
afb920c147
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      image/service/slapd/startup.sh

+ 3 - 0
image/service/slapd/startup.sh

@@ -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() {
@@ -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}