This file is indexed.

/usr/bin/pegasus-config is in pegasus-wms 4.4.0+dfsg-7.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#!/usr/bin/env perl
#
# prototype for a tool like pkg-config that tells us all kinds of
# interesting things about Pegasus. This is mainly destined to be
# used inside scripts to determine various configuration options,
# locations and directories. 
#
# $Id$
#
use 5.006;
use strict;
use Cwd; 
use File::Spec;
use File::Basename;
use Getopt::Long qw(:config bundling no_ignore_case);
use POSIX (); 
use Sys::Hostname; 

my $tmpdir = $ENV{'MY_TMP'} ||  # MY_TMP to override standard settings
    $ENV{TMP} ||                # standard
    $ENV{TEMP} ||               # windows standard
    $ENV{TMPDIR} ||             # also somewhat used
    File::Spec->tmpdir() ||     # OK, this gets used if all above fail
    ( -d '/scratch' ? '/scratch' : '/tmp' ); # last resort
my $userdir = $ENV{HOME} || (getpwuid($>))[7] || $tmpdir; # user $HOME

my $bin_dir = Cwd::abs_path(dirname($0));

# basically PEGASUS_HOME - but let's not expose that anymore
my $base_dir	= dirname($bin_dir);
my $version     = '4.4.0';
my $lib         = 'lib'; # lib64 for 64bit RPMS
if (substr($lib, 0, 1) eq '@') {
    $lib = "lib";
}
my $python_lib  = 'lib/python2.7/dist-packages';
if (substr($python_lib, 0, 1) eq '@') {
    $python_lib = "lib/pegasus/python";
}
my $conf_dir	= File::Spec->catdir( $base_dir, 'etc' );
my $share_dir	= File::Spec->catdir( $base_dir, 'share', 'pegasus' );
my $java_dir	= File::Spec->catdir( $share_dir, 'java' );
my $perl_dir	= File::Spec->catdir( $base_dir, $lib, 'pegasus', 'perl' );
my $python_dir	= File::Spec->catdir( $base_dir, $python_lib );
my $python_externals_dir = File::Spec->catdir( $base_dir, $lib, 'pegasus', 'externals', 'python' );
my $php_dir	= File::Spec->catdir( $base_dir, $lib, 'pegasus', 'php' );
my $js_dir	= File::Spec->catdir( $base_dir, $lib, 'pegasus', 'javascript' );
my $schema_dir	= File::Spec->catdir( $share_dir, 'schema' );
my $extra_classpath = '';

# for development - running out of a source checkout
my $test = File::Spec->catdir( $base_dir, 'build', 'classes' );
$extra_classpath = $test if -e $test;


# in native packaging mode, some directories move
if ($base_dir eq "/usr") {
    $conf_dir = "/etc/pegasus";
}

# classpath
my @jars = sort(<$java_dir/*.jar>);
if ($extra_classpath ne "") {
    unshift(@jars, $extra_classpath);
}
my $classpath = join(":", @jars);
if ($ENV{"CLASSPATH"} ne "") {
    $classpath = $classpath . ":" . $ENV{"CLASSPATH"};
}

sub usage {
    my $app = basename($0); 
    print << "EOF";
Usage: $app [argument]

This is NOT an application to configure Pegasus, but an application
to query the current Pegasus installation.

Arguments:
 -h|--help            Print this help and exit.
 -V|--version         Print Pegasus version information and exit. 

 --perl-dump          Dumps all settings in perl format as separate variables.
 --perl-hash          Dumps all settings in perl format as single perl hash.
 --python-dump        Dumps all settings in python format.
 --sh-dump            Dumps all settings in shell format.

 --bin                Print the directory containing Pegasus binaries.
 --conf               Print the directory containing configuration files.
 --java               Print the directory containing the jars.
 --perl               Print the directory to include into your PERL5LIB.
 --python             Print the directory to include into your PYTHONPATH.
 --python-externals   Print the directory to the external Python libraries.
 --schema             Print the directory containing schemas.
 --classpath          Builds a classpath containing the Pegasus jars.
 --noeoln             Do not produce a end-of-line after output. This is useful
                      when being called from non-shell backticks in scripts.
                      Order is important for this option; specify first.
 --local-site [d]     Create a site catalog entry for site "local". This is
                      only an XML snippet without root element nor XML
                      headers. The optional argument "d" points to the mount
                      point to use. If not specified, defaults to the user\'s
                      \$HOME directory.
 --full-local [d]     Create a complete site catalog with only site "local".
                      The an XML snippet without root element nor XML headers.
                      The optional argument "d" points to the mount point to
                      use. If not specified, defaults to the user\'s \$HOME
                      directory.

EOF
    exit 1;
}

sub find_exec($;@) {
    # purpose: determine location of given binary in $PATH
    # paramtr: $program (IN): executable basename to look for
    #          @extra (opt. IN): additional directories to search
    # returns: fully qualified path to binary, undef if not found
    my $program = shift;
    foreach my $dir ( ( File::Spec->path, @_ ) ) {
        my $fs = File::Spec->catfile( $dir, $program );
        return $fs if -x $fs;
    }
    undef;
}

sub site_snippet($) {
    my $home = shift;
    my @u = POSIX::uname(); 
    $u[2] =~ s/^(\d+(\.\d+(\.\d+)?)?).*/$1/;
    $u[4] =~ s/i.86/x86/;

    # check for presence of Globus
    my $g_l = $ENV{'GLOBUS_LOCATION'};
    unless ( defined $g_l ) { 
        my $gr = find_exec( 'globusrun' ); 
        if ( defined $gr && -x $gr ) { 
            # OK, so we got Globus. Guess the globus location
            $g_l = dirname( Cwd::abs_path(dirname($gr)) ); 
        }
        undef $g_l unless -d $g_l; 
    }

    print "  <!-- site: local -->\n";
    print "  <site handle=\"local\" arch=\"", lc($u[4]), "\" os=\"", uc($u[0]), "\">\n";

    # so we got Globus installed. Let's check, if there are any
    # services associated with this Globus on this site
    if ( defined $g_l ) { 
	my $g_v = `globus-version`; 
	chomp($g_v); 
	my @g_v = split /\./, $g_v; 
	my $type = $g_v[0] >= 5 ? 'gt5' : 'gt2'; 

	my $dir = File::Spec->catdir( $g_l, 'etc', 'grid-services' ); 
	my $glob = File::Spec->catfile( $dir, 'jobmanager-*' ); 
	my $fqdn = Sys::Hostname::hostname(); 
	foreach my $jm ( CORE::glob($glob) ) {
	    if ( open( J, "<$jm" ) ) {
		my %grmblftz = ( 'fork' => 'Fork',
				 'condor' => 'Condor',
				 'pbs' => 'PBS',
				 'lsf' => 'LSF' ); 
		chomp( $_ = <J> );
		close J; 
		my $basejm = basename($jm); 
		my $jobtype = ( $jm =~ /-fork$/ ? 'auxillary' : 'compute' ); 
		if ( /-type (\S+)/ ) { 
		    my $t = lc($1); 
		    print( '    <grid type="', $type, 
			   '" contact="', $fqdn, '/', $basejm, 
			   '" scheduler="', ( $grmblftz{$t} || ucfirst($t) ), 
			   '" jobtype="', $jobtype, "\" />\n" ); 
		}
	    }
	}
    }

    print "    <head-fs>\n";
    print "      <scratch>\n";
    print "\t<shared>\n"; 
    print "\t  <file-server protocol=\"file\" url=\"file://\"\n\t\tmount-point=\"$home\" />\n";
    print "\t  <internal-mount-point\n\t\tmount-point=\"$home\" />\n";
    print "\t</shared>\n"; 
    print "      </scratch>\n"; 
    print "      <storage>\n";
    print "\t<shared>\n";
    print "\t  <file-server protocol=\"file\" url=\"file://\"\n\t\tmount-point=\"$home\" />\n";
    print "\t  <internal-mount-point\n\t\tmount-point=\"$home\" />\n";
    print "\t</shared>\n";
    print "      </storage>\n";
    print "    </head-fs>\n"; 
    print "    <replica-catalog type=\"LRC\" url=\"dummyValue.url.edu\" />\n";
    print "    <profile namespace=\"env\" key=\"HOME\">$userdir</profile>\n"; 
    if ( defined $g_l ) {
        print "    <profile namespace=\"env\" key=\"GLOBUS_LOCATION\">$g_l</profile>\n"; 
    }
    if ( exists $ENV{'LD_LIBRARY_PATH'} ) { 
        print( "    <profile namespace=\"env\" key=\"LD_LIBRARY_PATH\">", 
            $ENV{LD_LIBRARY_PATH}, "</profile>\n" ); 
    }
    print "  </site>\n";
}

# Parse command-line options.
usage() unless @ARGV;
my $eoln = 1; 
GetOptions( "help|h" => \&usage
    , 'eoln|crlf!' => \$eoln
    , 'version|V' => sub {
        print $version;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'perl-hash' => sub {
	print << "EOF";
use vars qw(\%pegasus);
\%pegasus = 
	( bin => \"$bin_dir\"
	, conf => \"$conf_dir\"
	, java => \"$java_dir\"
	, perl => \"$perl_dir\"
	, python => \"$python_dir\"
	, pyexts => \"$python_externals_dir\"
	, php => \"$php_dir\"
	, js => \"$js_dir\"
	, share => \"$share_dir\"
	, schema => \"$schema_dir\"
	); 
unshift( \@INC, \$pegasus{perl} );
EOF
    exit 0; 
    }
    , 'perl-dump' => sub {
	# This won't work, because the "my" variables inside a BEGIN/eval block
	# won't make it outside the BEGIN (i.e. not available to main program). 
        print "my \$pegasus_bin_dir = \"$bin_dir\";\n";
        print "my \$pegasus_conf_dir = \"$conf_dir\";\n";
        print "my \$pegasus_java_dir = \"$java_dir\";\n";
        print "my \$pegasus_perl_dir = \"$perl_dir\";\n";
        print "my \$pegasus_python_dir = \"$python_dir\";\n";
        print "my \$pegasus_python_externals_dir = \"$python_externals_dir\";\n";
        print "my \$pegasus_php_dir = \"$php_dir\";\n";
        print "my \$pegasus_javascript_dir = \"$js_dir\";\n";
        print "my \$pegasus_share_dir = \"$share_dir\";\n";
        print "my \$pegasus_schema_dir = \"$schema_dir\";\n";
        print "unshift(\@INC, \$pegasus_perl_dir);\n";
        exit 0; 
    }
    , 'python-dump' => sub {
        print "pegasus_bin_dir = \"$bin_dir\"\n";
        print "pegasus_conf_dir = \"$conf_dir\"\n";
        print "pegasus_java_dir = \"$java_dir\"\n";
        print "pegasus_perl_dir = \"$perl_dir\"\n";
        print "pegasus_python_dir = \"$python_dir\"\n";
        print "pegasus_python_externals_dir = \"$python_externals_dir\"\n";
        print "pegasus_php_dir = \"$php_dir\"\n";
        print "pegasus_javascript_dir = \"$js_dir\"\n";
        print "pegasus_share_dir = \"$share_dir\"\n";
        print "pegasus_schema_dir = \"$schema_dir\"\n";
        exit 0;
    }
    , 'sh-dump' => sub {
        print "PEGASUS_BIN_DIR=\"$bin_dir\"\n";
        print "export PEGASUS_BIN_DIR\n";
        print "PEGASUS_CONF_DIR=\"$conf_dir\"\n";
        print "export PEGASUS_CONF_DIR\n";
        print "PEGASUS_JAVA_DIR=\"$java_dir\"\n";
        print "export PEGASUS_JAVA_DIR\n";
        print "PEGASUS_PERL_DIR=\"$perl_dir\"\n";
        print "export PEGASUS_PERL_DIR\n";
        print "PEGASUS_PYTHON_DIR=\"$python_dir\"\n";
        print "export PEGASUS_PYTHON_DIR\n";
        print "PEGASUS_PYTHON_EXTERNALS_DIR=\"$python_externals_dir\"\n";
        print "export PEGASUS_PYTHON_EXTERNALS_DIR\n";
        print "PEGASUS_SHARE_DIR=\"$share_dir\"\n";
        print "export PEGASUS_SHARE_DIR\n";
        print "PEGASUS_SCHEMA_DIR=\"$schema_dir\"\n";
        print "export PEGASUS_SCHEMA_DIR\n";
        print "CLASSPATH=\"$classpath\"\n";
        print "export CLASSPATH\n";
        exit 0; 
    }
    , 'bin' => sub {
        print $bin_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'conf' => sub {
        print $conf_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'classpath' => sub {
        print $classpath;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'java' => sub {
        print $java_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'perl' => sub {
        print $perl_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'python' => sub {
        print $python_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'python-externals' => sub {
        print $python_externals_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'schema' => sub {
        print $schema_dir;
        print "\n" if $eoln; 
        exit 0; 
    }
    , 'local-site:s' => sub {
        site_snippet( ($_[1] || $userdir) ); 
        exit 0; 
    }
    , 'full-local:s' => sub {
        print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        #print '<!-- generated: ', isodate, " -->\n"; 
        print('<sitecatalog xmlns="http://pegasus.isi.edu/schema/sitecatalog"',
              ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
              ' xsi:schemaLocation="http://pegasus.isi.edu/schema/sitecatalog',
              ' http://pegasus.isi.edu/schema/sc-3.0.xsd" version="3.0">', "\n" ); 
        site_snippet( ($_[1] || $userdir) ); 
        print "</sitecatalog>\n";
        exit 0;
    }
);
usage();