Set initial user password from MemberApp in database
authorClinton Ebadi <clinton@unknownlamer.org>
Sun, 6 Jan 2013 08:51:29 +0000 (03:51 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Sun, 6 Jan 2013 08:51:29 +0000 (03:51 -0500)
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

index 48ca9ab..56d7845 100755 (executable)
--- a/new-user
+++ b/new-user
@@ -3,7 +3,6 @@
 USERNM=$1
 REALNM=$2
 EMAILADDR=$3
 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]
 
 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
 
        exit 1
 fi
 
+INITPW=$(sudo -u hcoop psql hcoop_hcoop -tc "select unix_passwd from MemberApp where name = '${USERNM}';")
 
 
 #
 # Create user
 #
 
 
 #
 # 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 )
 
 #
 ( 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
 #
 #
 # 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 "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`
        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
 
 
 fi