#!/bin/sh prefix="{{DS-ROOT}}" if [ "$prefix" = "/" ] ; then prefix="" fi LD_LIBRARY_PATH=$prefix/{{SERVER-DIR}}:$prefix@nss_libdir@:$prefix@libdir@:$prefix@pcre_libdir@ if [ -n "$prefix" ] ; then LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@nss_libdir@" fi export LD_LIBRARY_PATH SHLIB_PATH=$LD_LIBRARY_PATH export SHLIB_PATH make_ldiffile() { be="" while [ "$1" != "" ] do if [ "$1" = "-a" ]; then shift echo $1 return 1 elif [ "$1" = "-n" ]; then shift if [ "$be" = "" ]; then be="$1" else tmpbe="$be" be="${tmpbe}-$1" fi elif [ "$1" = "-s" ]; then shift if [ "$1" != "" ]; then rdn=`echo $1 | awk -F, '{print $1}'` rdnval=`echo $rdn | awk -F= '{print $2}'` if [ "$be" = "" ]; then be="$rdnval" else tmpbe="$be" be="${tmpbe}-$rdnval" fi fi elif [ "$1" = "-M" ]; then be="" fi if [ "$1" != "" ]; then shift fi done if [ "$be" = "" ]; then echo {{LDIF-DIR}}/{{SERV-ID}}-`date +%Y_%m_%d_%H%M%S`.ldif else echo {{LDIF-DIR}}/{{SERV-ID}}-${be}-`date +%Y_%m_%d_%H%M%S`.ldif fi return 0 } cd {{SERVERBIN-DIR}} if [ "$#" -lt 2 ]; then echo "Usage: db2ldif {-n backend_instance}* | {-s includesuffix}*" echo " [{-x excludesuffix}*] [-a outputfile]" echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1]" echo "Note: either \"-n backend_instance\" or \"-s includesuffix\" is required." exit 1 fi ldif_file=`make_ldiffile $@` rn=$? echo "Exported ldif file: $ldif_file" if [ $rn -eq 1 ] then ./ns-slapd db2ldif -D {{CONFIG-DIR}} "$@" else ./ns-slapd db2ldif -D {{CONFIG-DIR}} -a $ldif_file "$@" fi