summaryrefslogtreecommitdiff
path: root/utils/create-large-groups.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/create-large-groups.sh')
-rwxr-xr-xutils/create-large-groups.sh47
1 files changed, 47 insertions, 0 deletions
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
+