#!/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. =item roll Change the URL for the new version to C and the URL for the old current version to C. =item fix Change the URL for the current version to C. =back The C command is used when updating or creating the staging site. The C 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 CIC<.log> file in the FIG temporary directory, where I is the value of the B 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 CIC<.log> and CIC<.log>, respectively, where I is the value of the B 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"], }, "", @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;