-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·45 lines (31 loc) · 1.13 KB
/
start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -euo pipefail
if [[ ${FORCE_NEW_CONFIG} == "true" ]]; then
rm -rf "/var/lib/ldap/*"
rm -rf "/etc/ldap/slapd.d/*"
fi
echo "Generating LDIF"
echo "Domain: ${LDAP_DOMAIN}"
ORG="$(echo "${LDAP_DOMAIN}" | sed 's/\..*$//')"
TLD="$(echo "${LDAP_DOMAIN}" | sed 's/^.*\.//')"
echo "ORG: ${ORG}"
echo "TLD: ${TLD}"
SERVICE_PASSWORD="$(slappasswd -h "{SSHA}" -s "${LDAP_SVC_PASSWORD}")"
for filename in /container/templates/*.ldif; do
echo "Building ${filename}"
sed -i "s|CUSTOM_ORG|${ORG}|" "${filename}"
sed -i "s|CUSTOM_TLD|${TLD}|" "${filename}"
sed -i "s|CUSTOM_SERVICE_PASSWORD|${SERVICE_PASSWORD}|" "${filename}"
cat ${filename}
cp "${filename}" "/container/service/slapd/assets/config/bootstrap/ldif/"
done
/container/tool/run&
sed -i "s|CUSTOM_ORG|${ORG}|" "/container/modify.ldif"
sed -i "s|CUSTOM_TLD|${TLD}|" "/container/modify.ldif"
sed -i "s|CUSTOM_SERVICE_PASSWORD|${SERVICE_PASSWORD}|" "/container/modify.ldif"
until ldapmodify -D 'cn=admin,dc=cotak,dc=gov' -H ldap://localhost:389 -w "${LDAP_ADMIN_PASSWORD}" -f /container/modify.ldif
do
echo "sleeping for 10s"
sleep 10
done
wait