#!/usr/bin/perl -T
use warnings;
use strict;

use Data::Dump qw(dump);

use lib '/srv/cloudstore/lib';
use CloudStore::Store;

my $store = CloudStore::Store->new;

my $login = $ENV{RSYNC_MODULE_NAME} || die "no RSYNC_MODULE_NAME";

exit 0; # FIXME

my $user  = $store->user_get($login);

my $ok = $user->{usage} <= $user->{quota};

print "$login ", $store->status( $login => sprintf 'quota: %s %d %s %d'
	, ( $ok ? 'OK' : 'ERROR' )
	, $user->{usage}
	, ( $ok ? '<=' : '>' )
	, $user->{quota}
),$/;

my $exit = $ok ? 0 : 1;
warn "# exit $exit" if $ENV{DEBUG};
exit $exit;
