[Bio] / Sprout / NMPDRSetup.pl Repository:
ViewVC logotype

Diff of /Sprout/NMPDRSetup.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12, Wed Sep 3 20:57:10 2008 UTC revision 1.13, Tue Sep 9 23:47:07 2008 UTC
# Line 21  Line 21 
21  FIG temporary directory. The output file will be C<outYou.log>, the  FIG temporary directory. The output file will be C<outYou.log>, the
22  error file will be C<errYou.log>, and the trace file C<traceYou.log>.  error file will be C<errYou.log>, and the trace file C<traceYou.log>.
23    
24  Currently, the development NMPDR runs on the nmpdr-1 server, while  Currently, the development NMPDR runs on the %DEVSERVER% server, while
25  the production NMPDR runs on the nmpdr-3 server. When copying files  the production NMPDR runs on the %PRODSERVER% server. When copying files
26  between servers for purposes of synchronization, it is important that  between servers for purposes of synchronization, it is important that
27  the rsync originate from the destination server so that the ownership is  the rsync originate from the destination server so that the ownership is
28  not all messed up.  not all messed up.
# Line 32  Line 32 
32  =item trace  =item trace
33    
34  Numeric trace level. A higher trace level causes more messages to appear. The  Numeric trace level. A higher trace level causes more messages to appear. The
35  default trace level is 2.  default trace level is 3.
36    
37  =item user  =item user
38    
# Line 97  Line 97 
97    
98  =item 5  =item 5
99    
100  Copy the cover pages.  Copy the wiki pages.
101    
102  =item 6  =item 6
103    
# Line 108  Line 108 
108  =item group  =item group
109    
110  Name of the group to be given write permission for all the files. The default  Name of the group to be given write permission for all the files. The default
111  is C<figadmin>.  is C<fig>.
112    
113  =item server  =item server
114    
115  Server path to the cover pages. This indicates the type of NMPDR being created,  Symbolic name of the new version. This indicates the type of NMPDR being created,
116  and is usually the name of a symlink known to the Apache configuration. The  and is usually the name of a symlink known to the Apache configuration. The
117  default is C<next>, which indicates the development version. For the experimental  default is C<next>, which indicates the development version. For the experimental
118  version, it should be C<dev>.  version, it should be C<dev>.
# Line 124  Line 124 
124  This script will need to be updated if the default directories change. In addition,  This script will need to be updated if the default directories change. In addition,
125  the CVS information is hard-coded.  the CVS information is hard-coded.
126    
 Currently the FIG_Config is set up to use the NEXT pointer in the proxy URL system.  
 This means it has to be edited manually during the cutover.  
   
127  =cut  =cut
128    
129  use strict;  use strict;
# Line 136  Line 133 
133  use File::Copy;  use File::Copy;
134  use File::Path;  use File::Path;
135  use File::stat;  use File::stat;
 #use POSIX;  
136  use IO::Handle;  use IO::Handle;
137    
138  # Get the command-line options.  # Get the command-line options.
139  my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],  my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],
140                                          { envDir =>   ["$FIG_Config::nmpdr_base/FIGdisk/env",                                          { envDir =>   ["$FIG_Config::nmpdr_base/FIGdisk/env",
141                                                         'environment directory containing pointers to applications and development tools'],                                                         'environment directory containing pointers to applications and development tools'],
142                                            blastMAT => ["copy",                                            blastMAT => ["copy", 'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'],
143                                                         'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'],                                            dataDir =>  ["0", 'fully-qualified name of the SEED data directory to use; default is most recent'],
144                                            dataDir =>  ["0",                                            relName =>  ["nmpdr_XX", 'name to use for the release created (default "nmpdr_XX")'],
145                                                         'fully-qualified name of the SEED data directory to use; default is most recent'],                                            test =>     [0, 'print some data but do not run'],
146                                            relName =>  ["nmpdr_XX",                                            stage =>    [0, 'stage at which to start'],
147                                                         'name to use for the release created (default "nmpdr_XX")'],                                            force =>    [0, 'force an update over a possible existing SEED'],
148                                            test =>     [0,                                            group =>    ['fig', 'group to be given write permission for the new files'],
149                                                         'print some data but do not run'],                                            server =>   ['next', 'NMPDR version type'],
150                                            stage =>    [0,                                            trace =>    [3, 'tracing level'],
                                                        'stage at which to start'],  
                                           force =>    [0,  
                                                        'force an update over a possible existing SEED'],  
                                           group =>    ['fig',  
                                                        'group to be given write permission for the new files'],  
                                           server =>   ['next',  
                                                        'server path to the cover pages'],  
151                                          },                                          },
152                                              '<versionNumber>',                                              '<versionNumber>',
153                                              @ARGV);                                              @ARGV);
# Line 182  Line 171 
171    
172  # Check the parameters.  # Check the parameters.
173  if (! $FIG_Config::nmpdr_base) {  if (! $FIG_Config::nmpdr_base) {
174      Confess("Please specify a value for FIG_Config::nmpdr_base.");      Confess("Please specify a directory value for FIG_Config::nmpdr_base.");
175  } elsif (! -d $FIG_Config::nmpdr_base) {  } elsif (! -d $FIG_Config::nmpdr_base) {
176      Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");      Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");
177  } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {  } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {
# Line 194  Line 183 
183  } elsif ($version !~ /^\d+$/) {  } elsif ($version !~ /^\d+$/) {
184      Confess("Invalid (non-numeric) version number $version.");      Confess("Invalid (non-numeric) version number $version.");
185  }  }
186  # Make the version number pretty.  # Make the version number pretty. This means stripping off the "v" (if any)
187    # and converting to two digits.
188    $version =~ s/^v//;
189  $version = sprintf("%02d", $version);  $version = sprintf("%02d", $version);
190  # Add the version number to the release name.  # Add the version number to the release name.
191  my $version_rel = $options->{relName};  my $version_rel = $options->{relName};
# Line 381  Line 372 
372  #            and protect from updates.  #            and protect from updates.
373  #  #
374  if ($options->{stage} <= 3) {  if ($options->{stage} <= 3) {
375      # Switch to the configuration directory.      # Compute the configuration directory locations.
376      Insure("$target_dir/config");      my $old_config_dir = "$FIG_Config::fig_disk/config";
377      ChDir("$target_dir/config");      my $new_config_dir = "$target_dir/config";
378      # Create a hash of the changes that need to be made.      Insure($new_config_dir);
379        # Copy the old configuration. This destroys the config file created by the
380        # bootstrap.
381        my $old_config = "$old_config_dir/FIG_Config.pm";
382        my $new_config = "$new_config_dir/FIG_Config.pm";
383        if ($options->{test}) {
384            Trace("$old_config would be copied to $new_config.") if T(2);
385        } else {
386            Trace("Copying $old_config to $new_config") if T(2);
387            copy $old_config, $new_config;
388        }
389        # Next, we update the few lines at the beginning that have all the magic in them.
390        # Every other config value is derived from these three.
391      my %changes = (      my %changes = (
392                     temp_url          => "\$nmpdr_site_url/FIG-Tmp",          version => $version,
393                     cgi_url           => "\$nmpdr_site_url/FIG",          old_version => $FIG_Config::version,
394                     temp_base         => "/next/FIG-Tmp",          nmpdr_site_type => "/$options->{server}",
                    cgi_base          => "/next/FIG",  
                    template_url      => "\$nmpdr_site_url/templates",  
                    dbms              => "mysql",  
                    sproutDbms        => "mysql",  
                    db                => $FIG_Config::db,  
                    dbuser            => $FIG_Config::dbuser,  
                    dbpass            => $FIG_Config::dbpass,  
                    dbsock            => $FIG_Config::dbsock,  
                    dbport            => $FIG_Config::dbport,  
                    sproutDB          => $sprout_db_name,  
                    oldSproutDB       => $FIG_Config::sproutDB,  
                    oldSproutDBD      => "$FIG_Config::fig/SproutDBD.xml",  
                    sproutUser        => "seed",  
                    sproutPass        => "",  
                    sproutSock        => "",  
                    sproutPort        => 3306,  
                    sprout_host       => "localhost",  
                    nmpdr_version     => $version_rel,  
                    nmpdr_release     => $version,  
                    nmpdr_base        => $FIG_Config::nmpdr_base,  
                    nmpdr_pages       => "$version_dir/html",  
                    preIndex          => 1,  
                    otherGroup        => "(supporting)",  
                    feature_types     => "peg rna pp pi",  
                    results_per_page  => 50,  
                    blast_limit       => 1000,  
                    prop_search_limit => 4,  
                    drug_directory    => "\$var/DrugTargets",  
                    dockLimit         => "00000100",  
                    advanced_class    => "FidSearch BlastSearch",  
                    splitter          => " : ",  
                    attrURL           => "http://anno-3.nmpdr.org/attrib_server/AttribXMLRPC.cgi",  
                    attrDbms          => "mysql",  
                    attrDbName        => "fig_v5_attributes",  
                    attrHost          => undef,  
                    attrUser          => "seed",  
                    attrPass          => "",  
                    attrPort          => 3306,  
                    attrSock          => undef,  
                    attrDBD           => "/disks/nmpdr/v$version/FIGdisk/FIG/AttributesDBD.xml",  
                    phone             => "{ user => 'BruceTheHumanPet', password => 'STARl00k', api_id => '2561022' }",  
                    nmpdr_mode        => 1,  
                    lib               => "\$FIG_Config::fig_disk/dist/releases/$version_rel/$FIG_Config::arch/lib",  
                    wiki_data         => "\$FIG_Config::fig/WikiData",  
                    web_app_db        => "{ -database => 'WebAppBackend', -host => 'bioseed.mcs.anl.gov', -user => 'root' };",  
                    app_name          => "NMPDR",  
                    live_server       => 0,  
                    sprout_host       => "localhost",  
                    ontology_db       => "\$FIG_Config::global/Ontology/ontology.sqlite",  
                    file_images_only  => 1,  
                    error_feed        => "rss2trace.xml",  
                    robot_feed        => 1,  
                    nmpdr_source      => "\$FIG_Config::fig_disk/dist/releases/current",  
                    kegg_maps         => $FIG_Config::kegg_maps,  
                    linkinSV          => "\$FIG_Config::cgi_url/wiki/rest.cgi/NmpdrPlugin/SeedViewer",  
395                    );                    );
     # Pull forward the server values from the current version.  
     for my $serverKey (qw(bbh_server_url sim_server_url pin_server_url pch_server_url use_pch_server)) {  
         my $value = eval("\$FIG_Config::$serverKey");  
         if (defined $value) {  
             $changes{$serverKey} = $value;  
         }  
     }  
   
     # Create a list of lines to be added to the front.  
     my $nmpdr_url = "http://" . $ENV{'HTTP-HOST'} . "/$options->{server}";  
     Trace("URL for this NMPDR release is $nmpdr_url") if T(2);  
     my $inserts = [  
                    "",  
                    "\$nmpdr_site_url = \"$nmpdr_url\";",  
                   ];  
396      if ($options->{test}) {      if ($options->{test}) {
397          Trace("Configuration file update would run from " . getcwd() . ".") if T(2);          Trace("Configuration file update would run from $new_config_dir.") if T(2);
398      } else {      } else {
399          Trace("Updating configuration file in " . getcwd() . ".") if T(2);          Trace("Updating configuration file $new_config.") if T(2);
400          DocUtils::ModifyConfigFile("FIG_Config.pm", \%changes, $inserts);          DocUtils::ModifyConfigFile($new_config, \%changes, []);
401      }      }
402      # The next step is to update the shell script. We need to add CVS information and      # The next step is to update the shell script. We need to add CVS information and
403      # the temp directory.      # the temp directory.
# Line 472  Line 405 
405                   CVS_RSH => 'ssh',                   CVS_RSH => 'ssh',
406                   TMPDIR => "$target_dir/FIG/Tmp",                   TMPDIR => "$target_dir/FIG/Tmp",
407                  );                  );
408      # Switch to the configuration directory.      # Switch to the new configuration directory.
409      ChDir("$target_dir/config");      ChDir($new_config_dir);
410      # Check to see if we're in test mode.      # Check to see if we're in test mode.
411      if ($options->{test}) {      if ($options->{test}) {
412          Trace("File fig-user-env.sh would be updated.") if T(2);          Trace("File fig-user-env.sh would be updated in " . getcwd() . ".") if T(2);
413          for my $elim (keys %elims) {          for my $elim (keys %elims) {
414              Trace("export $elim = \"$elims{$elim}\"") if T(2);              Trace("export $elim = \"$elims{$elim}\"") if T(2);
415          }          }
# Line 501  Line 434 
434          rename "fig-user-env.sh~", "fig-user-env.sh";          rename "fig-user-env.sh~", "fig-user-env.sh";
435      }      }
436      # Copy the WebApplication configuration subdirectory from the      # Copy the WebApplication configuration subdirectory from the
437      # current version to the next version. First, we get our current      # current version to the next version.
438      # configuration directory.      Insure("$new_config_dir/WebApplication");
439      my $currentConfig = "$FIG_Config::fig_disk/config";      if ($options->{test}) {
440      # Now we create the web-application subdirectory in the target directory.          Trace("WebApplication configuration files would be copied to $new_config_dir/WebApplication.") if T(2);
441      mkdir "WebApplication";      } else {
442      # Copy across the files inside.          my @lines = `cp -r $old_config_dir/WebApplication/* $new_config_dir/WebApplication`;
     my @lines = `cp -r $currentConfig/WebApplication/* $target_dir/config/WebApplication`;  
443      Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);      Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);
444        }
445      # Finally, create a marker file to protect this installation from      # Finally, create a marker file to protect this installation from
446      # automatic updates.      # automatic updates.
447      my $marker_file = "$target_dir/config/DISABLE_P2P";      my $marker_file = "$target_dir/config/DISABLE_P2P";
# Line 535  Line 468 
468      } else {      } else {
469          # Set the permissions.          # Set the permissions.
470          Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777);          Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777);
471            Trace("Permissions fixed in $version_dir.") if T(2);
472      }      }
473      Trace("Stage 4 complete.") if T(2);      Trace("Stage 4 complete.") if T(2);
474  }  }
475  #  #
476  # STAGE 5: Copy the cover pages.  # STAGE 5: Copy the wiki pages.
477  #  #
478  if ($options->{stage} <= 5) {  if ($options->{stage} <= 5) {
479      Trace("Copying cover pages.") if T(2);      # Make sure we have a place to put them.
480      my @syncData = `rsync --archive --recursive /disks/nmpdr/v$old_version/html $version_dir/`;      Insure("$target_dir/FIG/WikiData");
481        # Compute the sync command.
482        my $command = "rsync --archive --recursive --perms --group --exclude=Trash/ $FIG_Config::wiki_data/ $target_dir/FIG/WikiData/";
483        # Execute it.
484        if ($options->{test}) {
485            Trace("Command to execute:\n$command") if T(2);
486        } else {
487            Trace("Copying wiki pages.") if T(2);
488            my @syncData = `$command`;
489      Trace("Copy results\n" . join("\n", @syncData)) if T(3);      Trace("Copy results\n" . join("\n", @syncData)) if T(3);
490      # Create the version number file for the wiki.      }
     my $text = join("\n", "<?php",  
                           "\$wgNmpdrVersion = $version;",  
                           "?>",  
                           "");  
     my $fh = Tracer::Open(undef, ">$version_dir/html/wiki/extensions/NmpdrVersion.php");  
     print "$fh", $text;  
     close $fh;  
     Trace("Version file created for wiki.") if T(2);  
491      Trace("Stage 5 complete.") if T(2);      Trace("Stage 5 complete.") if T(2);
492  }  }
493  #  #
494  # STAGE 6: Copy the drug target files.  # STAGE 6: Copy the drug target files.
495  #  #
496  if ($options->{stage} <= 6) {  if ($options->{stage} <= 6) {
497        # Compute the sync command.
498        my $command = "rsync --archive --recursive $FIG_Config::var/DrugTargets $target_dir/FIG/var/";
499        if ($options->{test}) {
500            Trace("Command to execute:\n$command") if T(2);
501        } else {
502      Trace("Copying drug target files.") if T(2);      Trace("Copying drug target files.") if T(2);
503      my @syncData = `  rsync --archive --recursive /disks/nmpdr/v$old_version/FIGdisk/FIG/var/DrugTargets $version_dir/FIGdisk/FIG/var/`;          my @syncData = `$command`;
504      Trace("Copy results\n" . join("\n", @syncData)) if T(3);      Trace("Copy results\n" . join("\n", @syncData)) if T(3);
505        }
506      Trace("Stage 6 complete.") if T(2);      Trace("Stage 6 complete.") if T(2);
507  }  }
508    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3