/usr/bin/getData is in getdata 0.2-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | #!/usr/bin/perl -w
use strict;
use vars qw(%toBeMirrored $sharedWgetOptions);
$sharedWgetOptions = "--continue --recursive --no-host-directories --no-directories --level 1 --no-parent";
=head1 NAME
getData - retrieves databases from the Internet
=cut
# This script shall help maintaining sets of frequently changing databases
# of various sorts. It is motivated by demands in computational biology
# and astronomy.
# Copyright (c) 2008-2011 Steffen Moeller <moeller@debian.org>
# Copyright (c) 2008-2011 Charles Plessy <plessy@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Or else go to GNU Web pages http://www.gnu.org and follow the white rabbit.
#
my ($mirrordir,$confd);
my $configfile="/etc/getData.conf";
my $error=0;
if ( -r $configfile ) {
open(FH,"<$configfile") or die "Could not open config data at '$configfile'.\n";
while(<FH>) {
next if /^\s*#/;
next unless /\s*(\S.*\S)\s*=\s*"([^"]*)"\s*/;
#print STDERR "Read: $1\n";
if ("mirrordir" eq "$1") {
$mirrordir=$2;
print STDERR "Seting mirrordir to '$mirrordir'.\n";
}
elsif ("confd" eq "$1") {
$confd=$2;
print STDERR "Configuration directory not existing: '$confd'\n" unless ! -d "$confd";
$error++;
}
}
close FH;
}
exit -1 if $error;
=head1 SYNOPSIS
getData [ --mirrordir <path> ] <list of db names>
getData --list
=head1 DESCRIPTION
Bioinformatics has the intrinsic problem to bring the biological data
to the end user. Astronomers have the equivalent problem and particle
physicists, well, they haven come up with (first) the web and (second)
the computational grids to address their problems. Debian helps with the
programs but will not provide such huge datasets that are even frequently
updated - not even in volatile.debian.org. Most bioinformatics researchers
will not need too many of such databases. And even more so will gladly
continue in using public services remotely.
For those who need a set of databases on a regular basis, this script
shall be a start to automate the burden to download the data and update
indices and the like. The world has seen such magic before with the
Lion Biosciences Prisma tool (http://bib.oxfordjournals.org/cgi/reprint/3/4/389.pdf)
but how about something simpler (as a start) that at least gets close
to what we desire and is Free. The aim must be to address the needs of
all (most) communities, not only of the bioinformatics world. The seed was
hence made with databases from astronomy.
Please contact the Debian-Med community if you consider this program
to be
almost
ready for your needs and explain what still needs to be added. Public
databases that you managed to integrate with this system are also very
warmly welcomed as feedback.
=head1 OPTIONS
=over 4
=item --help
this help
=item --man
Present a more detailed description in form of a man page.
=item --verbose
Say one or two words more than required.
=item --mirrordir <path>
Specifies destination directory. The data will be mirrored to the folder $mirrordir/$dbname/.
Please be aware that this mirrordir is nowhere stored. The directory can consequently be moved
to arbitrary locations at any time, if the users of the data are only informed about that
moving.
=item --list
Lists all databases that may be requested to be installed.
=item <list of db names>
Only those databases that are explicitly requested to be downloaded
will be downloaded. Such databases may require considerable bandwidth,
so please make sure you know you are doing the right thing.
=item --post
Perform only the unpacking/indexing, but do not retrieve/update the
databases. This option is considered useful when adding a new database
management system to the system, e.g. after installing EMBOSS.
=item --source
Perform only the unpacking/indexing, but do not retrieve/update the
databases. This option may be beneficial when the site administator is
aware of current analyses that should not be disturbed by the indexing
process but the downloading from the net can already be started.
=item --confd <directory>
Allows for the specification of a directory in which multiple files
can be stored that will be read by getData upon its invocation. These
may add values to the global variable %toBeMirrored that specifies
the databases and their download scripts.
=item --config <system>
Preparation of the configuration file that would be reuired for a
particular system that deals with the database. The configuration is
printed to stdout and is expected to be copied manually to the proper
file or folder. One could imagine this process to be automated,
though this is not yet implemented.
Currently available is support for two systems:
=over 8
=item emboss
This specifies the EMBOSS suite of tools for bioinformatics
(www.emboss.org) that is also available as a Debian package.
The configuration for the Uniprot databases will allow the sequence
retrieval with the seqret tool.
=item dre - ARC Grid Runtime Environment
Runtime environments (REs) are a concept of the ARC grid middleware
of which more can be learned on http://www.nordugrid.org. A script
is needed to indicate the presence of a runtime environment. Here,
the name of the script is important, which is not definable by getData
though since it only writes to stdout.
=back
Unfortunately, the configuration was not yet be found to be modularised.
It all needs to happen within the getData script itself.
=item --remove <list of dbnames>
This command removes folders that store the data. In principle this
could be performed manually, though some databases may have special
requirements pre- or post-removal, which can be specified individually
for every database.
=back
=head1 SPECIFICATION OF DATABASES
Databases for download and their post-processing are specified at
two different locations. One is the getData script itself, the other
are files stored in /etc/getData.d. Either will define elements of a
considerably large hash. The key is the identifier which is also shown
by the 'getData --list' directive. The value is a reference to another
hash, which assigns values to all the properties that a database has
for its download and post-processing:
=over 4
=item name - a human-readable pretty-printed name or short description that makes clear to the world what this database is about.
A bad example is the mere assignment of "DE405", which few people
understand. A better example is "Pfam-A : Manually curated protein
families and domains, only the seed is presented.". One could argue that
one should have that field renamed to "description".
=item source - shell commands to perform the initial download and subsequent updates
Commonly the wget tool is used for download. The such
presented little script is executed underneath the
mirrordir directory. One simple example is "wget --mirror
ftp://ssd.jpl.nasa.gov/pub/eph/export/unix/unxp2[01]*.405". With
increasing proficiency in using wget, one is tempted to substitute
"--mirror" with "--recursive --no-host-directories --no-directories
--level 1 --no-parent".
=item post-download - shell commands to perform after the data has been downloaded.
A simple (and unnecessary when used the right flags to wget) example is the mere setting of a symbolic link:
"post-download" => "ln -s ssd.jpl.nasa.gov/pub/eph/export/unix/unxp*.405 ."
Some more effort has been put into TrEMBL for the merging of releases with subsequent updates and the
indexing for EMBOSS:
"d=uncompressed; if [ ! -d \$d ]; then mkdir \$d; fi; "
."rm -rf \$d/trembl.dat; "
."(find ftp.ebi.ac.uk -name '*.dat.gz' | xargs -r zcat ) > \$d/trembl.dat; "
."[ -x /usr/bin/dbxflat ] "
. "&& cd \$d && "
. "dbxflat -dbresource embl -dbname trembllocal -idformat swiss -filenames=trembl.dat -fields id,acc -auto",
The dots are connecting strings in Perl. This helps the readability of
the code. When writing these scripts, please be aware the newlines don't
separate the individual commands here. Semicolon are required.
=item recommends - suggests a series of packages to be present for the use of the database or the performance of the indexing.
This information is not used at the moment, also to render this script
more useful for other Linux distributions than Debian.
=item getWgetOptions - private command to get wget options
This is used at download time by makefiles, is not intended to be used
interactively, and could be removed anytime.
=back
=head1 EXAMPLES
The following will list the identifiers and the descriptions of the
first 4 databases that area available via getData on your system.
./getData --mirrordir=/local/databases/mirrored --list | head 4
To install any particular database, only give its name as an argument. If
the installation is performed at another directory than the default,
then the --mirrordir needs again to be set.
./getData swiss.dat
To remove the database again, give the script a hint with the --remove flag
./getData --remove swiss.dat
To perform the indexing only and circumvent the download (attention,
this is dangerous since the index files will look newer than the database
is), do
./getData --post swiss.dat
A special exception to these extra scripts is the --config flag in
that it takes a list of extra arguments. Each shall denote a particular
system that this database may be of interest for. There are today two
systems supported:
=head1 TODO
We now need a mechanism with which packages can specify hooks that
shall be called upon an update of a database. But we cannot assume that
every indexing that can be performed because of the installation of some
package is also desired by the user. How to configure this properly is
left to be decided.
=head1 SEE ALSO
http://debian-med.alioth.debian.org, http://wiki.debian.org/DebianMed, /etc/getData.conf
=head1 AUTHORS
This script was prepared by
Steffen Moeller <moeller@debian.org>
and
Charles Plessy <debian-no-spam@plessy.org>
and is distributed under the terms of the GNU Public License (GPL). On Debian
systems, this license can be found under /usr/share/common-licenses/GPL.
=cut
use strict;
use Getopt::Long;
use Cwd;
%toBeMirrored = (
#
# A S T R O N O M Y
#
"tycho2" => {
name => "Tycho2 Star Coordinates",
source => "wget --mirror ftp://cdsarc.u-strasbg.fr/pub/cats/I/259/ReadMe ftp://cdsarc.u-strasbg.fr/pub/cats/I/259/index.dat.gz ftp://cdsarc.u-strasbg.fr/pub/cats/I/259/tyc2.dat*",
"post-download" => "[ -r tyc2.dat -a -z \"`find . -cnewer tyc2.dat "
. "-a ! -name .listing`\" ] "
. "&& echo \"No mirrored file newer than previously created index.\" "
. "|| ( zcat cdsarc.u-strasbg.fr/pub/cats/I/259/tyc2.dat* > tycho2.dat && ln -sf tycho2.dat Tycho2.dat)"
},
"astorb" => {
name => "asteroid orbits",
source => "wget --mirror ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz",
"post-download" => "[ -r astorb.dat "
. "-a ftp.lowell.edu/pub/elgb/astorb.dat.gz -nt astorb.dat ] "
. "|| zcat ftp.lowell.edu/pub/elgb/astorb.dat.gz > astorb.dat"
},
"DE405" => {
name => "DE405",
# URL moved
#source => "wget $sharedWgetOptions ftp://ssd.jpl.nasa.gov/pub/eph/export/unix/unxp2[01]*.405",
source => "wget $sharedWgetOptions ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/de405/",
"post-download" => "[ -r unxp2000.405 -a ascp1600.405 -nt unxp2000.405 ] || cat ascp*.405 > unxp2000.405",
recommends => "jpl-eph-tools"
},
#
# B I O I N F O R M A T I C S
#
"ensembl.hsa" => {
name => "ENSEMBL flatfile dump -- Homo Sapiens",
source => "wget $sharedWgetOptions ftp://ftp.ensembl.org/pub/current_embl/homo_sapiens/*"
},
"gene.ontology.rdf" => {
name => "GeneOntology - RDF-formatted, terms only.",
source => "wget $sharedWgetOptions ftp://ftp.geneontology.org/pub/go/godatabase/archive/latest/go_*-termdb.rdf-xml.gz",
"post-download" => "gzip -dc ftp.geneontology.org/pub/go/godatabase/archive/latest/go_*-termdb.rdf-xml.gz > go-termdb.rdf-xml"
},
"gwascatalog" => {
name => "Genome.org - GWAScatalog: SNPs and diseases",
source => "wget $sharedWgetOptions http://www.genome.gov/admin/gwascatalog.txt"
},
"intact.psimitab" => {
name => "IntACT Protein Interaction Database",
source => "wget $sharedWgetOptions ftp://ftp.ebi.ac.uk/pub/databases/intact/current/psimitab/intact.zip",
"post-download" => "unzip `find ftp.ebi.ac.uk -name '*.zip'`"
},
"jaspar" => {
name => "The high-quality transcription factor binding profile database",
source => "wget $sharedWgetOptions --accept .zip "
. "http://jaspar.genereg.net/html/DOWNLOAD/MatrixDir/",
},
"jaspar.core" => {
name => "Jaspar Core Database of transcription factor binding sites",
source => "wget --mirror http://jaspar.genereg.net/html/DOWNLOAD/MatrixDir/JASPAR_CORE_2008/"
#recommends => ["TFBS"]
},
# "jaspar.sites" => {
# name => "Sites subfolder of JASPAR database",
# source => "wget --mirror http://jaspar.genereg.net/html/DOWNLOAD/SITES/*/*.sites"
# },
#
# "jaspar.MatrixDir" => {
# name => "MatrixDir subfolder of JASPAR database",
# source => "wget --mirror http://jaspar.genereg.net/html/DOWNLOAD/MatrixDir/*/*.sites"
# }
"kegg.brite" => {
name => "Kegg Brite Database",
source => "wget $sharedWgetOptions ftp://ftp.genome.jp/pub/kegg/release/current/brite.tar.gz"
},
"kegg.pathway" => {
name => "Kegg Pathway Database",
source => "wget $sharedWgetOptions ftp://ftp.genome.jp/pub/kegg/release/current/pathway.tar.gz"
},
"kegg.pathway.hsa" => {
name => "Kegg Pathway Database (HSA)",
source => "wget --mirror ftp://ftp.genome.jp/pub/kegg/pathway/organisms/hsa"
},
"kegg.pathway.hsa.xml" => {
name => "XML representation of pathways in KEGG",
source => "wget --mirror ftp://ftp.genome.jp/pub/kegg/xml/README ftp://ftp.genome.jp/pub/kegg/xml//KGML.dtd ftp://ftp.genome.jp/pub/kegg/xml/ko ftp://ftp.genome.jp/pub/kegg/xml/map ftp://ftp.genome.jp/pub/kegg/xml/organisms/hsa"
},
"reactome.tab.human" => {
name => "Reactome Pathway Database - Human interactions as tab delimited",
source => "wget $sharedWgetOptions http://www.reactome.org/download/interactions.README.txt http://www.reactome.org/download/current/homo_sapiens.interactions.txt.gz"
},
"pfam-a" => {
name => "Pfam-A : Manually curated protein families and domains, only the seed is presented.",
source => "wget $sharedWgetOptions ftp://ftp.sanger.ac.uk/pub/databases/Pfam/current_release/Pfam-A-seed.gz"
},
"pfam-b" => {
name => "Pfam-B : Automated assembly of protein families",
source => "wget $sharedWgetOptions ftp://ftp.sanger.ac.uk/pub/databases/Pfam/current_release/Pfam-B.gz"
},
"pfam-c" => {
name => "Pfam-C : Clans of sequences that may be assigned to multiple Pfam entries",
source => "wget $sharedWgetOptions ftp://ftp.sanger.ac.uk/pub/databases/Pfam/current_release/Pfam-C.gz"
},
"trembl.dat" => {
name => "UniProt - TrEMBL in EMBL format",
source => "wget $sharedWgetOptions ftp://ftp.ebi.ac.uk/pub/databases/swissprot/release_compressed/uniprot_trembl.dat.gz",
"post-download" => "d=uncompressed; if [ ! -d \$d ]; then mkdir \$d; fi; "
."rm -rf \$d/trembl.dat; "
."(find . -name '*.dat.gz' | xargs -r zcat ) > \$d/trembl.dat; "
."[ -x /usr/bin/dbxflat ] "
. "&& cd \$d && "
. "dbxflat -dbresource embl -dbname trembllocal -idformat swiss -filenames=trembl.dat -fields id,acc -auto",
"recommends" => ["emboss"],
"test" => "seqret trembllocal:Q9YZN7"
},
"swiss.dat" => {
name => "UniProt - SwissProt in EMBL format",
source => "wget $sharedWgetOptions ftp://ftp.ebi.ac.uk/pub/databases/swissprot/release_compressed/uniprot_sprot.dat.gz ftp://ftp.ebi.ac.uk/pub/databases/swissprot/updates_compressed/*.dat.gz",
"post-download" => "d=uncompressed; if [ ! -d \$d ]; then mkdir \$d; fi; "
."rm -rf \$d/swissprot.dat; "
."(find . -name '*.dat.gz' | xargs -r zcat ) > \$d/swissprot.dat; "
."[ -x /usr/bin/dbiflat ] && "
. "cd \$d && "
. "dbiflat -dbname swisslocal -fields acc,des -idformat swiss -auto",
# source => "wget --mirror ftp://ftp.ebi.ac.uk/pub/databases/swissprot/release_compressed/uniprot_sprot.dat.gz"
"recommends" => ["emboss"],
"test" => "seqret -feature swisslocal:p12345 -osf swiss -stdout -auto"
},
"swiss.fasta" => {
name => "UniProt - SWISS-PROT in FASTA format",
source => "wget $sharedWgetOptions ftp://ftp.ebi.ac.uk/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_sprot.fasta.gz"
},
"trembl.fasta" => {
name => "UniProt - TrEMBL in FASTA format",
source => "wget $sharedWgetOptions ftp://ftp.ebi.ac.uk/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_trembl.fasta.gz"
},
);
$mirrordir = "/var/lib/mirrored" unless defined($mirrordir);
$confd = "/etc/getData.conf.d" unless defined($confd);
my ($post,$source,$removal,$config,$list,$help,$man,$verbose,$getWgetOptions)=(undef,undef,undef,0,0,0,0,0);
my %options=("mirrordir:s" => \$mirrordir,
"list" => \$list,
"help"=>\$help, "man"=>\$man,
"verbose"=>\$verbose,
"post"=>\$post,
"confd=s"=>\$confd,
"config:s@"=>\$config,
"remove"=>\$removal,
"source"=>\$source,
"getWgetOptions"=>\$getWgetOptions);
my ($do_source,$do_post,$do_config,$do_removal)=(1,1,0,0);
sub myhelp () {
require "Pod/Usage.pm";
import Pod::Usage;
pod2usage() unless defined($man);
pod2usage( -verbose => 2 );
}
GetOptions(%options) or die "Could not parse arguments.\n";
die "Cannot set both --post-download-only and --source-only options.\n" if $post and $source;
if ($help or $man) {
myhelp()
}
if ($getWgetOptions) {
print "$sharedWgetOptions\n";
exit 0;
}
print "post: $post, source: $source\n" if $verbose;
if ($post) {
print "solely enabling post-download operations, disabling retrieval of database updates and removal.\n";
$do_source=0;
$do_post=1;
$do_config=0;
$do_removal=0;
}
if ($source) {
print "solely enabling download, disabling unpacking, configuration, indexing and removal.\n";
$do_post=0;
$do_source=1;
$do_config=0;
$do_removal=0;
}
if ($config) {
print "solely enabling database configuration for external systems, disabling retrieval of updates, the removal and their unpacking/indexing.\n";
$do_post=0;
$do_source=0;
$do_removal=0;
$do_config=1;
}
if ($removal) {
print "enabling removal, disabling retrieval of updates, the configuration and their unpacking/indexing.\n";
$do_post=0;
$do_source=0;
$do_config=0;
$do_removal=1;
}
if ($verbose) {
foreach my $o (keys %options) {
print "$o => " . ${$options{$o}}."\n";
}
}
if ( -d "$confd" ) {
foreach my $f (glob "$confd/*.getData") {
eval require $f or die "Could not read '$f': $@\n";
print STDERR "Read '$f'\n";
}
}
############## A C T I O N ##################
if ($list) {
my $maxlength=0;
foreach my $db (keys %toBeMirrored) {
$maxlength=length($db) if length($db)>$maxlength;
}
foreach my $db (sort keys %toBeMirrored) {
printf "%-${maxlength}s",$db;
# more information like the expected size should be printed here.
print "\t".$toBeMirrored{$db}{"name"};
print "\n";
}
exit 0;
}
die "Cannot write to root destination directory at '$mirrordir'.\n" unless ( -w "$mirrordir" or $do_config);
#print join(", ",@ARGV)."\n";
my $d=getcwd();
foreach my $db (@ARGV) {
unless(exists($toBeMirrored{$db})) {
print STDERR "Unknown database: '$db'\n";
next;
}
if ($do_config) {
die "Please specify a system to configure.\n"
unless 0<length(@$config);
foreach my $system (@$config) {
if ("emboss" eq "$system") {
if ($db =~ /(swiss|trembl).dat/ ) {
print "\n";
print "########### " . $db . " ##############\n";
print "\n";
print "DB ";
my $n=$db;
$n =~ s/\.dat$//;
print $n;
print "local [\n";
print " type: P\n";
print " format: swiss\n";
if ($db eq "swiss.dat") {
print " method: emblcd\n";
}
elsif ($db eq "trembl.dat") {
print " method: emboss\n";
}
else {
print " # method: unknown\n";
}
print " directory: $mirrordir/$db/uncompressed\n";
print "]\n";
print "\n";
print "####################################\n";
}
}
elsif ("dre" eq "$system") {
if ( -d "$mirrordir/$db" ) {
print "MIRRORDIR=\"$mirrordir\"\n";
}
else {
print STDERR "$db: not installed, configuration not printed.";
}
}
else {
print "Unknown system $system\n";
}
}
}
print STDERR "\"$db\" -> \"$mirrordir\"\n";
unless ( -d "$mirrordir/$db" ) {
if ($do_source) {
print " creating directory $mirrordir/$db\n";
mkdir("$mirrordir/$db") or die "Could not create directory \"$mirrordir/$db\"\n";
}
else {
die "Directory '$mirrordir/$db' is not existing, no data to treat post-download,"
." the download itself was disabled via the command line.\n";
}
}
chdir("$mirrordir/$db") or die "Could not change directory to \"$mirrordir/$db\"\n";
if ($do_source) {
print "Mirroring ".$toBeMirrored{$db}{"name"}." ($db)\n";
my $cmd = $toBeMirrored{$db}{"source"};
if (!defined ($cmd) or "" eq $cmd) {
print STDERR "$db: download instructions not specified - skipping.\n";
next;
}
print STDERR "$cmd\n";
system($cmd) and die "Experienced problem.";
}
if ($do_post) {
print "Executing post-download scripts for ".$toBeMirrored{$db}{"name"}." ($db)\n";
my $cmd = $toBeMirrored{$db}{"post-download"};
if ( defined($cmd) and "" ne $cmd) {
print STDERR "$cmd\n";
system($cmd) and die "$db: post-download: Experienced problem.";
}
else {
print STDERR "$db: No post-download command defined.\n" if $verbose;
}
}
if ($do_removal) {
print "Removal of ".$toBeMirrored{$db}{"name"}." ($db)\n";
if (exists($toBeMirrored{$db}{"pre-removal"})) {
my $cmd = $toBeMirrored{$db}{"pre-removal"};
print "Performing: '$cmd'\n" if $verbose;
if (defined($cmd)) {
system($cmd) and die "$db: pre-removal: Experienced problem while executing '$cmd': $@\n";
}
}
# This will be performed one way or the other
my $cmd="";
if (exists($toBeMirrored{$db}{"removal"})) {
$cmd = $toBeMirrored{$db}{"removal"};
}
else {
$cmd = "rm -rf \"$mirrordir/$db\"";
}
print "Performing: '$cmd'\n" if $verbose;
system($cmd) and die "$db: removal: Experienced problem while executing '$cmd': $@\n";
if (exists($toBeMirrored{$db}{"post-removal"})) {
my $cmd = $toBeMirrored{$db}{"post-removal"};
print "Performing: '$cmd'\n" if $verbose;
if (defined($cmd)) {
my $cmd = $toBeMirrored{$db}{"post-removal"};
system($cmd) and die "$db: post-removal: Experienced problem while executing '$cmd': $@\n";
}
}
}
chdir($d) or die "Could not change back to dir '$d'.\n";
}
|