|
104 | 104 |
|
105 | 105 | # start OpenLDAP |
106 | 106 | echo "Starting openldap..." |
107 | | - slapd -h "ldapi:///" -u openldap -g openldap |
| 107 | + slapd -h "ldap://localhost ldapi:///" -u openldap -g openldap |
108 | 108 | echo "[ok]" |
109 | 109 |
|
110 | 110 | # set bootstrap config part 2 |
@@ -142,12 +142,33 @@ EOF |
142 | 142 | get_ldap_base_dn |
143 | 143 | sed -i "s|{{ LDAP_BASE_DN }}|${LDAP_BASE_DN}|g" /container/service/slapd/assets/config/bootstrap/ldif/02-security.ldif |
144 | 144 |
|
145 | | - # process config files |
146 | | - for f in $(find /container/service/slapd/assets/config/bootstrap/ldif -name \*.ldif -type f | sort); do |
| 145 | + # process config files in bootstrap directory (do no process files in subdirectories) |
| 146 | + for f in $(find /container/service/slapd/assets/config/bootstrap/ldif -name \*.ldif -mindepth 1 -maxdepth 1 -type f | sort); do |
147 | 147 | echo "Processing file ${f}" |
148 | 148 | ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f $f |
149 | 149 | done |
150 | 150 |
|
| 151 | + # read only user |
| 152 | + if [ "${LDAP_READONLY_USER,,}" == "true" ]; then |
| 153 | + |
| 154 | + echo "Add read only user" |
| 155 | + |
| 156 | + LDAP_READONLY_USER_PASSWORD_ENCRYPTED=$(slappasswd -s $LDAP_READONLY_USER_PASSWORD) |
| 157 | + sed -i "s|{{ LDAP_READONLY_USER_USERNAME }}|${LDAP_READONLY_USER_USERNAME}|g" /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user.ldif |
| 158 | + sed -i "s|{{ LDAP_READONLY_USER_PASSWORD_ENCRYPTED }}|${LDAP_READONLY_USER_PASSWORD_ENCRYPTED}|g" /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user.ldif |
| 159 | + sed -i "s|{{ LDAP_BASE_DN }}|${LDAP_BASE_DN}|g" /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user.ldif |
| 160 | + |
| 161 | + sed -i "s|{{ LDAP_READONLY_USER_USERNAME }}|${LDAP_READONLY_USER_USERNAME}|g" /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user-acl.ldif |
| 162 | + sed -i "s|{{ LDAP_BASE_DN }}|${LDAP_BASE_DN}|g" /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user-acl.ldif |
| 163 | + |
| 164 | + echo "Processing file /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user.ldif" |
| 165 | + ldapmodify -h localhost -p 389 -D cn=admin,$LDAP_BASE_DN -w $LDAP_ADMIN_PASSWORD -f /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user.ldif |
| 166 | + |
| 167 | + echo "Processing file /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user-acl.ldif" |
| 168 | + ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f /container/service/slapd/assets/config/bootstrap/ldif/readonly-user/readonly-user-acl.ldif |
| 169 | + |
| 170 | + fi |
| 171 | + |
151 | 172 | fi |
152 | 173 |
|
153 | 174 | # tls config |
|
0 commit comments