X-Git-Url: https://git.hcoop.net/hcoop/scripts.git/blobdiff_plain/0dceb8135d8e32bdb39b2beda0f23c6625d3c63e..6157acaa8da2aec73ed1958ad02cdb9b6c300aaf:/new-user diff --git a/new-user b/new-user index 48ca9ab..56d7845 100755 --- a/new-user +++ b/new-user @@ -3,7 +3,6 @@ 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] @@ -15,12 +14,13 @@ if test -z "$REALNM"; then exit 1 fi +INITPW=$(sudo -u hcoop psql hcoop_hcoop -tc "select unix_passwd from MemberApp where name = '${USERNM}';") # # Create user # -ssh -K fritz.hcoop.net /afs/hcoop.net/common/etc/scripts/create-user $USERNM || \ +/afs/hcoop.net/common/etc/scripts/create-user $USERNM || \ ( echo "create-user $USERNM failed" && exit 2 ) # @@ -37,18 +37,14 @@ ssh -K fritz.hcoop.net /afs/hcoop.net/common/etc/scripts/create-user $USERNM || # # Now set the password # -if ! test -r "$PWFILE"; then +if test -z "$INITPW"; then echo "Skipping password set from $PWFILE (doesn't exist or permission denied)" #exit 4 else - echo Setting password from $PWFILE + echo Setting password from database actual_user=`whoami` - sudo sh -c "cat $PWFILE | tee -| ssh -K ${actual_user}@fritz.hcoop.net /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" + sudo sh -c "echo $INITPW | tee -| /afs/hcoop.net/common/etc/scripts/change-user-password $USERNM" || \ + ( echo "echo XXX | tee - | change-user-password $USERNM failed" && exit 5 ) fi