@@ -722,7 +722,6 @@ schema2ldif() {
722
722
723
723
tmpd=$(mktemp -d)
724
724
pushd "${tmpd}" >>/dev/null
725
-
726
725
echo "include /etc/openldap/schema/core.schema" >> convert.dat
727
726
echo "include /etc/openldap/schema/cosine.schema" >> convert.dat
728
727
echo "include /etc/openldap/schema/${SCHEMA_TYPE}.schema" >> convert.dat
@@ -741,14 +740,20 @@ schema2ldif() {
741
740
fi
742
741
743
742
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
748
743
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
750
752
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
752
757
sed -i \
753
758
-e "/dn:/ c dn: cn=${schema_name},cn=schema,cn=config" \
754
759
-e "/cn:/ c cn: ${schema_name}" \
@@ -760,10 +765,10 @@ schema2ldif() {
760
765
-e '/modifiersName/ d' \
761
766
-e '/modifyTimestamp/ d' \
762
767
"${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}"
765
768
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}"
767
772
done
768
773
769
774
popd >>/dev/null
0 commit comments