remove obsolete init file
[cloudstore.git] / create-user.sh
index 244d6f9..54d81a1 100755 (executable)
@@ -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