1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | ###########################################################################
|
---|
4 | #
|
---|
5 | # nightly.pl
|
---|
6 | #
|
---|
7 | # A component of the Greenstone digital library software
|
---|
8 | # from the New Zealand Digital Library Project at the
|
---|
9 | # University of Waikato, New Zealand.
|
---|
10 | #
|
---|
11 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or modify
|
---|
14 | # it under the terms of the GNU General Public License as published by
|
---|
15 | # the Free Software Foundation; either version 2 of the License, or
|
---|
16 | # (at your option) any later version.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful,
|
---|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
21 | # GNU General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, write to the Free Software
|
---|
25 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
26 | #
|
---|
27 | ###########################################################################
|
---|
28 |
|
---|
29 |
|
---|
30 | # This program will find all the collections under $GSDLHOME/collect
|
---|
31 | # and use the update.pl script to update them all. It should be run
|
---|
32 | # every night to keep mirror collections up-to-date.
|
---|
33 |
|
---|
34 |
|
---|
35 | BEGIN {
|
---|
36 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
37 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
38 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
39 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
|
---|
40 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify");
|
---|
41 | }
|
---|
42 |
|
---|
43 | use arcinfo;
|
---|
44 | use colcfg;
|
---|
45 | use util;
|
---|
46 | use parsargv;
|
---|
47 |
|
---|
48 | sub print_usage {
|
---|
49 | print STDERR "\n";
|
---|
50 | print STDERR "nightly.pl: Attempts to update all Greenstone collections found on\n";
|
---|
51 | print STDERR " the local filesystem by calling update.pl for each of\n";
|
---|
52 | print STDERR " them.\n\n";
|
---|
53 | print STDERR " usage: $0 [options]\n\n";
|
---|
54 | print STDERR " options:\n";
|
---|
55 | print STDERR " -verbosity number 0=none, 3=lots\n";
|
---|
56 | print STDERR " -importdir directory Where to place the mirrored material\n";
|
---|
57 | print STDERR " -archivedir directory Where the converted material ends up\n";
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | &main ();
|
---|
62 |
|
---|
63 | sub main {
|
---|
64 | my ($verbosity, $collectdir, $name, $collection);
|
---|
65 |
|
---|
66 | if (!parsargv::parse(\@ARGV,
|
---|
67 | 'verbosity/\d+/2', \$verbosity )) {
|
---|
68 | &print_usage();
|
---|
69 | die "\n";
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | # get the contents of the collect directory
|
---|
74 | $collectdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect");
|
---|
75 | opendir(CDIR, $collectdir) || die "Cannot open $collectdir: $!";
|
---|
76 | my @files = readdir(CDIR);
|
---|
77 | closedir CDIR;
|
---|
78 |
|
---|
79 |
|
---|
80 | # update each collection
|
---|
81 | foreach $name (@files) {
|
---|
82 |
|
---|
83 | $collection = &util::filename_cat($collectdir, $name);
|
---|
84 |
|
---|
85 | # igore entries for "." and ".."
|
---|
86 | next unless ($name =~ /[^\.]/);
|
---|
87 |
|
---|
88 | # ignore modelcol
|
---|
89 | next if ($name eq "modelcol");
|
---|
90 |
|
---|
91 | # ignore entries that are not directories
|
---|
92 | next unless (-d $collection);
|
---|
93 |
|
---|
94 | # ignore directories that do not have a subdir called etc
|
---|
95 | next unless (-d &util::filename_cat($collection, "etc"));
|
---|
96 |
|
---|
97 | print "Updating: $name\n";
|
---|
98 | print `update.pl $name`;
|
---|
99 |
|
---|
100 | }
|
---|
101 |
|
---|
102 | }
|
---|