aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/openldap/openldap_2.4.39.bbappend
blob: d8166ce8cd531eb30f5f6aca364a73b25bba9586 (plain)
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
PRINC = "2"

DEPEND_${PN} += "cyrus-sasl" 
RDEPEND_${PN} += "libsasl2-modules"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://initscript"
SRC_URI += "file://ops-base.ldif"

LDAP_DN ?= "dc=my-domain,dc=com"
LDAP_DATADIR ?= "/etc/openldap-data/"

do_install_append() {
    install -D -m 0755 ${WORKDIR}/initscript ${D}${sysconfdir}/init.d/openldap
    sed -i -e 's/%DEFAULT_DN%/${LDAP_DN}/g' ${D}${sysconfdir}/init.d/openldap
    sed -i -e 's#%LDAP_DATADIR%#${LDAP_DATADIR}#g' ${D}${sysconfdir}/init.d/openldap

    # This is duplicated in /etc/openldap and is for slapd
    rm -f ${D}${localstatedir}/openldap-data/DB_CONFIG.example
    rmdir "${D}${localstatedir}/run"
    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}"

    # remove symlinks for backends, recreating in postinstall
    rm ${D}/${libexecdir}/openldap/*.so

    sed -i -e '/^include\s*/a \
include         /etc/openldap/schema/cosine.schema \
include         /etc/openldap/schema/nis.schema \
include         /etc/openldap/schema/inetorgperson.schema \
include         /etc/openldap/schema/misc.schema' \
	${D}/etc/openldap/slapd.conf

    sed -i -e '/^# Load dynamic backend modules:/a \
modulepath      /usr/libexec/openldap \
moduleload      back_bdb.la' \
	${D}/etc/openldap/slapd.conf

    sed -i -e 's#^pidfile\s*.*$#pidfile ${LDAP_DATADIR}/slapd.pid#' ${D}/etc/openldap/slapd.conf
    sed -i -e 's#^argsfile\s*.*$#argsfile ${LDAP_DATADIR}/slapd.args#' ${D}/etc/openldap/slapd.conf
    sed -i -e 's#^directory\s*.*$#directory ${LDAP_DATADIR}/#' ${D}/etc/openldap/slapd.conf

    sed -i -e 's/dc=my-domain,dc=com/${LDAP_DN}/g' ${D}/etc/openldap/slapd.conf

    # modify access perms for ldap/authentication
    sed -i -e '$a\
\
access to attrs=userPassword \
        by self write \
        by anonymous auth \
        by * none \
\
access to * \
        by self write \
        by * read' \
        ${D}/etc/openldap/slapd.conf

    install -D -m 0644 ${WORKDIR}/ops-base.ldif ${D}/etc/openldap/ops-base.ldif
    sed -i -e 's/dc=my-domain,dc=com/${LDAP_DN}/g' ${D}/etc/openldap/ops-base.ldif

    mkdir ${D}/${LDAP_DATADIR}
}

inherit update-rc.d

INITSCRIPT_NAME = "openldap"
INITSCRIPT_PARAMS = "defaults"