summaryrefslogtreecommitdiff
path: root/populate-ldap/00a-add-kolab-users.sh
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:50:15 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:50:15 (GMT)
commit811f83ace1e63d493093dff78151e9a64d90cf53 (patch)
treef3dde9326fdc7b4d3592f46c95bf687915ed4513 /populate-ldap/00a-add-kolab-users.sh
parentbe3183ea867ad6fe909e9684b45d6e3667cf2ede (diff)
downloadkolab-scripts-811f83ace1e63d493093dff78151e9a64d90cf53.tar.gz
Add the kolab-scripts used in migration and development
Diffstat (limited to 'populate-ldap/00a-add-kolab-users.sh')
-rwxr-xr-xpopulate-ldap/00a-add-kolab-users.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/populate-ldap/00a-add-kolab-users.sh b/populate-ldap/00a-add-kolab-users.sh
new file mode 100755
index 0000000..3c1586a
--- /dev/null
+++ b/populate-ldap/00a-add-kolab-users.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+ . ./settings.sh
+
+i=0
+while [ $i -lt 0$1 ]; do
+
+ givenname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c5`
+ surname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c10`
+
+ givenname="$(echo ${givenname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${givenname:1} | tr '[:upper:]' '[:lower:]')"
+ givenname_lower="$(echo ${givenname} | tr '[:upper:]' '[:lower:]')"
+ surname="$(echo ${surname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${surname:1} | tr '[:upper:]' '[:lower:]')"
+ surname_lower="$(echo ${surname} | tr '[:upper:]' '[:lower:]')"
+
+ uid="$(echo ${givenname:0:1}.${surname} | tr '[:upper:]' '[:lower:]')"
+
+ userpassword="Welcome2KolabSystems"
+
+ telephonenumber=""
+ if [ $(( $RANDOM % 2 )) -eq 0 ]; then
+ telephonenumber="+"
+ while [ "$(echo ${telephonenumber} | wc -c)" -lt 12 ]; do
+ telephonenumber="${telephonenumber}$(echo $RANDOM)"
+ done
+ fi
+
+ mobile=""
+ if [ $(( $RANDOM % 2 )) -eq 0 ]; then
+ mobile="+"
+ while [ "$(echo ${mobile} | wc -c)" -lt 12 ]; do
+ mobile="${mobile}$(echo $RANDOM)"
+ done
+ fi
+
+ jpegphoto_from=""
+ if [ $(( $RANDOM % 2 )) -eq 0 ]; then
+ [ ! -f "/root/hackergotchi.png" ] && \
+ wget -q -O/root/hackergotchi.png \
+ http://kanarip.fedorapeople.org/kanarip.png
+
+ jpegphoto_from="< file:/root/hackergotchi.png"
+ fi
+
+ mailalternateaddress=""
+ if [ $(( $RANDOM % 2 )) -eq 0 ]; then
+ mailalternateaddress="${uid}@${surname_lower}.com"
+ fi
+
+ echo "dn: uid=$uid,ou=People,${rootdn}"
+ echo "uid: $uid"
+ echo "givenName: $givenname"
+ echo "objectClass: top"
+ echo "objectClass: person"
+ echo "objectClass: inetOrgPerson"
+ echo "objectclass: kolabinetorgperson"
+ echo "objectclass: organizationalperson"
+ echo "objectclass: mailrecipient"
+
+ if [ ! -z "${telephonenumber}" ]; then
+ echo "telephonenumber: ${telephonenumber}"
+ fi
+
+ if [ ! -z "${mobile}" ]; then
+ echo "mobile: ${mobile}"
+ fi
+
+ if [ ! -z "${jpegphoto_from}" ]; then
+ echo "jpegphoto:${jpegphoto_from}"
+ fi
+
+ if [ ! -z "${mailalternateaddress}" ]; then
+ echo "mailalternateaddress: ${mailalternateaddress}"
+ fi
+
+ echo "sn: $surname"
+ echo "cn: $givenname $surname"
+ echo "displayname: $surname, $givenname"
+ echo "mail: ${givenname_lower}.${surname_lower}@${domain}"
+ echo ""
+
+ let i++
+done | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c
+