272 |
return $out; |
return $out; |
273 |
} |
} |
274 |
|
|
275 |
|
sub update_node { |
276 |
|
my $self = shift; |
277 |
|
my $updated; |
278 |
|
foreach my $port ( @_ ) { |
279 |
|
my $host = $self->{port_on_host}->{$port} || die "no port $port in ",dump $self; |
280 |
|
next if $host =~ m{(localhost|127\.)}; |
281 |
|
next if $updated->{$host}++; |
282 |
|
warn "update $host $Sack::VERSION\n"; |
283 |
|
system("find /srv/Sack/ | cpio --create | ssh -F etc/lib.ssh $host cpio --extract --make-directories --unconditional") == 0 and $self->restart_nodes( $port ); |
284 |
|
} |
285 |
|
} |
286 |
|
|
287 |
sub command { |
sub command { |
288 |
my ( $self, $cmd ) = @_; |
my ( $self, $cmd ) = @_; |
289 |
|
|
304 |
} elsif ( $cmd =~ m{^i} ) { |
} elsif ( $cmd =~ m{^i} ) { |
305 |
$self->send_to_all({ info => 1 }); |
$self->send_to_all({ info => 1 }); |
306 |
my $info = $self->get_from_all; |
my $info = $self->get_from_all; |
307 |
|
warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n"; |
308 |
foreach my $port ( $self->connected ) { |
foreach my $port ( $self->connected ) { |
309 |
warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n"; |
warn "[$port] $self->{port_on_host}->{$port} $pids->{$port} ", dump( $info->{$port} ), "\n"; |
310 |
warn "[$port] $self->{port_on_host}->{$port} ", dump( $info->{$port} ), "\n"; |
if ( my $version = $info->{version} ) { |
311 |
|
warn "# $version $Sack::VERSION\n"; |
312 |
|
$self->update_node( $port ) if $version ne $Sack::VERSION; |
313 |
|
} |
314 |
} |
} |
315 |
} elsif ( $cmd =~ m{^u} ) { |
} elsif ( $cmd =~ m{^u} ) { |
316 |
my $updated; |
$self->update_node( $self->connected ); |
|
foreach my $host ( $self->connected ) { |
|
|
next if $updated->{$host}++; |
|
|
warn "update $host\n"; |
|
|
system "find /srv/Sack/ | cpio --create | ssh -F etc/lib.ssh $host cpio --extract --make-directories --unconditional"; |
|
|
} |
|
317 |
} elsif ( $cmd =~ m{^sh\s+(.+)} ) { |
} elsif ( $cmd =~ m{^sh\s+(.+)} ) { |
318 |
$self->send_to_all({ sh => $1 }); |
$self->send_to_all({ sh => $1 }); |
319 |
my $sh = $self->get_from_all; |
my $sh = $self->get_from_all; |