--- /dev/null
+#!/bin/bash
+
+USERNM=$1
+REALNM=$2
+EMAILADDR=$4
+PWFILE=/var/lib/portal/$USERNM
+
+if test -z "$USERNM"; then
+ echo Usage: create-user-wrapper USERNAME \'NAME SURNAME\' [EMAIL]
+ exit 1
+fi
+
+if test -z "$REALNM"; then
+ echo Usage: create-user-wrapper USERNAME \'NAME SURNAME\' [EMAIL]
+ exit 1
+fi
+
+
+
+#
+# Create user
+#
+/afs/hcoop.net/common/etc/scripts/create-user $USERNM || \
+( echo "create-user $USERNM failed" && exit 2 )
+
+#
+# Entry in LDAP is created, set real name
+#
+echo "
+dn: uid=$USERNM,ou=People,dc=hcoop,dc=net
+changetype: modify
+replace: gecos
+gecos: $REALNM
+" | sudo ldapmodify -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret || \
+ (echo Error modifying LDAP entry && exit 3 )
+
+#
+# Now set the password
+#
+if ! test -r "$PWFILE"; then
+ echo "Skipping password set from $PWFILE (doesn't exist or permission denied)"
+ #exit 4
+else
+ echo Setting password from $PWFILE
+ sudo sh -c "cat $PWFILE | tee -| /afs/hcoop.net/common/etc/scripts/change-user-password $USERNM" || \
+ ( echo "cat $PWFILE | tee - | change-user-password $USERNM failed" && exit 5 )
+
+ # Delete password file
+ #sudo rm -- "$PWFILE"
+ echo "Not deleting $PWFILE. Enable it in the script when you want"
+fi
+
+
+#
+# Set email forwarding
+#
+if test -z "$EMAILADDR"; then
+ echo "Skipping email forwarding, no email address was specified."
+else
+ echo setting email forward to "$EMAILADDR"
+ sh -c "echo '$EMAILADDR' > ~$USERNM/.public/.forward" || \
+ ( echo "Failed to set forward address" && exit 6 )
+fi
+
+#
+# Done
+#
+echo All done.
+