-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
67 lines (57 loc) · 1.83 KB
/
setup.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
## Note: we rely on "standard" LDAP schemas as defined in /usr/share/dirsrv/schema
dsconf localhost backend create --suffix="dc=example,dc=com" --be-name="example"
# We must wait for dsconf to finish. It apparently returns before server is actually ready for following ldapadds
# TODO: maybe use: dsctl --json slapd-localhost healthcheck
sleep 5
SUFFIX="dc=example,dc=com"
# Add structure
echo "Adding example dcObject"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: dc=example,dc=com
dc: example
objectClass: dcObject
EOF
# We are simulating freeipa LDAP so need freeipa flat schema
# See /~https://github.com/freeipa/freeipa/blob/master/install/share/bootstrap-template.ldif
echo "Adding accounts nsContainer"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: cn=accounts,$SUFFIX
changetype: add
objectClass: top
objectClass: nsContainer
cn: accounts
EOF
echo "Adding users nsContainer"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: cn=users,cn=accounts,$SUFFIX
changetype: add
objectClass: top
objectClass: nsContainer
cn: users
EOF
echo "Adding groups nsContainer"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: cn=groups,cn=accounts,$SUFFIX
changetype: add
objectClass: top
objectClass: nsContainer
cn: groups
EOF
## Now add some entries
echo "Adding User jdoe"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: uid=jdoe,cn=users,cn=accounts,dc=example,dc=com
uid: jdoe
givenName: John
objectClass: inetorgperson
sn: Doe
cn: John Doe
EOF
echo "Adding ops management group"
ldapadd -D "cn=Directory Manager" -w password -H ldap://ldap:3389 -x <<EOF
dn: cn=opsmngd,cn=groups,cn=accounts,dc=example,dc=com
cn: opsmngd
objectclass: groupOfNames
member: uid=jdoe,ou=People,dc=example,dc=com
EOF