1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
|
|
3 |
|
package Sack::Server; |
4 |
|
|
5 |
use warnings; |
use warnings; |
6 |
use strict; |
use strict; |
7 |
|
|
13 |
use File::Slurp; |
use File::Slurp; |
14 |
use Cwd qw(abs_path); |
use Cwd qw(abs_path); |
15 |
|
|
16 |
my @cloud = qw(localhost tab.lan llin.lan); |
my @cloud; |
17 |
|
my $cloud_path = $ENV{CLOUD} || die "start with: CLOUD=etc/cloud perl -I/srv/Sack/lib $0\n"; |
|
my $cloud_path = $ENV{CLOUD} || '/srv/Sack/etc/lib'; |
|
18 |
@cloud = read_file $cloud_path; |
@cloud = read_file $cloud_path; |
19 |
@cloud = map { chomp $_; $_ } @cloud; |
@cloud = map { chomp $_; $_ } @cloud; |
20 |
|
|
34 |
push @{ $info->{$port} }, [ @_ ]; |
push @{ $info->{$port} }, [ @_ ]; |
35 |
} |
} |
36 |
|
|
37 |
sub fork_node { |
sub fork_ssh { |
38 |
my ( $port, $host ) = @_; |
my ( $port, $host ) = @_; |
39 |
|
|
40 |
if ( my $pid = fork ) { |
if ( my $pid = fork ) { |
57 |
|
|
58 |
foreach my $host ( @cloud ) { |
foreach my $host ( @cloud ) { |
59 |
system "find /srv/Sack/ | cpio --create --dereference | ssh -T -F $cloud_path.ssh $host cpio --extract --make-directories --unconditional"; |
system "find /srv/Sack/ | cpio --create --dereference | ssh -T -F $cloud_path.ssh $host cpio --extract --make-directories --unconditional"; |
60 |
fork_node( $node_port++, $host ); |
fork_ssh( $node_port++, $host ); |
61 |
} |
} |
62 |
|
|
63 |
my $session; |
my $session; |