1 | #!/usr/local/bin/perl5 -w
|
---|
2 |
|
---|
3 | # This program will look to see what collections are installed
|
---|
4 | # under this file system
|
---|
5 |
|
---|
6 | BEGIN {
|
---|
7 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
8 | unshift (@INC, "$ENV{'GSDLHOME'}/lib");
|
---|
9 | }
|
---|
10 |
|
---|
11 | use parsargv;
|
---|
12 | use colcfg;
|
---|
13 |
|
---|
14 |
|
---|
15 | # the collection information is stored as an array of hashes
|
---|
16 | # (one hash for each collection). The hash contains all the
|
---|
17 | # information in the collect and build configuration files
|
---|
18 |
|
---|
19 |
|
---|
20 | # read in all the collection configuration information
|
---|
21 |
|
---|
22 | opendir (DIR, "$ENV{'GSDLHOME'}/collect") ||
|
---|
23 | die "ERROR - couldn't read the directory $ENV{'GSDLHOME'}/collect\n";
|
---|
24 | @dir = readdir (DIR);
|
---|
25 | closedir (DIR);
|
---|
26 |
|
---|
27 | @collections = ();
|
---|
28 | foreach $dir (@dir) {
|
---|
29 | if ($dir =~ /^(\..*|modelcol)$/) {
|
---|
30 | # do nothing
|
---|
31 |
|
---|
32 | } else {
|
---|
33 | # read in the collection configuration file
|
---|
34 | my $collectcfg = {};
|
---|
35 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/collect.cfg") {
|
---|
36 | $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$dir/collect.cfg");
|
---|
37 | }
|
---|
38 | $collectcfg->{'collection'} = $dir;
|
---|
39 |
|
---|
40 | # read in the build configuration file
|
---|
41 | my $buildcfg = {};
|
---|
42 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg") {
|
---|
43 | $buildcfg = &colcfg::read_build_cfg ("$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg");
|
---|
44 | }
|
---|
45 |
|
---|
46 | # add the merged configuration files to the current list of collections
|
---|
47 | push (@collections, {%$collectcfg, %$buildcfg});
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | # do any sorting requested
|
---|
53 |
|
---|
54 |
|
---|
55 | # print out the collection information
|
---|
56 |
|
---|
57 | # {'creator'}->string
|
---|
58 | # {'maintainer'}->array of strings
|
---|
59 | # {'public'}->string
|
---|
60 | # {'beta'}->string
|
---|
61 | # {'key'}->string
|
---|
62 | # {'indexes'}->array of strings
|
---|
63 | # {'defaultindex'}->string
|
---|
64 | # {'builddate'}->string
|
---|
65 | # {'metadata'}->array of strings
|
---|
66 | # {'languages'}->array of strings
|
---|
67 | # {'numdocs'}->string
|
---|
68 | # {'numwords'}->string
|
---|
69 | # {'numbytes'}->string
|
---|
70 |
|
---|
71 | print "\n";
|
---|
72 | foreach $info (@collections) {
|
---|
73 | if (defined $info->{'collection'}) {
|
---|
74 | $collection = $info->{'collection'};
|
---|
75 | if (defined $info->{'public'}) {
|
---|
76 | $public = $info->{'public'};
|
---|
77 | } else {
|
---|
78 | $public = "?";
|
---|
79 | }
|
---|
80 | if (defined $info->{'beta'}) {
|
---|
81 | $beta = $info->{'beta'};
|
---|
82 | } else {
|
---|
83 | $beta = "?";
|
---|
84 | }
|
---|
85 | if (defined $info->{'numdocs'}) {
|
---|
86 | $numdocs = $info->{'numdocs'};
|
---|
87 | } else {
|
---|
88 | $numdocs = "?";
|
---|
89 | }
|
---|
90 | if (defined $info->{'numbytes'}) {
|
---|
91 | $numMbytes = int(($info->{'numbytes'}/1024.0/1024.0)*1000)/1000.0;
|
---|
92 | } else {
|
---|
93 | $numMbytes = "?";
|
---|
94 | }
|
---|
95 | write;
|
---|
96 | }
|
---|
97 | }
|
---|
98 | print "\n";
|
---|
99 |
|
---|
100 | exit;
|
---|
101 |
|
---|
102 | format STDOUT_TOP =
|
---|
103 | name public beta documents size (Mbytes)
|
---|
104 | -------- ------ ------ ----------- -------------
|
---|
105 | .
|
---|
106 |
|
---|
107 | format STDOUT =
|
---|
108 | @>>>>>>> @>>>>> @>>>>> @>>>>>>>>>> @>>>>>>>>>>>>
|
---|
109 | $collection, $public, $beta, $numdocs, $numMbytes
|
---|
110 | .
|
---|