summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpopulate-ldap/10d-test-use-detected-vlv.sh40
1 files changed, 27 insertions, 13 deletions
diff --git a/populate-ldap/10d-test-use-detected-vlv.sh b/populate-ldap/10d-test-use-detected-vlv.sh
index 26f67bc..3c8e24a 100755
--- a/populate-ldap/10d-test-use-detected-vlv.sh
+++ b/populate-ldap/10d-test-use-detected-vlv.sh
@@ -8,31 +8,35 @@ vlvfilter=""
vlvsort=""
(
- ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "cn=ldbm database,cn=plugins,cn=config" "(objectclass=vlvsearch)" entrydn | grep ^dn | cut -d':' -f2-
-) | while read vlvsearch; do
- vlvbasedn=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvbase | grep -v ^dn | sed '/^vlvbase:/{
+ ldapsearch -o ldif-wrap=no -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "cn=ldbm database,cn=plugins,cn=config" "(objectclass=vlvsearch)" entrydn | sed -e '/^dn:/{
+ $!{ N
+ s/dn: //
+ s/\n\s//
+}};') | grep -v '^$' | while read vlvsearch; do
+
+ vlvbasedn=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvbase | sed '/^vlvbase:/{
$!{ N
s/vlvbase: //
s/\n\s//
-}}'`
+}}' | grep -vE "^(dn|\s)"`
- vlvscope=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvscope | grep -v ^dn | sed '/^vlvscope:/{
+ vlvscope=`ldapsearch -o ldif-wrap=no -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvscope | sed '/^vlvscope:/{
$!{ N
s/vlvscope: //
s/\n\s//
-}}'`
+}}' | grep -vE "^(dn|\s)"`
- vlvfilter=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvfilter | grep -v ^dn | sed '/^vlvfilter:/{
+ vlvfilter=`ldapsearch -o ldif-wrap=no -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s base vlvfilter | sed '/^vlvfilter:/{
$!{ N
s/vlvfilter: //
s/\n\s//
-}}'`
+}}' | grep -vE "^(dn|\s)"`
- vlvsort=`ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s sub "(objectclass=vlvIndex)" vlvsort | grep -v ^dn | sed '/^vlvsort:/{
+ vlvsort=`ldapsearch -o ldif-wrap=no -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -LLL -b "${vlvsearch}" -s sub "(objectclass=vlvIndex)" vlvsort | sed '/^vlvsort:/{
$!{ N
s/vlvsort: //
s/\n\s//
-}}'`
+}}' | grep -vE "^(dn|\s)"`
echo "Found a VLV index and search with parameters:"
echo " - Base: ${vlvbasedn}"
@@ -61,7 +65,8 @@ vlvsort=""
# Use it
uses_before=`ldapsearch \
- -x \
+ -o ldif-wrap=no \
+ -x \
-h ${ldap_host} \
-D "${ldap_binddn}" \
-w "${ldap_bindpw}" \
@@ -76,8 +81,11 @@ vlvsort=""
uses_before=0
fi
+ echo "Searching '${vlvbasedn}'"
+
echo "after" | ldapsearch \
- -x \
+ -o ldif-wrap=no \
+ -x \
-h ${ldap_host} \
-D "${ldap_binddn}" \
-w "${ldap_bindpw}" \
@@ -86,8 +94,11 @@ vlvsort=""
-E '!vlv=5/5/1/10' \
-E "!sss=$(echo ${vlvsort} | sed -e 's| |/|g')" >/dev/null 2>&1
+ echo "Searching '${vlvsearch}'"
+
uses_after=`ldapsearch \
- -x \
+ -o ldif-wrap=no \
+ -x \
-h ${ldap_host} \
-D "${ldap_binddn}" \
-w "${ldap_bindpw}" \
@@ -104,6 +115,9 @@ vlvsort=""
if [ ${uses_before} -lt ${uses_after} ]; then
echo "Actually works, too (before: ${uses_before}, after: ${uses_after})"
+ else
+ echo "Does not seem to work (uses before -eq after)"
+ echo "Used: ldapsearch -x -h '${ldap_host}' -D '${ldap_binddn}' -w '${ldap_bindpw}' -b '${vlvbasedn}' -s ${vlvscope} '${vlvfilter}' -E '!vlv=5/5/1/10' -E '!sss=$(echo ${vlvsort} | sed -e 's| |/|g')'"
fi
done