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 [ ! -z $LDAPURL ] && LDAP_AUTH="$LDAP_AUTH -H $LDAPURL"
20 if [ -z "$XML" ] || [ ! -r $XML ]; then
21 echo "usage: $0 xmlfile"
25 NAME=`basename $XML .xml`
28 # add the top level record, if needed
29 ldapsearch $LDAP_AUTH -b $LDAP_BASE > /dev/null 2>&1 ||
30 ldapadd $LDAP_AUTH -f $LUSTRE/conf/top.ldif
32 # If this config already exists, then delete it
33 ldapsearch $LDAP_AUTH -b config=$NAME,$LDAP_BASE > /dev/null 2>&1 &&
34 ldapdelete $LDAP_AUTH -r config=$NAME,$LDAP_BASE
36 4xslt -D config=$NAME $XML $LUSTRE/conf/lustre2ldif.xsl > $LDIF
38 echo "Loading config to 'config=$NAME,$LDAP_BASE' ..."
39 ldapadd $LDAP_AUTH -f $LDIF