Skip to content

Commit 4631a73

Browse files
authored
Merge pull request #65 from adrianparilli/patch-1
Make custom schemas work
2 parents 92c0a84 + 5c625b6 commit 4631a73

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

install/assets/functions/10-openldap

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ schema2ldif() {
722722

723723
tmpd=$(mktemp -d)
724724
pushd "${tmpd}" >>/dev/null
725-
726725
echo "include /etc/openldap/schema/core.schema" >> convert.dat
727726
echo "include /etc/openldap/schema/cosine.schema" >> convert.dat
728727
echo "include /etc/openldap/schema/${SCHEMA_TYPE}.schema" >> convert.dat
@@ -741,14 +740,20 @@ schema2ldif() {
741740
fi
742741

743742
for schema in ${schemas}; do
744-
fullpath=${schema}
745-
schema_name=$(basename "${fullpath}" .schema)
746-
schema_dir=$(dirname "${fullpath}")
747-
ldif_file=${schema_name}.ldif
748743

749-
find "${slaptest_tmp}" -name *\}"${schema_name}".ldif -exec mv '{}' ./"${ldif_file}" \;
744+
# Schema name without extension
745+
schema_name=$(basename "${schema}" .schema)
746+
747+
# Schema path
748+
schema_dir=$(dirname "${schema}")
749+
750+
# Final path and name for LDIF file
751+
ldif_file=${schema_dir}/${schema_name}.ldif
750752

751-
# TODO: these sed invocations could all be combined
753+
# Locate the LDIF from temporal dir and move to its final location
754+
find "${slaptest_tmp}" -name *\}${schema_name}.ldif -exec mv '{}' "${ldif_file}" \;
755+
756+
# Apply LDAP stuff to LDIF file
752757
sed -i \
753758
-e "/dn:/ c dn: cn=${schema_name},cn=schema,cn=config" \
754759
-e "/cn:/ c cn: ${schema_name}" \
@@ -760,10 +765,10 @@ schema2ldif() {
760765
-e '/modifiersName/ d' \
761766
-e '/modifyTimestamp/ d' \
762767
"${ldif_file}"
763-
# slapd seems to be very sensitive to how a file ends. There should be no blank lines.
764-
sed -i '/^ *$/d' "${ldif_file}"
765768

766-
mv "${ldif_file}" "${schema_dir}"
769+
# slapd is very sensitive to how a file starts and ends. There should be no blank lines.
770+
# see https://www.openldap.org/doc/admin26/appendix-common-errors.html
771+
sed -i '/^ *$/d' "${ldif_file}"
767772
done
768773

769774
popd >>/dev/null

0 commit comments

Comments
 (0)