X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fldap;h=242755edcd8b393e2c7b639fbba9ec823d5cf453;hb=d15a347be54fea3ae44c595b454b22fb41149271;hp=ee46831092d10688be9d67d09401c7329346aeb5;hpb=fe7ee521a660ef38e5657c31eefb14b95f22827f;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/ldap b/handlers/ldap index ee46831..242755e 100644 --- a/handlers/ldap +++ b/handlers/ldap @@ -12,6 +12,14 @@ getconf restart no getconf method ldapsearch getconf passwordfile getconf binddn +getconf ldaphost +getconf tls yes + +if [ $tls = 'yes' ]; then + URLBASE="ldaps" +else + URLBASE="ldap" +fi status="ok" @@ -46,15 +54,11 @@ if [ "$ldif" == "yes" ]; then fi if [ "$method" == "slapcat" ]; then - if [ "$compress" == "yes" ]; then - execstr="$SLAPCAT -f $conf -b $dbsuffix | $GZIP" - else - execstr="$SLAPCAT -f $conf -b $dbsuffix" - fi + execstr="$SLAPCAT -f $conf -b $dbsuffix" debug "$execstr" else - if [ "$compress" == "yes" ]; then - execstr="$LDAPSEARCH -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile | $GZIP" + if [ -n "$ldaphost" ]; then + execstr="$LDAPSEARCH -H $URLBASE://$ldaphost -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile" else execstr="$LDAPSEARCH -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile" fi @@ -67,13 +71,17 @@ if [ "$ldif" == "yes" ]; then /etc/init.d/slapd stop fi - touch $dumpdir/$dbsuffix.ldif - if [ ! -f $dumpdir/$dbsuffix.ldif ]; then - fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif" + ext= + if [ "$compress" == "yes" ]; then + ext=".gz" + fi + touch $dumpdir/$dbsuffix.ldif$ext + if [ ! -f $dumpdir/$dbsuffix.ldif$ext ]; then + fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif$ext" fi if [ "$compress" == "yes" ]; then - output=`$execstr > $dumpdir/$dbsuffix.ldif.gz` + output=`$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz` else output=`$execstr > $dumpdir/$dbsuffix.ldif` fi