3 # Load a lustre config xml into an openldap database.
4 # See https://projects.clusterfs.com/lustre/LustreLDAP
7 # Usage: load_ldap.sh <xml_file>
10 LDAP_BASE=${LDAP_BASE:-fs=lustre}
11 LDAP_ROOTDN=${LDAP_ROOTDN:-cn=Manager,fs=lustre}
12 LDAP_PW=${LDAP_PW:-secret}
13 LDAP_AUTH="-x -D $LDAP_ROOTDN -w $LDAP_PW"
14 LUSTRE=${LUSTRE:-`dirname $0`/..}
16 if [ -f $LUSTRE/Makefile.am ]; then
19 CONFDIR=/usr/lib/lustre
23 XSL=$CONFDIR/lustre2ldif.xsl
25 [ ! -z $LDAPURL ] && LDAP_AUTH="$LDAP_AUTH -H $LDAPURL"
29 if [ -z "$XML" ] || [ ! -r $XML ]; then
30 echo "usage: $0 xmlfile"
34 NAME=`basename $XML .xml`
37 # add the top level record, if needed
38 ldapsearch $LDAP_AUTH -b $LDAP_BASE > /dev/null 2>&1 ||
39 ldapadd $LDAP_AUTH -f $TOP
41 # If this config already exists, then delete it
42 ldapsearch $LDAP_AUTH -b config=$NAME,$LDAP_BASE > /dev/null 2>&1 &&
43 ldapdelete $LDAP_AUTH -r config=$NAME,$LDAP_BASE
45 4xslt -D config=$NAME $XML $XSL > $LDIF
47 echo "Loading config to 'config=$NAME,$LDAP_BASE' ..."
48 ldapadd $LDAP_AUTH -f $LDIF