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

use Data::Dump qw(dump);

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

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

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

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

if ( $user->{usage} > $user->{quota} ) {
	warn $store->status( $login => "ERROR: $login $user->{usage} > quota $user->{quota}" );
	exit 1;
} else {
	warn $store->status( $login => "OK: $login $user->{usage} < quota $user->{quota}" );
	exit 0;
}
