[Yanel-dev] Create many, many groups and users script

Cedric Staub cedric.staub at wyona.com
Wed Sep 1 14:57:55 CEST 2010


Hello there

The from-scratch-realm contains a shell script that allows one to create
many, many groups and users for testing. Sadly, the script is broken.

1. It prints "\n" instead of actual newlines
2. It doesn't add the new "<group>" tag to users
3. The output is just not very nice in general :-)

So, I fixed it. Patch is attached. Please note the difference between
tabs and spaces in the shell script... Save the attachment rather than
copy/pasting the contents of the script.

Cheers
Cedric
-------------- next part --------------
Index: src/realms/from-scratch-realm-template/ac-identities/create-many-many-groups-and-users.sh
===================================================================
--- src/realms/from-scratch-realm-template/ac-identities/create-many-many-groups-and-users.sh	(revision 52644)
+++ src/realms/from-scratch-realm-template/ac-identities/create-many-many-groups-and-users.sh	(working copy)
@@ -1,17 +1,34 @@
 #!/bin/sh
 
-echo "Create many, many, many groups and users ..."
+echo "Create many, many, many groups and users..."
 
-count=0
-while [ $count -lt 1000 ]
-do
-    echo "<?xml version=\"1.0\"?>\n<group id=\"group$count\" xmlns=\"http://www.wyona.org/security/1.0\">\n<name>Example Group $count</name>\n</group>" > groups/group$count.xml
-    count=`expr $count + 1`
+# Number of users and groups to create
+count_users=1000
+count_groups=1000
+
+# Generate groups
+for n in `seq 1 $count_groups`; do
+	cat - > groups/group${n}.xml <<-EOF
+		<?xml version="1.0"?>
+		<group id="group${n}" xmlns="http://www.wyona.org/security/1.0">
+		  <name>Example Group ${n}</name>
+		</group>
+	EOF
 done
 
-count=0
-while [ $count -lt 1000 ]
-do
-    echo "<?xml version=\"1.0\"?>\n<user id=\"user$count\" xmlns=\"http://www.wyona.org/security/1.0\">\n<name>Example User $count</name>\n<email>user$count at yanel.org</email>\n<language>en</language>\n<password>5ebe2294ecd0e0f08eab7690d2a6ee69</password>\n<foo:custom xmlns:foo=\"http://www.foo.bar/security/1.0\">\n<foo:role>admin</foo:role>\n</foo:custom>\n</user>" > users/user$count.xml
-    count=`expr $count + 1`
+# Generate users
+for n in `seq 1 $count_users`; do
+	cat - > users/user${n}.xml <<-EOF
+		<?xml version="1.0"?>
+		<user id="user${n}" xmlns="http://www.wyona.org/security/1.0">
+		  <name>Example User ${n}</name>
+		  <email>user${n}@yanel.org</email>
+		  <language>en</language>
+		  <password>5ebe2294ecd0e0f08eab7690d2a6ee69</password>
+		  <foo:custom xmlns:foo="http://www.foo.bar/security/1.0">
+		    <foo:role>admin</foo:role>
+		  </foo:custom>
+		  <groups/>
+		</user>
+	EOF
 done


More information about the Yanel-development mailing list