source: trunk/gsdl/bin/script/gsdlinfo.pl@ 4

Last change on this file since 4 was 4, checked in by sjboddie, 25 years ago

Initial revision

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1#!/usr/local/bin/perl5 -w
2
3# This program will look to see what collections are installed
4# under this file system
5
6BEGIN {
7 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
8 unshift (@INC, "$ENV{'GSDLHOME'}/lib");
9}
10
11use parsargv;
12use 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
22opendir (DIR, "$ENV{'GSDLHOME'}/collect") ||
23 die "ERROR - couldn't read the directory $ENV{'GSDLHOME'}/collect\n";
24@dir = readdir (DIR);
25closedir (DIR);
26
27@collections = ();
28foreach $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
71print "\n";
72foreach $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}
98print "\n";
99
100exit;
101
102format STDOUT_TOP =
103 name public beta documents size (Mbytes)
104-------- ------ ------ ----------- -------------
105.
106
107format STDOUT =
108@>>>>>>> @>>>>> @>>>>> @>>>>>>>>>> @>>>>>>>>>>>>
109$collection, $public, $beta, $numdocs, $numMbytes
110.
Note: See TracBrowser for help on using the repository browser.