# don't check secrets file permission (uid)
strict modes = no
-#pre-xfer exec = /srv/cloudstore/pre-xfer.sh
-#post-xfer exec = /srv/cloudstore/post-xfer.sh
+pre-xfer exec = /srv/cloudstore/rsync-xfer-trigger.pl
+post-xfer exec = /srv/cloudstore/rsync-xfer-trigger.pl
};
write_file $cfg_file, $rsync_config;
warn "created $cfg_file ", -s $cfg_file, " bytes\n";
-if ( -e $pid_file ) {
+sub rsync_running_pid {
+ return unless -e $pid_file;
my $pid = read_file $pid_file;
chomp($pid);
+ return $pid;
+}
+
+if ( my $pid = rsync_running_pid ) {
if ( kill 0, $pid ) {
warn "found rsync pid $pid\n";
kill 2, $pid;
=cut
while(1) {
+ die "no rsync running" unless kill 0, rsync_running_pid;
warn "# reading log output from $log_fifo\n";
open(my $fifo, '<', $log_fifo);
while( my $line = <$fifo> ) {
Module::Refresh->refresh;
- die "ERROR: $line" if $line =~ /rsync error:/;
chomp $line;
print $line, $/;
$gearman->dispatch_background( 'rsync_transfer' => $json );
=cut
+ die "no rsync running" unless kill 0, rsync_running_pid;
}
}
close($fifo);
--- /dev/null
+#!/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 $usage = $store->usage({ login => $login });
+my $user = $store->user_get($login);
+
+if ( $usage > $user->{quota} ) {
+ warn "ERROR: $login $usage > quota $user->{quota}";
+ exit 1;
+} else {
+ warn "OK: $login $usage < quota $user->{quota}";
+ exit 0;
+}