X-Git-Url: http://git.rot13.org/?p=cloudstore.git;a=blobdiff_plain;f=create-user.sh;h=54d81a12c259d384d06c0b60f93e28419cc963d9;hp=244d6f91abb9ccb15ce5817fd189dabde2a222b6;hb=c74470045de1527a2ba7a10fd5f3f4d53c71624b;hpb=139feb5df0a4ea8af88557640a96a4f854a970d1 diff --git a/create-user.sh b/create-user.sh index 244d6f9..54d81a1 100755 --- a/create-user.sh +++ b/create-user.sh @@ -1,44 +1,18 @@ -#!/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]" +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" -test ! -z "$host" && login="$login+$host" -grep "^$login:" $secrets || echo "$login:$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