58 lines
1.4 KiB
Perl
Executable file
58 lines
1.4 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
#
|
|
# Checks the input dir for req-<version>-<start>-<count> files at regular
|
|
# intervals and generate planets accordingly.
|
|
#
|
|
# Syntax : ./planetmaker.pl
|
|
#
|
|
|
|
use strict; use warnings;
|
|
|
|
use FindBin qw($Bin);
|
|
require File::Temp;
|
|
use File::Temp ();
|
|
use File::Temp qw/ :seekable /;
|
|
|
|
my $outDir = $ENV{PGEN_OUTPUT} || "/tmp/pgen-out";
|
|
my $inDir = $ENV{PGEN_INPUT} || "/tmp/pgen-input";
|
|
|
|
chdir $Bin;
|
|
print "Entering main loop\n";
|
|
print " Input directory: $inDir\n";
|
|
print " Output directory: $outDir\n";
|
|
mkdir($inDir, 01777) unless -d $inDir;
|
|
mkdir($outDir, 00755) unless -d $outDir;
|
|
|
|
while (1) {
|
|
opendir(my $dir, $inDir) or die "Could not open $inDir: $! $_";
|
|
my @list = grep {
|
|
-f "$inDir/$_" && /^req-[a-z0-9]+-\d+-\d+$/
|
|
} readdir $dir;
|
|
close $dir;
|
|
|
|
foreach my $name (@list) {
|
|
unlink("$inDir/$name");
|
|
my ($junk,$version,$first,$count) = split /-/, $name;
|
|
print "Generating planets for $version.\n";
|
|
print " First planet $first.\n";
|
|
print " $count planets\n";
|
|
|
|
my $verDir = "$outDir/$version";
|
|
foreach my $suffix ("", "/l", "/s") {
|
|
my $dir = $verDir . $suffix;
|
|
mkdir($dir) unless -d $dir
|
|
}
|
|
|
|
for (my $i=$first;$i<$first+$count;$i++) {
|
|
my $fn = File::Temp->new(SUFFIX => '.pov');
|
|
`./generate.pl $fn`;
|
|
`povray +W80 +H80 +O$verDir/l/$i.png -D -V $fn >/dev/null 2>&1`;
|
|
`povray +W30 +H30 +O$verDir/s/$i.png -D -V $fn >/dev/null 2>&1`;
|
|
unlink($fn);
|
|
}
|
|
}
|
|
|
|
sleep(60);
|
|
print "Sleeping...\n";
|
|
}
|