summaryrefslogtreecommitdiff
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
parent0359f9cd4d708da6cdb70cb0edea5e72b4bdbfa0 (diff)
downloadkolab-scripts-37625feabd913c5ab38d1d298410301219f40e67.tar.gz
Add some more utils
-rwxr-xr-xutils/add-attribute-index.sh59
-rwxr-xr-xutils/create-large-groups.sh47
-rwxr-xr-xutils/list-attribute-indexes.sh9
-rwxr-xr-xutils/reset-user-passwords.sh14
l---------utils/settings.sh1
5 files changed, 130 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
+
diff --git a/utils/create-large-groups.sh b/utils/create-large-groups.sh
new file mode 100755
index 0000000..9e33f4d
--- /dev/null
+++ b/utils/create-large-groups.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+declare -a members
+
+for member_dn in `ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -b "ou=People,${rootdn}" -LLL "(objectclass=kolabinetorgperson)" entrydn | grep ^dn: | cut -d':' -f2`; do
+ members[${#members[@]}]="${member_dn}"
+done
+
+declare -a random_numbers
+
+i=0
+done=0
+while [ ${i} -lt $(( ${#members[@]} / 2 )) -a ${done} -eq 0 ]; do
+
+ for random_number in `head -n ${#members[@]} /dev/urandom | od | awk '{print $2}' | sort -u`; do
+ if [ ${random_number} -le ${#members[@]} ]; then
+ random_numbers[${#random_numbers[@]}]=${random_number}
+ else
+ done=1
+ break
+ fi
+ done
+
+ i=${#random_numbers[@]}
+
+done
+(
+ echo "dn: cn=Students,ou=Groups,${rootdn}"
+ echo "objectclass: top"
+ echo "objectclass: groupofuniquenames"
+ echo "objectclass: kolabgroupofuniquenames"
+ echo "cn: Students"
+ echo "mail: students@${domain}"
+ i=0
+ while [ $i -lt ${#random_numbers[@]} ]; do
+ if [ ! -z "${members[${random_numbers[$i]}]}" ]; then
+ echo "uniquemember: ${members[${random_numbers[$i]}]}"
+ fi
+ let i++
+ done | sort -u
+ echo ""
+) > /tmp/ldif
+
+ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c -f /tmp/ldif
+
diff --git a/utils/list-attribute-indexes.sh b/utils/list-attribute-indexes.sh
new file mode 100755
index 0000000..24eb209
--- /dev/null
+++ b/utils/list-attribute-indexes.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+for ldbm_cn in `ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -b "cn=ldbm database,cn=plugins,cn=config" -s one -LLL "(objectclass=nsBackendInstance)" cn | grep ^cn: | awk '{print $2}'`; do
+ echo "ldbm database: ${ldbm_cn}"
+
+ ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -b "cn=index,cn=${ldbm_cn},cn=ldbm database,cn=plugins,cn=config" -s one -LLL
+done
diff --git a/utils/reset-user-passwords.sh b/utils/reset-user-passwords.sh
new file mode 100755
index 0000000..09bb4a5
--- /dev/null
+++ b/utils/reset-user-passwords.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+ldapsearch -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -b "ou=People,${rootdn}" -LLL "(objectclass=kolabinetorgperson)" entrydn | grep ^dn: | cut -d':' -f2 | while read dn; do
+ (
+ echo "dn: ${dn}"
+ echo "changetype: modify"
+ echo "replace: userpassword"
+ echo "userpassword: ${default_user_password}"
+ echo ""
+ ) | ldapmodify -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}"
+done
+
diff --git a/utils/settings.sh b/utils/settings.sh
new file mode 120000
index 0000000..a08eca5
--- /dev/null
+++ b/utils/settings.sh
@@ -0,0 +1 @@
+../settings.sh \ No newline at end of file