Jan Engelhardt
17245dd92c
- Backported one hunk from upstream commit fb9e6a81bbee as openldap2-fb9e6a81bbee.patch to fix incompatible pointer type being passed to a function which is diagnosed as an error by GCC 14. If the request is OK, please forward it to Factory soon so that we can switch the default compiler. Thanks! OBS-URL: https://build.opensuse.org/request/show/1190307 OBS-URL: https://build.opensuse.org/package/show/network:ldap/openldap2?expand=0&rev=323
54 lines
1.2 KiB
Bash
54 lines
1.2 KiB
Bash
#!/bin/bash
|
|
#
|
|
# This is a simple tool to convert OpenLDAP Schema files to
|
|
# LDIF suitable for usage with OpenLDAP's dynamic configuration
|
|
# backend (cn=config)
|
|
#
|
|
# usage:
|
|
# schema2ldif <input file>
|
|
#
|
|
# The generated LDIF is printed to stdout.
|
|
#
|
|
|
|
if [ -z "$1" ]; then
|
|
echo 'usage: schema2ldif <input file>'
|
|
exit;
|
|
fi
|
|
|
|
cn=`basename $1 .schema`
|
|
|
|
echo "dn: cn=$cn,cn=schema,cn=config";
|
|
echo "objectclass: olcSchemaConfig";
|
|
echo "cn: $cn";
|
|
|
|
/usr/bin/awk '
|
|
BEGIN {
|
|
buffer = "";
|
|
width=78 ;
|
|
}
|
|
function wrap(data)
|
|
{
|
|
if (length(data) > 0) {
|
|
do {
|
|
print substr(data,0,width);
|
|
data = " " substr(data, width+1);
|
|
}
|
|
while (length(data) > 1 )
|
|
};
|
|
}
|
|
/^[\t ]*$/ {wrap(buffer); buffer=""; print "#"; next; }
|
|
/^#.*$/ { wrap(buffer); buffer=""; print $0; next }
|
|
/^[\t ]+/ { gsub("^[\t ]+",""); buffer = buffer " " $0; next; }
|
|
{
|
|
wrap(buffer);
|
|
$1 = tolower($1) ;
|
|
gsub("^objectclass$","olcObjectclasses:",$1)
|
|
gsub("^attributetype$","olcAttributeTypes:",$1)
|
|
gsub("^attributetypes$","olcAttributeTypes:",$1)
|
|
gsub("^objectidentifier$","olcObjectIdentifier:",$1)
|
|
buffer = $0;
|
|
}
|
|
END { wrap(buffer); print "" }
|
|
' "$@"
|
|
|