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

Annotation of /Sprout/FigConfigFix.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 FIG_Config Fixup
4 :    
5 : parrello 1.4 This is a tiny utility script that fixes the web site url parameters in the NMPDR
6 :     FIG_Config files.
7 : parrello 1.1
8 :     =over 4
9 :    
10 :     The currently-supported command-line options are as follows.
11 :    
12 :     =over 4
13 :    
14 :     =item user
15 :    
16 :     Name suffix to be used for log files. If omitted, the PID is used.
17 :    
18 :     =item trace
19 :    
20 :     Numeric trace level. A higher trace level causes more messages to appear. The
21 :     default trace level is 2. Tracing will be directly to the standard output
22 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
23 :     where I<User> is the value of the B<user> option above.
24 :    
25 :     =item sql
26 :    
27 :     If specified, turns on tracing of SQL activity.
28 :    
29 :     =item background
30 :    
31 :     Save the standard and error output to files. The files will be created
32 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
33 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
34 :     B<user> option above.
35 :    
36 : parrello 1.4 =item help
37 : parrello 1.1
38 :     Display this command's parameters and options.
39 :    
40 :     =item phone
41 :    
42 :     Phone number to message when the script is complete.
43 :    
44 : parrello 1.4 =item live
45 :    
46 :     If specified, the NMPDR in question will be treated as the live NMPDR, which means
47 :     the current instance will not have a site type.
48 :    
49 : parrello 1.1 =back
50 :    
51 :     =cut
52 :    
53 :     use strict;
54 :     use Tracer;
55 :     use Cwd;
56 :     use File::Copy;
57 :     use File::Path;
58 :     use FIG;
59 : parrello 1.4 use DocUtils;
60 : parrello 1.1
61 :     # Get the command-line options and parameters.
62 : parrello 1.4 my ($options, @parameters) = StandardSetup([qw(File DocUtils) ],
63 : parrello 1.1 {
64 : parrello 1.4 live => [0, "indicates the target system is the live NMPDR"],
65 : parrello 1.1 phone => ["", "phone number (international format) to call when load finishes"],
66 :     },
67 : parrello 1.4 "",
68 : parrello 1.1 @ARGV);
69 :     # Set a variable to contain return type information.
70 :     my $rtype;
71 :     # Insure we catch errors.
72 :     eval {
73 : parrello 1.4 # Loop through the NMPDR types.
74 :     my @places = qw(prev cur next);
75 :     # We'll use the ModifyConfigFile utility from DocUtils to do the update.
76 :     for my $place (@places) {
77 :     # Locate this NMPDR.
78 :     my $loc = "$FIG_Config::nmpdr_base/$place";
79 :     if (! -d $loc) {
80 :     Trace("Nmpdr type \"$place\" not present.") if T(2);
81 :     } else {
82 :     # We found it. Update its config file.
83 :     my $config_file = "$FIG_Config::nmpdr_base/$place/FIGdisk/config/FIG_Config.pm";
84 :     # Determine the value we'll be putting in. If this is the current instance on
85 :     # the live system, the site type is null. Otherwise, it's the same as the
86 :     # instance type.
87 :     my $targat = ($options->{live} && $place eq 'cur' ? "" : "/$place");
88 :     Trace("Updating $config_file.") if T(2);
89 :     DocUtils::ModifyConfigFile($config_file, { nmpdr_site_type => "/$place" }, []);
90 :     }
91 : parrello 1.1 }
92 :     };
93 :     if ($@) {
94 :     Trace("Script failed with error: $@") if T(0);
95 :     $rtype = "error";
96 :     } else {
97 :     Trace("Script complete.") if T(2);
98 :     $rtype = "no error";
99 :     }
100 :     if ($options->{phone}) {
101 :     my $msgID = Tracer::SendSMS($options->{phone}, "FIG_Config Fixup terminated with $rtype.");
102 :     if ($msgID) {
103 :     Trace("Phone message sent with ID $msgID.") if T(2);
104 :     } else {
105 :     Trace("Phone message not sent.") if T(2);
106 :     }
107 :     }
108 :    
109 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3