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

Annotation of /Sprout/FigConfigFix.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 FIG_Config Fixup
4 :    
5 :     This is a tiny utility script that fixes the web site url parameter in the current
6 :     FIG_Config file. There is one positional parameter with the following possible values.
7 :    
8 :     =over 4
9 :    
10 :     =item stage
11 :    
12 :     Change the URL to C<www.nmpdr.org/next>.
13 :    
14 :     =item roll
15 :    
16 :     Change the URL for the new version to C<www.nmpdr.org> and the URL for the old current version to
17 :     C<www.nmpdr.org/prev>.
18 :    
19 :     =item fix
20 :    
21 :     Change the URL for the current version to C<www.nmpdr.org>.
22 :    
23 :     =back
24 :    
25 :     The C<stage> command is used when updating or creating the staging site. The C<roll>
26 :     command is used when rolling over to a new live version.
27 :    
28 :     The currently-supported command-line options are as follows.
29 :    
30 :     =over 4
31 :    
32 :     =item user
33 :    
34 :     Name suffix to be used for log files. If omitted, the PID is used.
35 :    
36 :     =item trace
37 :    
38 :     Numeric trace level. A higher trace level causes more messages to appear. The
39 :     default trace level is 2. Tracing will be directly to the standard output
40 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
41 :     where I<User> is the value of the B<user> option above.
42 :    
43 :     =item sql
44 :    
45 :     If specified, turns on tracing of SQL activity.
46 :    
47 :     =item background
48 :    
49 :     Save the standard and error output to files. The files will be created
50 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
51 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
52 :     B<user> option above.
53 :    
54 :     =item h
55 :    
56 :     Display this command's parameters and options.
57 :    
58 :     =item phone
59 :    
60 :     Phone number to message when the script is complete.
61 :    
62 :     =back
63 :    
64 :     =cut
65 :    
66 :     use strict;
67 :     use Tracer;
68 :     use DocUtils;
69 :     use TestUtils;
70 :     use Cwd;
71 :     use File::Copy;
72 :     use File::Path;
73 :     use FIG;
74 :    
75 :     # Get the command-line options and parameters.
76 :     my ($options, @parameters) = StandardSetup([qw(File) ],
77 :     {
78 :     phone => ["", "phone number (international format) to call when load finishes"],
79 :     },
80 :     "<command>",
81 :     @ARGV);
82 :     # Set a variable to contain return type information.
83 :     my $rtype;
84 :     # Insure we catch errors.
85 :     eval {
86 :     # We'll use the ModifyConfigFile utility from DocUtils to do the update. We make only one change.
87 :     my $newValue;
88 :     if ($parameters[0] eq 'stage') {
89 :     my $changes = { nmpdr_site_url => "http://www.nmpdr.org/next" };
90 :     Trace("Changing nmpdr site URL for staging version to $changes->{nmpdr_site_url}.") if T(2);
91 :     DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []);
92 :     } elsif ($parameters[0] eq 'roll') {
93 :     my $changes = { nmpdr_site_url => "http://www.nmpdr.org" };
94 :     Trace("Changing nmpdr site URL for new version to $changes->{nmpdr_site_url}.") if T(2);
95 :     DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []);
96 :     $changes->{nmpdr_site_url} = "http://www.nmpdr.org/prev";
97 :     Trace("Changing nmpdr site URL for old version to $changes->{nmpdr_site_url}.") if T(2);
98 :     DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []);
99 :     } elsif ($parameters[0] eq 'fix') {
100 :     my $changes = { nmpdr_site_url => "http://www.nmpdr.org" };
101 :     Trace("Changing nmpdr site URL for current version to $changes->{nmpdr_site_url}.") if T(2);
102 :     DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []);
103 :     } else {
104 :     Confess("Invalid parameter $parameters[0].");
105 :     }
106 :     };
107 :     if ($@) {
108 :     Trace("Script failed with error: $@") if T(0);
109 :     $rtype = "error";
110 :     } else {
111 :     Trace("Script complete.") if T(2);
112 :     $rtype = "no error";
113 :     }
114 :     if ($options->{phone}) {
115 :     my $msgID = Tracer::SendSMS($options->{phone}, "FIG_Config Fixup terminated with $rtype.");
116 :     if ($msgID) {
117 :     Trace("Phone message sent with ID $msgID.") if T(2);
118 :     } else {
119 :     Trace("Phone message not sent.") if T(2);
120 :     }
121 :     }
122 :    
123 :    
124 :    
125 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3