[4] | 1 | #!/usr/local/bin/perl5 -w
|
---|
| 2 |
|
---|
[538] | 3 | ###########################################################################
|
---|
| 4 | #
|
---|
| 5 | # gsdlinfo.pl --
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
| 10 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
| 27 |
|
---|
[4] | 28 | # This program will look to see what collections are installed
|
---|
| 29 | # under this file system
|
---|
| 30 |
|
---|
| 31 | BEGIN {
|
---|
| 32 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
[9] | 33 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
[4] | 34 | }
|
---|
| 35 |
|
---|
| 36 | use parsargv;
|
---|
| 37 | use colcfg;
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | # the collection information is stored as an array of hashes
|
---|
| 41 | # (one hash for each collection). The hash contains all the
|
---|
| 42 | # information in the collect and build configuration files
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | # read in all the collection configuration information
|
---|
| 46 |
|
---|
| 47 | opendir (DIR, "$ENV{'GSDLHOME'}/collect") ||
|
---|
| 48 | die "ERROR - couldn't read the directory $ENV{'GSDLHOME'}/collect\n";
|
---|
| 49 | @dir = readdir (DIR);
|
---|
| 50 | closedir (DIR);
|
---|
| 51 |
|
---|
| 52 | @collections = ();
|
---|
| 53 | foreach $dir (@dir) {
|
---|
[91] | 54 | if ($dir =~ /^(\..*|modelcol|CVS)$/) {
|
---|
[4] | 55 | # do nothing
|
---|
| 56 |
|
---|
| 57 | } else {
|
---|
| 58 | # read in the collection configuration file
|
---|
| 59 | my $collectcfg = {};
|
---|
[91] | 60 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg") {
|
---|
| 61 | $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg");
|
---|
[4] | 62 | }
|
---|
| 63 | $collectcfg->{'collection'} = $dir;
|
---|
| 64 |
|
---|
| 65 | # read in the build configuration file
|
---|
| 66 | my $buildcfg = {};
|
---|
| 67 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg") {
|
---|
| 68 | $buildcfg = &colcfg::read_build_cfg ("$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg");
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | # add the merged configuration files to the current list of collections
|
---|
| 72 | push (@collections, {%$collectcfg, %$buildcfg});
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | # do any sorting requested
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | # print out the collection information
|
---|
| 81 |
|
---|
| 82 | # {'creator'}->string
|
---|
| 83 | # {'maintainer'}->array of strings
|
---|
| 84 | # {'public'}->string
|
---|
| 85 | # {'beta'}->string
|
---|
| 86 | # {'key'}->string
|
---|
| 87 | # {'indexes'}->array of strings
|
---|
| 88 | # {'defaultindex'}->string
|
---|
| 89 | # {'builddate'}->string
|
---|
| 90 | # {'metadata'}->array of strings
|
---|
| 91 | # {'languages'}->array of strings
|
---|
| 92 | # {'numdocs'}->string
|
---|
| 93 | # {'numwords'}->string
|
---|
| 94 | # {'numbytes'}->string
|
---|
| 95 |
|
---|
| 96 | print "\n";
|
---|
| 97 | foreach $info (@collections) {
|
---|
| 98 | if (defined $info->{'collection'}) {
|
---|
| 99 | $collection = $info->{'collection'};
|
---|
| 100 | if (defined $info->{'public'}) {
|
---|
| 101 | $public = $info->{'public'};
|
---|
| 102 | } else {
|
---|
| 103 | $public = "?";
|
---|
| 104 | }
|
---|
| 105 | if (defined $info->{'beta'}) {
|
---|
| 106 | $beta = $info->{'beta'};
|
---|
| 107 | } else {
|
---|
| 108 | $beta = "?";
|
---|
| 109 | }
|
---|
| 110 | if (defined $info->{'numdocs'}) {
|
---|
| 111 | $numdocs = $info->{'numdocs'};
|
---|
| 112 | } else {
|
---|
| 113 | $numdocs = "?";
|
---|
| 114 | }
|
---|
| 115 | if (defined $info->{'numbytes'}) {
|
---|
| 116 | $numMbytes = int(($info->{'numbytes'}/1024.0/1024.0)*1000)/1000.0;
|
---|
| 117 | } else {
|
---|
| 118 | $numMbytes = "?";
|
---|
| 119 | }
|
---|
| 120 | write;
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 | print "\n";
|
---|
| 124 |
|
---|
| 125 | exit;
|
---|
| 126 |
|
---|
| 127 | format STDOUT_TOP =
|
---|
| 128 | name public beta documents size (Mbytes)
|
---|
| 129 | -------- ------ ------ ----------- -------------
|
---|
| 130 | .
|
---|
| 131 |
|
---|
| 132 | format STDOUT =
|
---|
| 133 | @>>>>>>> @>>>>> @>>>>> @>>>>>>>>>> @>>>>>>>>>>>>
|
---|
| 134 | $collection, $public, $beta, $numdocs, $numMbytes
|
---|
| 135 | .
|
---|