[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.9, Wed May 7 23:09:47 2008 UTC revision 1.15, Tue Sep 23 20:42:51 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>.
119    
120    =item logdir
121    
122    Directory to contain the log files. The default is C<logs> in the NMPDR base
123    directory.
124    
125    =item version
126    
127    If specified, displays information about this version of the NMPDR and exits.
128    
129  =back  =back
130    
131  =head2 Maintenance Notes  =head2 Maintenance Notes
# Line 124  Line 133 
133  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,
134  the CVS information is hard-coded.  the CVS information is hard-coded.
135    
 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.  
   
136  =cut  =cut
137    
138  use strict;  use strict;
# Line 136  Line 142 
142  use File::Copy;  use File::Copy;
143  use File::Path;  use File::Path;
144  use File::stat;  use File::stat;
 #use POSIX;  
145  use IO::Handle;  use IO::Handle;
146    use SFXlate;
147    
148  # Get the command-line options.  # Get the command-line options.
149  my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],  my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'],
150                                          { envDir =>   ["$FIG_Config::nmpdr_base/FIGdisk/env",                                          { envDir =>   ["$FIG_Config::nmpdr_base/FIGdisk/env",
151                                                         'environment directory containing pointers to applications and development tools'],                                                         'environment directory containing pointers to applications and development tools'],
152                                            blastMAT => ["copy",                                            blastMAT => ["copy", 'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'],
153                                                         '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'],
154                                            dataDir =>  ["0",                                            relName =>  ["nmpdr_XX", 'name to use for the release created (default "nmpdr_XX")'],
155                                                         'fully-qualified name of the SEED data directory to use; default is most recent'],                                            test =>     [0, 'print some data but do not run'],
156                                            relName =>  ["nmpdr_XX",                                            stage =>    [0, 'stage at which to start'],
157                                                         'name to use for the release created (default "nmpdr_XX")'],                                            force =>    [0, 'force an update over a possible existing SEED'],
158                                            test =>     [0,                                            group =>    ['fig', 'group to be given write permission for the new files'],
159                                                         'print some data but do not run'],                                            server =>   ['next', 'NMPDR version type'],
160                                            stage =>    [0,                                            trace =>    [3, 'tracing level'],
161                                                         'stage at which to start'],                                            logdir =>   ["$FIG_Config::nmpdr_base/logs", 'directory for log files'],
162                                            force =>    [0,                                            version =>  [0, 'print NMPDR version info and exit'],
                                                        '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'],  
163                                          },                                          },
164                                              '<versionNumber>',                                              '<versionNumber>',
165                                              @ARGV);                                              @ARGV);
# Line 182  Line 183 
183    
184  # Check the parameters.  # Check the parameters.
185  if (! $FIG_Config::nmpdr_base) {  if (! $FIG_Config::nmpdr_base) {
186      Confess("Please specify a value for FIG_Config::nmpdr_base.");      Confess("Please specify a directory value for FIG_Config::nmpdr_base.");
187  } elsif (! -d $FIG_Config::nmpdr_base) {  } elsif (! -d $FIG_Config::nmpdr_base) {
188      Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");      Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found.");
189  } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {  } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) {
190      Confess("BlastMAT TAR file not found at $blastmat_tarfile.");      Confess("BlastMAT TAR file not found at $blastmat_tarfile.");
191  } elsif (! -d $env_dir) {  } elsif (! -d $env_dir) {
192      Confess("Environment directory $env_dir not found.");      Confess("Environment directory $env_dir not found.");
193  } elsif (! $version) {  }
194    
195    # If this is version-display-only, display version info.
196    if ($options->{version}) {
197        Trace("Computing version information.") if T(3);
198        # We'll put the version data in here, a line at a time.
199        my @lines;
200        push @lines, "Current directory is " . getcwd . ".";
201        my $type = $FIG_Config::nmpdr_site_type;
202        $type =~ s#/##;
203        push @lines, "NMPDR version is $old_version with type \"$type\" for $FIG_Config::arch.";
204        push @lines, "Sprout database is $FIG_Config::sproutDB.";
205        push @lines, "Attribute database is $FIG_Config::attrDbName on $FIG_Config::attrHost.";
206        # This part is a little tricky. We want to see what's in the database, but it may
207        # not exist yet.
208        my $sproutLine = "Sprout database is not working.";
209        eval {
210            my $sprout = SFXlate->new_sprout_only();
211            # If we got this far, the database exists.
212            $sproutLine = "Sprout database is working.";
213            my $features = Tracer::CommaFormat($sprout->GetCount(['Feature'], "", []));
214            # Here the database exists and it has features in it.
215            $sproutLine = "Sprout database contains $features features.";
216        };
217        push @lines, $sproutLine;
218        # Check for load files.
219        if (! -d $FIG_Config::sproutData) {
220            push @lines, "No sprout load files found.";
221        } else {
222            my $dtxFiles = scalar(grep { $_ =~ /\.dtx$/i } Tracer::OpenDir("$FIG_Config::sproutData"));
223            push @lines, "$dtxFiles sprout load files found.";
224        }
225        Trace("NMPDR Version information:\n\n" . join("\n", @lines)) if T(2);
226        exit;
227    }
228    # Check the version parameter.
229    if (! $version) {
230      Confess("No version number specified.");      Confess("No version number specified.");
231  } elsif ($version !~ /^\d+$/) {  } elsif ($version !~ /^\d+$/) {
232      Confess("Invalid (non-numeric) version number $version.");      Confess("Invalid (non-numeric) version number $version.");
233  }  }
234  # Make the version number pretty.  # Make the version number pretty. This means stripping off the "v" (if any)
235    # and converting to two digits.
236    $version =~ s/^v//;
237  $version = sprintf("%02d", $version);  $version = sprintf("%02d", $version);
238  # Add the version number to the release name.  # Add the version number to the release name.
239  my $version_rel = $options->{relName};  my $version_rel = $options->{relName};
240  $version_rel =~ s/XX/$version/e;  $version_rel =~ s/XX/$version/e;
241    # Create the log file directory.
242    my $log_dir = $options->{logdir};
243    Insure($log_dir);
244    my $logFilePrefix = "$log_dir/v$version";
245  # Now we can start the setup.  # Now we can start the setup.
246  Trace("Creating NMPDR version $version with name $version_rel.");  Trace("Creating NMPDR version $version with name $version_rel.");
247  # Get the directory for the version-specific stuff.  # Get the directory for the version-specific stuff.
# Line 206  Line 249 
249  Insure($version_dir);  Insure($version_dir);
250  # This will be the directory of FIG stuff.  # This will be the directory of FIG stuff.
251  my $target_dir = "$version_dir/FIGdisk";  my $target_dir = "$version_dir/FIGdisk";
252    # This is a global for the name of the code directory.
253    my $code_dir = "$target_dir/dist/releases/$version_rel";
254  # Compute the Sprout database name.  # Compute the Sprout database name.
255  my $sprout_db_name = "nmpdr_v${version}_sprout";  my $sprout_db_name = "nmpdr_v${version}_sprout";
256  Trace("Starting at stage $options->{stage}.") if T(2);  Trace("Starting at stage $options->{stage}.") if T(2);
# Line 328  Line 373 
373      ChDir($rel);      ChDir($rel);
374      # Set up the CVS log file. Note it will be in the same directory as      # Set up the CVS log file. Note it will be in the same directory as
375      # our other log files with the same suffix.      # our other log files with the same suffix.
376      my $lf = "$FIG_Config::temp/CVS$options->{user}.log";      my $lf = "$logFilePrefix-CVS.log";
377      if ($options->{test}) {      if ($options->{test}) {
378          Trace("CVS checkout would be to " . getcwd() . ".") if T(2);          Trace("CVS checkout would be to " . getcwd() . ".") if T(2);
379      } else {      } else {
# Line 367  Line 412 
412          Trace("Configuration script would be executed from $target_dir.") if T(2);          Trace("Configuration script would be executed from $target_dir.") if T(2);
413      } else {      } else {
414          delete $ENV{PERL5LIB};          delete $ENV{PERL5LIB};
415          my $lf = "$FIG_Config::temp/Config$options->{user}.log";          my $lf = "$logFilePrefix-Config.log";
416          Trace("Executing configuration script from $target_dir.") if T(2);          Trace("Executing configuration script from $target_dir.") if T(2);
417          system("./configure $arch >$lf 2>&1");          system("./configure $arch $target_dir >$lf 2>&1");
418          if ($? != 0) {          if ($? != 0) {
419              Trace("Error during configuration script.") if T(0);              Trace("Error during configuration script.") if T(0);
420          }          }
# Line 381  Line 426 
426  #            and protect from updates.  #            and protect from updates.
427  #  #
428  if ($options->{stage} <= 3) {  if ($options->{stage} <= 3) {
429      # Switch to the configuration directory.      # Compute the configuration directory locations.
430      Insure("$target_dir/config");      my $old_config_dir = "$FIG_Config::fig_disk/config";
431      ChDir("$target_dir/config");      my $new_config_dir = "$target_dir/config";
432      # Create a hash of the changes that need to be made.      Insure($new_config_dir);
433        # Copy the old configuration. This destroys the config file created by the
434        # bootstrap.
435        my $old_config = "$old_config_dir/FIG_Config.pm";
436        my $new_config = "$new_config_dir/FIG_Config.pm";
437        if ($options->{test}) {
438            Trace("$old_config would be copied to $new_config.") if T(2);
439        } else {
440            Trace("Copying $old_config to $new_config") if T(2);
441            copy $old_config, $new_config;
442        }
443        # Next, we update the few lines at the beginning that have all the magic in them.
444        # Every other config value is derived from these three.
445      my %changes = (      my %changes = (
446                     temp_url          => "\$nmpdr_site_url/FIG-Tmp",          version => $version,
447                     cgi_url           => "\$nmpdr_site_url/FIG",          old_version => $FIG_Config::version,
448                     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",  
                    nmpdr_source      => "\$FIG_Config::fig_disk/dist/releases/current",  
449                    );                    );
     # 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\";",  
                   ];  
450      if ($options->{test}) {      if ($options->{test}) {
451          Trace("Configuration file update would run from " . getcwd() . ".") if T(2);          Trace("Configuration file update would run from $new_config_dir.") if T(2);
452      } else {      } else {
453          Trace("Updating configuration file in " . getcwd() . ".") if T(2);          Trace("Updating configuration file $new_config.") if T(2);
454          DocUtils::ModifyConfigFile("FIG_Config.pm", \%changes, $inserts);          DocUtils::ModifyConfigFile($new_config, \%changes, []);
455      }      }
456      # 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
457      # the temp directory.      # the temp directory.
# Line 469  Line 459 
459                   CVS_RSH => 'ssh',                   CVS_RSH => 'ssh',
460                   TMPDIR => "$target_dir/FIG/Tmp",                   TMPDIR => "$target_dir/FIG/Tmp",
461                  );                  );
462      # Switch to the configuration directory.      # Switch to the new configuration directory.
463      ChDir("$target_dir/config");      ChDir($new_config_dir);
464      # Check to see if we're in test mode.      # Check to see if we're in test mode.
465      if ($options->{test}) {      if ($options->{test}) {
466          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);
467          for my $elim (keys %elims) {          for my $elim (keys %elims) {
468              Trace("export $elim = \"$elims{$elim}\"") if T(2);              Trace("export $elim = \"$elims{$elim}\"") if T(2);
469          }          }
# Line 498  Line 488 
488          rename "fig-user-env.sh~", "fig-user-env.sh";          rename "fig-user-env.sh~", "fig-user-env.sh";
489      }      }
490      # Copy the WebApplication configuration subdirectory from the      # Copy the WebApplication configuration subdirectory from the
491      # current version to the next version. First, we get our current      # current version to the next version.
492      # configuration directory.      Insure("$new_config_dir/WebApplication");
493      my $currentConfig = "$FIG_Config::fig_disk/config";      if ($options->{test}) {
494      # 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);
495      mkdir "WebApplication";      } else {
496      # 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`;  
497      Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);      Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2);
498        }
499      # Finally, create a marker file to protect this installation from      # Finally, create a marker file to protect this installation from
500      # automatic updates.      # automatic updates.
501      my $marker_file = "$target_dir/config/DISABLE_P2P";      my $marker_file = "$target_dir/config/DISABLE_P2P";
# Line 521  Line 511 
511      Trace("Stage 3 complete.") if T(2);      Trace("Stage 3 complete.") if T(2);
512  }  }
513  #  #
514  # STAGE 4: fix the file permissions.  # STAGE 4: Fix the file permissions and do a make.
515  #  #
516  if ($options->{stage} <= 4) {  if ($options->{stage} <= 4) {
517      # Get the group name and ID.      # Get the group name and ID.
# Line 532  Line 522 
522      } else {      } else {
523          # Set the permissions.          # Set the permissions.
524          Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777);          Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777);
525            Trace("Permissions fixed in $version_dir.") if T(2);
526            # Make the build utilities executable.
527            my @utilities = grep { $_ =~ m/\.pl$/i } Tracer::OpenDir("$code_dir/WinBuild");
528            for my $script (@utilities) {
529                Trace("Fixing permissions for $script in $code_dir.") if T(3);
530                chmod 0775, "$code_dir/$script";
531            }
532        }
533        if ($options->{test}) {
534            Trace("Make would occur in directory $code_dir.") if T(2);
535        } else {
536            ChDir($code_dir);
537            Trace("Making in $code_dir.") if T(2);
538            my $lf = "$logFilePrefix-Make.log";
539            my @lines = `make 2>&1 1>$lf`;
540            if (scalar @lines) {
541                Trace("Messages from make:\n" . join("\n", @lines)) if T(1);
542            }
543            Trace("Make complete.") if T(2);
544      }      }
545      Trace("Stage 4 complete.") if T(2);      Trace("Stage 4 complete.") if T(2);
546  }  }
547  #  #
548  # STAGE 5: Copy the cover pages.  # STAGE 5: Copy the wiki pages.
549  #  #
550  if ($options->{stage} <= 5) {  if ($options->{stage} <= 5) {
551      Trace("Copying cover pages.") if T(2);      # Make sure we have a place to put them.
552      my @syncData = `rsync --archive --recursive /disks/nmpdr/v$old_version/html $version_dir/`;      Insure("$target_dir/FIG/WikiData");
553        # Compute the sync command.
554        my $command = "rsync --archive --recursive --perms --group --exclude=Trash/ $FIG_Config::wiki_data/ $target_dir/FIG/WikiData/";
555        # Execute it.
556        if ($options->{test}) {
557            Trace("Command to execute:\n$command") if T(2);
558        } else {
559            Trace("Copying wiki pages.") if T(2);
560            my @syncData = `$command`;
561      Trace("Copy results\n" . join("\n", @syncData)) if T(3);      Trace("Copy results\n" . join("\n", @syncData)) if T(3);
562      # 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);  
563      Trace("Stage 5 complete.") if T(2);      Trace("Stage 5 complete.") if T(2);
564  }  }
565  #  #
566  # STAGE 6: Copy the drug target files.  # STAGE 6: Copy the drug target files.
567  #  #
568  if ($options->{stage} <= 6) {  if ($options->{stage} <= 6) {
569        # Compute the sync command.
570        my $command = "rsync --archive --recursive $FIG_Config::var/DrugTargets $target_dir/FIG/var/";
571        if ($options->{test}) {
572            Trace("Command to execute:\n$command") if T(2);
573        } else {
574      Trace("Copying drug target files.") if T(2);      Trace("Copying drug target files.") if T(2);
575      my @syncData = `  rsync --archive --recursive /disks/nmpdr/v$old_version/FIGdisk/FIG/var/DrugTargets $version_dir/FIGdisk/FIG/var/`;          my @syncData = `$command`;
576      Trace("Copy results\n" . join("\n", @syncData)) if T(3);      Trace("Copy results\n" . join("\n", @syncData)) if T(3);
577        }
578      Trace("Stage 6 complete.") if T(2);      Trace("Stage 6 complete.") if T(2);
579  }  }
580    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3