[1378] | 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 thecollections 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 strict;
|
---|
| 44 | use arcinfo;
|
---|
| 45 | use colcfg;
|
---|
| 46 | use plugin;
|
---|
| 47 | use docprint;
|
---|
| 48 | use util;
|
---|
| 49 | use parsargv;
|
---|
| 50 |
|
---|
| 51 | sub print_usage {
|
---|
| 52 | print STDERR "\n usage: $0 [options]\n\n";
|
---|
| 53 | print STDERR " options:\n";
|
---|
| 54 | print STDERR " -verbosity number 0=none, 3=lots\n";
|
---|
| 55 | print STDERR " -importdir directory Where to place the mirrored material\n";
|
---|
| 56 | print STDERR " -archivedir directory Where the converted material ends up\n";
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | &main ();
|
---|
| 61 |
|
---|
| 62 | sub main {
|
---|
| 63 | my ($verbosity, $collectdir, $name, $collection);
|
---|
| 64 |
|
---|
| 65 | if (!parsargv::parse(\@ARGV,
|
---|
| 66 | 'verbosity/\d+/2', \$verbosity )) {
|
---|
| 67 | &print_usage();
|
---|
| 68 | die "\n";
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | # get the contents of the collect directory
|
---|
| 73 | $collectdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect");
|
---|
| 74 | opendir(CDIR, $collectdir) || die "Cannot open $collectdir: $!";
|
---|
| 75 | my @files = readdir(CDIR);
|
---|
| 76 | closedir CDIR;
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | # update each collection
|
---|
| 80 | foreach $name (@files) {
|
---|
| 81 |
|
---|
| 82 | $collection = &util::filename_cat($collectdir, $name);
|
---|
| 83 |
|
---|
| 84 | # igore entries for "." and ".."
|
---|
| 85 | next unless ($name =~ /[^\.]/);
|
---|
| 86 |
|
---|
| 87 | # ignore modelcol
|
---|
| 88 | next if ($name eq "modelcol");
|
---|
| 89 |
|
---|
| 90 | # ignore entries that are not directories
|
---|
| 91 | next unless (-d $collection);
|
---|
| 92 |
|
---|
| 93 | # ignore directories that do not have a subdir called etc
|
---|
| 94 | next unless (-d &util::filename_cat($collection, "etc"));
|
---|
| 95 |
|
---|
| 96 | print "Updating: $name\n";
|
---|
| 97 | print `update.pl $name`;
|
---|
| 98 |
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|