#!/bin/bash USERNM=$1 REALNM=$2 EMAILADDR=$3 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 # ssh -K fritz.hcoop.net /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" FORWARD_PATH=$(sh -c "echo ~$USERNM/.public/.forward") echo "$EMAILADDR" > $FORWARD_PATH || \ ( echo "Failed to set forward address" && exit 6 ) chown $USERNM $FORWARD_PATH fi # # Done # echo All done.