test.sh
- excercise rsync server to test basic operation and deduplication
+
+Installation on Debian:
+
+$ ./bin/debian-install.sh
+
+Disk quota calculation depends on custom POSIX ids created using libnss-extrausers
+so ensure that /etc/nsswitch.conf has extrausers enabled:
+
+$ egrep '^(passwd|group):' /etc/nsswitch.conf
+passwd: compat extrausers
+group: compat extrausers
+
+Install default test user and first slice:
+
+$ sudo cp -v extrausers/* /var/lib/extrausers/
+`extrausers/group' -> `/var/lib/extrausers/group'
+`extrausers/passwd' -> `/var/lib/extrausers/passwd'
+
#!/bin/sh -xe
-login=$1
+. ./env.sh
+
+email=$1
password=$2
-host=$3
+quota=$3
+host=$4
-if [ -z "$login" -o -z "$password" ]; then
- echo "Usage: $0 login password [host]"
+if [ -z "$email" -o -z "$password" ]; then
+ echo "Usage: $0 email password [quota] [host]"
exit 1
fi
-mkdir -p users/$login/blob
-secrets="users/$login/secrets"
+test -z "$quota" && quota=200k
+
+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
-cat $secrets
+md5mail=`echo -n $email | md5sum | cut -d" " -f1`
+md5passwd=`echo -n $password | md5sum | cut -d" " -f1`
+grep "^$md5mail:" $secrets || echo "$md5mail:$md5passwd" >> $secrets
+
+id u$uid
+zfs get userquota@u$uid $ZSLICE
+zfs get userused@u$uid $ZSLICE
}
-./remove-user.sh test
+#./remove-user.sh u2000
-./create-user.sh test secret
-./create-user.sh test secret localhost
+#./create-user.sh u2000 secret
+#./create-user.sh u2000 secret localhost
-./remove-user.sh test2
-./create-user.sh test2 secret
+#./remove-user.sh u2001
+#./create-user.sh u2001 secret
dir=/tmp/test
rm -Rf "$dir"