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

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

added GPL header

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1#!/usr/local/bin/perl5 -w
2
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
28# This program will look to see what collections are installed
29# under this file system
30
31BEGIN {
32 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
33 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
34}
35
36use parsargv;
37use 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
47opendir (DIR, "$ENV{'GSDLHOME'}/collect") ||
48 die "ERROR - couldn't read the directory $ENV{'GSDLHOME'}/collect\n";
49@dir = readdir (DIR);
50closedir (DIR);
51
52@collections = ();
53foreach $dir (@dir) {
54 if ($dir =~ /^(\..*|modelcol|CVS)$/) {
55 # do nothing
56
57 } else {
58 # read in the collection configuration file
59 my $collectcfg = {};
60 if (-e "$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg") {
61 $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$dir/etc/collect.cfg");
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
96print "\n";
97foreach $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}
123print "\n";
124
125exit;
126
127format STDOUT_TOP =
128 name public beta documents size (Mbytes)
129-------- ------ ------ ----------- -------------
130.
131
132format STDOUT =
133@>>>>>>> @>>>>> @>>>>> @>>>>>>>>>> @>>>>>>>>>>>>
134$collection, $public, $beta, $numdocs, $numMbytes
135.
Note: See TracBrowser for help on using the repository browser.