Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: dc15c1e8f3
Fetching contributors…

Cannot retrieve contributors at this time

executable file 61 lines (49 sloc) 1.172 kb
#!/usr/bin/perl
# Examples
#
# start-sheepdog -n=5 -d=/tmp/1203
$port = 7000;
$nr = 1;
@hosts = ();
$home = ".";
$dir = "/tmp/".rand(100);
while (@ARGV && $ARGV[0] =~ m/^-/) {
$_ = shift(@ARGV);
if (m/^-n=([0-9]*)$/) {
$nr = $1;
} elsif (m/^-d=(.*)$/) {
$dir = $1;
} elsif (m/^-h=(.*)$/) {
@hosts = &expand(split ':', $1);
} elsif (m/^-H=(.*)$/) {
$home = $1;
}
}
print("killing all sheepdogs...\n\n");
system("$home/script/stop-sheepdog [0-100]");
my %count;
foreach $host (grep {!$count{$_}++} @hosts) {
system("$home/script/stop-sheepdog [0-100]");
}
for ($i = 0; $i < $nr; $i++, $port++) {
$_dir = $dir.$i;
if ($hosts[$i]) {
print("ssh $hosts[$i] $home/sheep/sheep --port $port $_dir -d\n");
system("ssh $hosts[$i] $home/sheep/sheep --port $port $_dir -d");
} else {
print("$home/sheep/sheep --port $port $_dir -d\n");
system("$home/sheep/sheep --port $port $_dir -d");
}
}
sub expand {
my @hosts = @_;
my @ret = ();
for my $host (@hosts) {
if ($host =~ /\[(\d+)-(\d+)\]/) {
push @ret, &expand(map { $` . $_ . $' } ($1..$2));
} else {
push @ret, $host;
}
}
return @ret;
}
Jump to Line
Something went wrong with that request. Please try again.