prerender_all.in 1.7 KB
Newer Older
Chad Barb's avatar
Chad Barb committed
1 2 3
#!/usr/bin/perl -w

#
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Chad Barb's avatar
Chad Barb committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#

use English;
use Getopt::Std;

# Configure variables
my $TB       = "@prefix@";

use lib '@prefix@/lib';
use libdb;

# Turn off line buffering on output
$| = 1;

# Untaint the path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

42
my $PRERENDER_CMD = "@prefix@/libexec/vis/prerender -f ";
Chad Barb's avatar
Chad Barb committed
43 44

sub usage {
45
    die "Usage: prerender_all [-v] [-t]";
Chad Barb's avatar
Chad Barb committed
46 47
}

48
my $optlist = "vt";
Chad Barb's avatar
Chad Barb committed
49 50 51 52 53 54 55 56 57 58

%options = ();

if (!getopts($optlist, \%options)) { usage; }
if (@ARGV != 0) { usage; }

if ( defined($options{"v"}) ) { 
    $PRERENDER_CMD .= " -v";
}

59 60 61 62
if ( defined($options{"t"}) ) { 
    $PRERENDER_CMD .= " -t";
}

Chad Barb's avatar
Chad Barb committed
63 64 65 66 67 68 69 70 71
my $result = DBQueryFatal("SELECT pid,eid FROM experiments");

while (my ($pid,$eid) = $result->fetchrow) {
    print "Prerendering $pid/$eid\n";
    if (system("$PRERENDER_CMD $pid $eid") != 0) {
	print STDERR "Prerender of $pid/$eid FAILED!\n";
    }
}

72 73


Chad Barb's avatar
Chad Barb committed
74
exit(0);