29 lines
747 B
Bash
Executable File
29 lines
747 B
Bash
Executable File
#!/bin/bash -e
|
|
|
|
LDAPMODIFY=(ldapmodify -Q -YEXTERNAL -Hldapi:///)
|
|
SLAPD=(su openldap -c "slapd '-hldap:/// ldaps:/// ldapi:///' -d$LDAP_LOG_LEVEL")
|
|
|
|
# https://sources.debian.org/src/openldap/2.5.13+dfsg-5/debian/slapd.templates/
|
|
cat <<EOF | debconf-set-selections && dpkg-reconfigure slapd
|
|
slapd slapd/dump_database select always
|
|
slapd slapd/domain string '$LDAP_DOMAIN'
|
|
slapd shared/organization string '$LDAP_ORGANIZATION'
|
|
slapd slapd/password1 string '$LDAP_ADMIN_PASSWORD'
|
|
slapd slapd/password2 string '$LDAP_ADMIN_PASSWORD'
|
|
EOF
|
|
|
|
# start slapd
|
|
"${SLAPD[@]}" &
|
|
sleep 1
|
|
|
|
# enable SHA2
|
|
"${LDAPMODIFY[@]}" <<EOF
|
|
dn: cn=module{0},cn=config
|
|
changetype: modify
|
|
add: olcModuleLoad
|
|
olcModuleLoad: pw-sha2
|
|
EOF
|
|
|
|
/etc/init.d/slapd stop
|
|
exec "${SLAPD[@]}"
|