]> TLD Linux GIT Repositories - packages/rpm-tld-macros.git/blob - macros.openldap
- merged 2.029 from PLD
[packages/rpm-tld-macros.git] / macros.openldap
1 # Register OpenLDAP schema.
2 # Author: Elan Ruusamäe <glen@pld-linux.org>
3 #
4 # Usage:
5 #   %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
6 #
7 #  -d specify dependant schemas, separated by comma
8 #
9 %openldap_schema_register(d:) \
10 for schema in %*; do \
11         if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
12                 %{__sed} -i -e " \
13                         /^include.*local.schema/{ \
14                                 iinclude\\t     $schema\
15                         } \
16                 " /etc/openldap/slapd.conf \
17         fi \
18 done \
19 # enable dependant schemas \
20 if [ "%{-d*}" ]; then \
21         %{__sed} -i -e ' \
22         /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
23                 s/^#// \
24         }' /etc/openldap/slapd.conf \
25 fi \
26 %{nil}
27
28 # Unregister OpenLDAP schema.
29 # Author: Elan Ruusamäe <glen@pld-linux.org>
30 #
31 # Usage:
32 #   %%openldap_schema_unregister %{schemadir}/horde.schema
33 #
34 %openldap_schema_unregister() \
35 for schema in %*; do \
36         if grep -q "$schema" /etc/openldap/slapd.conf; then \
37                 %{__sed} -i -e " \
38                 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
39                 # for symmetry it would be nice if we disable enabled schemas in post, \
40                 # but we really can not do that, it would break something else. \
41                 " /etc/openldap/slapd.conf \
42         fi \
43 done \
44 %{nil}