From 6157acaa8da2aec73ed1958ad02cdb9b6c300aaf Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Sun, 6 Jan 2013 03:51:29 -0500 Subject: [PATCH] Set initial user password from MemberApp in database The portal password files are not being created for whatever reason, and the data is there in the database so there's no real point not using it anyway. --- new-user | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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 -- 2.20.1