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

View of /Sprout/FigConfigFix.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Thu Feb 14 19:05:35 2008 UTC (11 years, 10 months ago) by parrello
Branch: MAIN
CVS Tags: rast_rel_2008_06_18, rast_rel_2008_06_16, rast_rel_2008_07_21, rast_rel_2008_04_23, mgrast_rel_2008_0806, rast_rel_2008_08_07
Changes since 1.2: +6 -0 lines
Fixed to properly update the url_base configuration items.

#!/usr/bin/perl -w

=head1 FIG_Config Fixup

This is a tiny utility script that fixes the web site url parameter in the current
FIG_Config file. There is one positional parameter with the following possible values.

=over 4

=item stage

Change the URL to C<www.nmpdr.org/next>.

=item roll

Change the URL for the new version to C<www.nmpdr.org> and the URL for the old current version to
C<www.nmpdr.org/prev>.

=item fix

Change the URL for the current version to C<www.nmpdr.org>.

=back

The C<stage> command is used when updating or creating the staging site. The C<roll>
command is used when rolling over to a new live version.

The currently-supported command-line options are as follows.

=over 4

=item user

Name suffix to be used for log files. If omitted, the PID is used.

=item trace

Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is 2. Tracing will be directly to the standard output
as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
where I<User> is the value of the B<user> option above.

=item sql

If specified, turns on tracing of SQL activity.

=item background

Save the standard and error output to files. The files will be created
in the FIG temporary directory and will be named C<err>I<User>C<.log> and
C<out>I<User>C<.log>, respectively, where I<User> is the value of the
B<user> option above.

=item h

Display this command's parameters and options.

=item phone

Phone number to message when the script is complete.

=back

=cut

use strict;
use Tracer;
use Cwd;
use File::Copy;
use File::Path;
use FIG;

# Get the command-line options and parameters.
my ($options, @parameters) = StandardSetup([qw(File) ],
                                           {
                                              phone => ["", "phone number (international format) to call when load finishes"],
                                           },
                                           "<command>",
                                           @ARGV);
# Set a variable to contain return type information.
my $rtype;
# Insure we catch errors.
eval {
    # We'll use the ModifyConfigFile utility from DocUtils to do the update. Note we force
    # $live_server to 1.
    my $newValue;
    my $changes = { live_server => 1 };
    if ($parameters[0] eq 'stage') {
        $changes->{nmpdr_site_url} = "http://www.nmpdr.org/next";
        Trace("Changing nmpdr site URL for staging version to $changes->{nmpdr_site_url}.") if T(2);
        DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []);
    } elsif ($parameters[0] eq 'roll') {
        $changes->{nmpdr_site_url} = "http://www.nmpdr.org";
        $changes->{cgi_base} = '/FIG/';
        $changes->{temp_base} = '/FIG-Tmp/';
        Trace("Changing nmpdr site URL for new version to $changes->{nmpdr_site_url}.") if T(2);
        DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []);
        $changes->{nmpdr_site_url} = "http://www.nmpdr.org/prev";
        $changes->{cgi_base} = '/prev/FIG/';
        $changes->{temp_base} = '/prev/FIG-Tmp/';
        Trace("Changing nmpdr site URL for old version to $changes->{nmpdr_site_url}.") if T(2);
        DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []);
    } elsif ($parameters[0] eq 'fix') {
        $changes->{nmpdr_site_url} = "http://www.nmpdr.org";
        $changes->{cgi_base} = '/FIG/';
        $changes->{temp_base} = '/FIG-Tmp/';
        Trace("Changing nmpdr site URL for current version to $changes->{nmpdr_site_url}.") if T(2);
        DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []);
    } else {
        Confess("Invalid parameter $parameters[0].");
    }
};
if ($@) {
    Trace("Script failed with error: $@") if T(0);
    $rtype = "error";
} else {
    Trace("Script complete.") if T(2);
    $rtype = "no error";
}
if ($options->{phone}) {
    my $msgID = Tracer::SendSMS($options->{phone}, "FIG_Config Fixup terminated with $rtype.");
    if ($msgID) {
        Trace("Phone message sent with ID $msgID.") if T(2);
    } else {
        Trace("Phone message not sent.") if T(2);
    }
}



1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3