100k quota for test user u2002
[cloudstore.git] / create-user.sh
index 244d6f9..56c9459 100755 (executable)
@@ -1,31 +1,29 @@
-#!/bin/sh -xe
+#!/bin/sh -e
 
 . ./env.sh
 
 email=$1
 password=$2
 quota=$3
-host=$4
 
 if [ -z "$email" -o -z "$password" ]; then
-       echo "Usage: $0 email password [quota] [host]"
+       echo "Usage: $0 email password [quota]"
        exit 1
 fi
 
 test -z "$quota" && quota=200k
 
 if passwd=`grep ":$email:" /var/lib/extrausers/passwd` ; then
-       echo "## $passwd"
+       echo "## $passwd" 1>&2
        uid=`echo $passwd | cut -d: -f3`
 else
        uid=`tail -1 /var/lib/extrausers/passwd | cut -d: -f3`
-       echo $uid
+       echo "## last uid: $uid" 1>&2
        uid=`expr $uid + 1`
        echo "u$uid:$password:$uid:$PORT:$email:$SLICE/$uid:/bin/false" \
                >> /var/lib/extrausers/passwd
 fi
 
-ZSLICE=`echo $SLICE | sed 's!^/!!'`
 if [ ! -e $SLICE/$uid ] ; then
        mkdir $SLICE/$uid
        chown $uid:$PORT $SLICE/$uid
@@ -33,12 +31,14 @@ if [ ! -e $SLICE/$uid ] ; then
 fi
 
 secrets="$SLICE/$uid/.secrets"
-test ! -z "$host" && login="$login+$host"
-grep "^$login:" $secrets || echo "$login:$password" >> $secrets
+grep "^u$uid:" $secrets 1>&2 || echo "u$uid:$password" >> $secrets
 md5mail=`echo -n $email | md5sum | cut -d" " -f1`
 md5passwd=`echo -n $password | md5sum | cut -d" " -f1`
-grep "^$md5mail:" $secrets || echo "$md5mail:$md5passwd" >> $secrets
+grep "^$md5mail:" $secrets 1>&2 || echo "$md5mail:$md5passwd" >> $secrets
 
-id u$uid
-zfs get userquota@u$uid $ZSLICE
-zfs get userused@u$uid $ZSLICE
+id u$uid 1>&2
+zfs get userquota@u$uid $ZSLICE 1>&2
+zfs get userused@u$uid $ZSLICE 1>&2
+cat $secrets 1>&2
+
+echo "u$uid"