From 237fd1012dfc74827068e3e63a871c9edc93779e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 4 Sep 2011 16:45:49 +0000 Subject: [PATCH] rsync server now creates user objects --- bin/debian-install.sh | 2 +- rsync-piper.pl | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/debian-install.sh b/bin/debian-install.sh index 358b313..73a7df1 100755 --- a/bin/debian-install.sh +++ b/bin/debian-install.sh @@ -1,5 +1,5 @@ #!/bin/sh -x sudo apt-get install libautodie-perl libdata-dump-perl libfile-slurp-perl libtime-hires-perl \ -libjson-xs-perl libfile-path-perl +libjson-xs-perl libfile-path-perl libmodule-refresh-perl diff --git a/rsync-piper.pl b/rsync-piper.pl index f46d22b..bcab4cd 100755 --- a/rsync-piper.pl +++ b/rsync-piper.pl @@ -9,6 +9,7 @@ use IO::Select; use Time::HiRes; use Data::Dump qw(dump); use English; +use Module::Refresh; use lib 'lib'; use CloudStore::Couchbase; @@ -53,6 +54,8 @@ if ( $ENV{SQL} ) { exit 1; } +my $store = CloudStore::Couchbase->new; + mkdir "$dir/var" if ! -e "$dir/var"; unlink $log_fifo if -f $log_fifo; @@ -106,6 +109,18 @@ __RSYNC_MODULE__ print "INFO: added $login = $auth_users\n"; + my $quota = read_file "$path/quota" if -e "$path/quota"; + chomp $quota && $quota * 1; + $quota ||= 100 * 1024; # Kb - XXX default quota + + $store->user_set({ + login => $login, + path => $path, + secrets => [ @secrets ], + quota => $quota, + port => $port, + }); + } else { warn "skipped $login: $!"; } @@ -175,9 +190,9 @@ $gearman->job_servers('127.0.0.1:4730'); while(1) { warn "# reading log output from $log_fifo\n"; open(my $fifo, '<', $log_fifo); - my $rsync = CloudStore::Couchbase->new; while( my $line = <$fifo> ) { - die $line if $line =~ /rsync error:/; + Module::Refresh->refresh; + die "ERROR: $line" if $line =~ /rsync error:/; chomp $line; print $line, $/; @@ -202,7 +217,7 @@ while(1) { print ">>> data ",dump( \%data ) if $ENV{DEBUG}; - $rsync->transfer( \%data ); + $store->transfer( \%data ); =for gearman $gearman->dispatch_background( 'rsync_transfer' => $json ); =cut -- 2.20.1