summaryrefslogtreecommitdiff
path: root/utils/add-attribute-index.sh
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-22 13:46:32 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-22 13:46:32 (GMT)
commit37625feabd913c5ab38d1d298410301219f40e67 (patch)
treefa42fc8cb1b651b736ce4e4310c3bf34bcf63463 /utils/add-attribute-index.sh
parent0359f9cd4d708da6cdb70cb0edea5e72b4bdbfa0 (diff)
downloadkolab-scripts-37625feabd913c5ab38d1d298410301219f40e67.tar.gz
Add some more utils
Diffstat (limited to 'utils/add-attribute-index.sh')
-rwxr-xr-xutils/add-attribute-index.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/utils/add-attribute-index.sh b/utils/add-attribute-index.sh
new file mode 100755
index 0000000..381ffad
--- /dev/null
+++ b/utils/add-attribute-index.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 <attribute>"
+ exit 1
+fi
+
+export index_attr=$1
+
+(
+ echo "dn: cn=${index_attr},cn=index,cn=${domain_db},cn=ldbm database,cn=plugins,cn=config"
+ echo "objectclass: top"
+ echo "objectclass: nsindex"
+ echo "cn: ${index_attr}"
+ echo "nsSystemIndex: false"
+ echo "nsindextype: pres"
+ echo "nsindextype: eq"
+ echo "nsindextype: sub"
+
+) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c
+
+
+(
+ echo "dn: cn=${domain_db} ${index_attr} index,cn=index,cn=tasks,cn=config"
+ echo "objectclass: top"
+ echo "objectclass: extensibleObject"
+ echo "cn: ${domain_db} ${index_attr} index"
+ echo "nsinstance: ${domain_db}"
+ echo "nsIndexAttribute: ${index_attr}:pres"
+ echo "nsIndexAttribute: ${index_attr}:eq"
+ echo "nsIndexAttribute: ${index_attr}:sub"
+ echo ""
+) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c
+
+ldap_complete=0
+
+while [ ${ldap_complete} -ne 1 ]; do
+ result=$(
+ ldapsearch \
+ -x \
+ -h ${ldap_host} \
+ -D "${ldap_binddn}" \
+ -w "${ldap_bindpw}" \
+ -c \
+ -LLL \
+ -b "cn=${domain_db} ${index_attr} index,cn=index,cn=tasks,cn=config" \
+ -s base 2>/dev/null
+ )
+ if [ -z "$result" ]; then
+ ldap_complete=1
+ echo ""
+ else
+ echo -n "."
+ sleep 1
+ fi
+done
+