From 305be8a46c8acf6a612d6ca4b1a5dee6dd469403 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 6 Dec 2017 17:16:32 +0100 Subject: [PATCH] Add command "clusterd push files..." The command "clusterd push file..." has a new syntax with a command verb. (as opposed to "clusterd --push file") The push command is distributed via the area routers to the cluster daemons on all nodes. It is intended that the cluster daemons call back over tcp to the originator to pull the file if needed. --- clusterd | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/clusterd b/clusterd index fcefac3..1cf5f3f 100755 --- a/clusterd +++ b/clusterd @@ -1667,6 +1667,22 @@ sub cmd_msg { } } +sub cmd_push { + my @files=@_; + for my $filename (@files) { + $filename =~ m"^/" or return warn "$filename: please use absolute path\n"; + -e $filename or die "$filename: no such file\n"; + } + sync_cluster_pw() or die "$CLUSTER_PW_FILE: $!\n"; + $donald_s=new My::Select::INET(Proto=>'udp') or die "$!\n"; + for my $filename (@files) { + my $st=Donald::FileInfo->lstat($filename); + defined $st or die "$filename: $!\n"; + $st->type eq 'F' or die "$filename: only plain files currently supported\n"; + udp_broadcast_message($donald_s,'push',$my_ip,$st); + } +} + #------------------------------------------------------------ use constant USAGE => <<'__EOF__'; @@ -1690,6 +1706,8 @@ usage: $0 [options] --foreground # stay in foreground, log to stderr --syslog # log to syslog instead of stderr + push files.... # push files over tcp + __EOF__ use Getopt::Long; @@ -1784,5 +1802,12 @@ if (defined $options{'push'}) { } elsif ($options{'kill'}) { Donald::Tools::kill_previous_server('clusterd'); } else { - die USAGE; + @ARGV or die USAGE; + my ($cmd,@args)=@ARGV; + if ($cmd eq 'push') { + @args>0 or die USAGE; + cmd_push(@args); + } else { + die USAGE; + } }