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

Diff of /Sprout/FigConfigFix.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Thu Feb 14 19:05:35 2008 UTC revision 1.4, Tue Sep 16 18:53:47 2008 UTC
# Line 2  Line 2 
2    
3  =head1 FIG_Config Fixup  =head1 FIG_Config Fixup
4    
5  This is a tiny utility script that fixes the web site url parameter in the current  This is a tiny utility script that fixes the web site url parameters in the NMPDR
6  FIG_Config file. There is one positional parameter with the following possible values.  FIG_Config files.
7    
8  =over 4  =over 4
9    
 =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.  
   
10  The currently-supported command-line options are as follows.  The currently-supported command-line options are as follows.
11    
12  =over 4  =over 4
# Line 51  Line 33 
33  C<out>I<User>C<.log>, respectively, where I<User> is the value of the  C<out>I<User>C<.log>, respectively, where I<User> is the value of the
34  B<user> option above.  B<user> option above.
35    
36  =item h  =item help
37    
38  Display this command's parameters and options.  Display this command's parameters and options.
39    
# Line 59  Line 41 
41    
42  Phone number to message when the script is complete.  Phone number to message when the script is complete.
43    
44    =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  =back  =back
50    
51  =cut  =cut
# Line 69  Line 56 
56  use File::Copy;  use File::Copy;
57  use File::Path;  use File::Path;
58  use FIG;  use FIG;
59    use DocUtils;
60    
61  # Get the command-line options and parameters.  # Get the command-line options and parameters.
62  my ($options, @parameters) = StandardSetup([qw(File) ],  my ($options, @parameters) = StandardSetup([qw(File DocUtils) ],
63                                             {                                             {
64                                                  live => [0, "indicates the target system is the live NMPDR"],
65                                                phone => ["", "phone number (international format) to call when load finishes"],                                                phone => ["", "phone number (international format) to call when load finishes"],
66                                             },                                             },
67                                             "<command>",                                             "",
68                                             @ARGV);                                             @ARGV);
69  # Set a variable to contain return type information.  # Set a variable to contain return type information.
70  my $rtype;  my $rtype;
71  # Insure we catch errors.  # Insure we catch errors.
72  eval {  eval {
73      # We'll use the ModifyConfigFile utility from DocUtils to do the update. Note we force      # Loop through the NMPDR types.
74      # $live_server to 1.      my @places = qw(prev cur next);
75      my $newValue;      # We'll use the ModifyConfigFile utility from DocUtils to do the update.
76      my $changes = { live_server => 1 };      for my $place (@places) {
77      if ($parameters[0] eq 'stage') {          # Locate this NMPDR.
78          $changes->{nmpdr_site_url} = "http://www.nmpdr.org/next";          my $loc = "$FIG_Config::nmpdr_base/$place";
79          Trace("Changing nmpdr site URL for staging version to $changes->{nmpdr_site_url}.") if T(2);          if (! -d $loc) {
80          DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []);              Trace("Nmpdr type \"$place\" not present.") if T(2);
     } 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, []);  
81      } else {      } else {
82          Confess("Invalid parameter $parameters[0].");              # 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      }      }
92  };  };
93  if ($@) {  if ($@) {
# Line 126  Line 106 
106      }      }
107  }  }
108    
   
   
109  1;  1;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3