[1665] | 1 | #!/usr/bin/perl -w
|
---|
[4] | 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 |
|
---|
[1970] | 39 | if (scalar(@ARGV) && $ARGV[0] eq "--help") {
|
---|
| 40 | print STDERR "\n";
|
---|
| 41 | print STDERR "gsdlinfo.pl: Prints information on any Greenstone collections\n";
|
---|
| 42 | print STDERR " found on the local file system.\n\n";
|
---|
| 43 | exit;
|
---|
| 44 | }
|
---|
[4] | 45 |
|
---|
[1970] | 46 |
|
---|
[4] | 47 | # the collection information is stored as an array of hashes
|
---|
| 48 | # (one hash for each collection). The hash contains all the
|
---|
| 49 | # information in the collect and build configuration files
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | # read in all the collection configuration information
|
---|
| 53 |
|
---|
| 54 | opendir (DIR, "$ENV{'GSDLHOME'}/collect") ||
|
---|
| 55 | die "ERROR - couldn't read the directory $ENV{'GSDLHOME'}/collect\n";
|
---|
| 56 | @dir = readdir (DIR);
|
---|
| 57 | closedir (DIR);
|
---|
| 58 |
|
---|
| 59 | @collections = ();
|
---|
| 60 | foreach $dir (@dir) {
|
---|
[91] | 61 | if ($dir =~ /^(\..*|modelcol|CVS)$/) {
|
---|
[4] | 62 | # do nothing
|
---|
| 63 |
|
---|
| 64 | } else {
|
---|
| 65 | # read in the collection configuration file
|
---|
| 66 | my $collectcfg = {};
|
---|
[91] | 67 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg") {
|
---|
| 68 | $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg");
|
---|
[4] | 69 | }
|
---|
| 70 | $collectcfg->{'collection'} = $dir;
|
---|
| 71 |
|
---|
| 72 | # read in the build configuration file
|
---|
| 73 | my $buildcfg = {};
|
---|
| 74 | if (-e "$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg") {
|
---|
| 75 | $buildcfg = &colcfg::read_build_cfg ("$ENV{'GSDLHOME'}/collect/$dir/index/build.cfg");
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | # add the merged configuration files to the current list of collections
|
---|
| 79 | push (@collections, {%$collectcfg, %$buildcfg});
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | # do any sorting requested
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | # print out the collection information
|
---|
| 88 |
|
---|
| 89 | # {'creator'}->string
|
---|
| 90 | # {'maintainer'}->array of strings
|
---|
| 91 | # {'public'}->string
|
---|
| 92 | # {'beta'}->string
|
---|
| 93 | # {'key'}->string
|
---|
| 94 | # {'indexes'}->array of strings
|
---|
| 95 | # {'defaultindex'}->string
|
---|
| 96 | # {'builddate'}->string
|
---|
| 97 | # {'metadata'}->array of strings
|
---|
| 98 | # {'languages'}->array of strings
|
---|
| 99 | # {'numdocs'}->string
|
---|
| 100 | # {'numwords'}->string
|
---|
| 101 | # {'numbytes'}->string
|
---|
| 102 |
|
---|
| 103 | print "\n";
|
---|
| 104 | foreach $info (@collections) {
|
---|
| 105 | if (defined $info->{'collection'}) {
|
---|
| 106 | $collection = $info->{'collection'};
|
---|
| 107 | if (defined $info->{'public'}) {
|
---|
| 108 | $public = $info->{'public'};
|
---|
| 109 | } else {
|
---|
| 110 | $public = "?";
|
---|
| 111 | }
|
---|
| 112 | if (defined $info->{'beta'}) {
|
---|
| 113 | $beta = $info->{'beta'};
|
---|
| 114 | } else {
|
---|
| 115 | $beta = "?";
|
---|
| 116 | }
|
---|
| 117 | if (defined $info->{'numdocs'}) {
|
---|
| 118 | $numdocs = $info->{'numdocs'};
|
---|
| 119 | } else {
|
---|
| 120 | $numdocs = "?";
|
---|
| 121 | }
|
---|
| 122 | if (defined $info->{'numbytes'}) {
|
---|
| 123 | $numMbytes = int(($info->{'numbytes'}/1024.0/1024.0)*1000)/1000.0;
|
---|
| 124 | } else {
|
---|
| 125 | $numMbytes = "?";
|
---|
| 126 | }
|
---|
| 127 | write;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 | print "\n";
|
---|
| 131 |
|
---|
| 132 | exit;
|
---|
| 133 |
|
---|
| 134 | format STDOUT_TOP =
|
---|
| 135 | name public beta documents size (Mbytes)
|
---|
| 136 | -------- ------ ------ ----------- -------------
|
---|
| 137 | .
|
---|
| 138 |
|
---|
| 139 | format STDOUT =
|
---|
| 140 | @>>>>>>> @>>>>> @>>>>> @>>>>>>>>>> @>>>>>>>>>>>>
|
---|
| 141 | $collection, $public, $beta, $numdocs, $numMbytes
|
---|
| 142 | .
|
---|