X-Git-Url: http://git.rot13.org/?p=cloudstore.git;a=blobdiff_plain;f=create-user.sh;h=54d81a12c259d384d06c0b60f93e28419cc963d9;hp=52bd56ba9769cbf535c8eb06a338811cf6078fc7;hb=1af8a6c4eb9976794ce6ce0084d9ac3484022c06;hpb=2be45b965e9b6d4929b8128fb51fa70476596686 diff --git a/create-user.sh b/create-user.sh index 52bd56b..54d81a1 100755 --- a/create-user.sh +++ b/create-user.sh @@ -6,38 +6,13 @@ email=$1 password=$2 quota=$3 -if [ -z "$email" -o -z "$password" ]; then +if [ -z "$email" -o -z "$password" -o ]; then echo "Usage: $0 email password [quota]" exit 1 fi -test -z "$quota" && quota=200k +test -z "$quota" && quota=200000 -if passwd=`grep ":$email:" /var/lib/extrausers/passwd` ; then - echo "## $passwd" - uid=`echo $passwd | cut -d: -f3` -else - uid=`tail -1 /var/lib/extrausers/passwd | cut -d: -f3` - echo $uid - 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 - zfs set userquota@u$uid=$quota $ZSLICE -fi -secrets="$SLICE/$uid/.secrets" -grep "^u$uid:" $secrets || 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 +perl -Ilib -MCloudStore::API -e 'print "u" . CloudStore::API->new("s1")->create_user(@ARGV),$/' $email $password $quota -id u$uid -zfs get userquota@u$uid $ZSLICE -zfs get userused@u$uid $ZSLICE -cat $secrets