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

View of /Sprout/FigConfigFix.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Tue Sep 16 18:53:47 2008 UTC (11 years, 3 months ago) by parrello
Branch: MAIN
CVS Tags: rast_2008_0924, rast_rel_2008_09_30, mgrast_rel_2008_0924, mgrast_rel_2008_0625, rast_rel_2008_10_09, rast_release_2008_09_29, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2008_09_29, mgrast_rel_2008_0917
Changes since 1.3: +30 -52 lines
Revamped to fit the new NMPDR procedures.

#!/usr/bin/perl -w

=head1 FIG_Config Fixup

This is a tiny utility script that fixes the web site url parameters in the NMPDR
FIG_Config files.

=over 4

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 help

Display this command's parameters and options.

=item phone

Phone number to message when the script is complete.

=item live

If specified, the NMPDR in question will be treated as the live NMPDR, which means
the current instance will not have a site type.

=back

=cut

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

# Get the command-line options and parameters.
my ($options, @parameters) = StandardSetup([qw(File DocUtils) ],
                                           {
                                              live => [0, "indicates the target system is the live NMPDR"],
                                              phone => ["", "phone number (international format) to call when load finishes"],
                                           },
                                           "",
                                           @ARGV);
# Set a variable to contain return type information.
my $rtype;
# Insure we catch errors.
eval {
    # Loop through the NMPDR types.
    my @places = qw(prev cur next);
    # We'll use the ModifyConfigFile utility from DocUtils to do the update.
    for my $place (@places) {
        # Locate this NMPDR.
        my $loc = "$FIG_Config::nmpdr_base/$place";
        if (! -d $loc) {
            Trace("Nmpdr type \"$place\" not present.") if T(2);
        } else {
            # We found it. Update its config file.
            my $config_file = "$FIG_Config::nmpdr_base/$place/FIGdisk/config/FIG_Config.pm";
            # Determine the value we'll be putting in. If this is the current instance on
            # the live system, the site type is null. Otherwise, it's the same as the
            # instance type.
            my $targat = ($options->{live} && $place eq 'cur' ? "" : "/$place");
            Trace("Updating $config_file.") if T(2);
            DocUtils::ModifyConfigFile($config_file, { nmpdr_site_type => "/$place" }, []);
        }
    }
};
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