Parent Directory
|
Revision Log
Revision 1.3 - (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 Cwd; | ||
69 : | use File::Copy; | ||
70 : | use File::Path; | ||
71 : | use FIG; | ||
72 : | |||
73 : | # Get the command-line options and parameters. | ||
74 : | my ($options, @parameters) = StandardSetup([qw(File) ], | ||
75 : | { | ||
76 : | phone => ["", "phone number (international format) to call when load finishes"], | ||
77 : | }, | ||
78 : | "<command>", | ||
79 : | @ARGV); | ||
80 : | # Set a variable to contain return type information. | ||
81 : | my $rtype; | ||
82 : | # Insure we catch errors. | ||
83 : | eval { | ||
84 : | parrello | 1.2 | # We'll use the ModifyConfigFile utility from DocUtils to do the update. Note we force |
85 : | # $live_server to 1. | ||
86 : | parrello | 1.1 | my $newValue; |
87 : | parrello | 1.2 | my $changes = { live_server => 1 }; |
88 : | parrello | 1.1 | if ($parameters[0] eq 'stage') { |
89 : | parrello | 1.2 | $changes->{nmpdr_site_url} = "http://www.nmpdr.org/next"; |
90 : | parrello | 1.1 | 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 : | parrello | 1.2 | $changes->{nmpdr_site_url} = "http://www.nmpdr.org"; |
94 : | parrello | 1.3 | $changes->{cgi_base} = '/FIG/'; |
95 : | $changes->{temp_base} = '/FIG-Tmp/'; | ||
96 : | parrello | 1.1 | Trace("Changing nmpdr site URL for new version to $changes->{nmpdr_site_url}.") if T(2); |
97 : | DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/next/FIGdisk/config/FIG_Config.pm", $changes, []); | ||
98 : | $changes->{nmpdr_site_url} = "http://www.nmpdr.org/prev"; | ||
99 : | parrello | 1.3 | $changes->{cgi_base} = '/prev/FIG/'; |
100 : | $changes->{temp_base} = '/prev/FIG-Tmp/'; | ||
101 : | parrello | 1.1 | Trace("Changing nmpdr site URL for old version to $changes->{nmpdr_site_url}.") if T(2); |
102 : | DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []); | ||
103 : | } elsif ($parameters[0] eq 'fix') { | ||
104 : | parrello | 1.2 | $changes->{nmpdr_site_url} = "http://www.nmpdr.org"; |
105 : | parrello | 1.3 | $changes->{cgi_base} = '/FIG/'; |
106 : | $changes->{temp_base} = '/FIG-Tmp/'; | ||
107 : | parrello | 1.1 | Trace("Changing nmpdr site URL for current version to $changes->{nmpdr_site_url}.") if T(2); |
108 : | DocUtils::ModifyConfigFile("$FIG_Config::nmpdr_base/cur/FIGdisk/config/FIG_Config.pm", $changes, []); | ||
109 : | } else { | ||
110 : | Confess("Invalid parameter $parameters[0]."); | ||
111 : | } | ||
112 : | }; | ||
113 : | if ($@) { | ||
114 : | Trace("Script failed with error: $@") if T(0); | ||
115 : | $rtype = "error"; | ||
116 : | } else { | ||
117 : | Trace("Script complete.") if T(2); | ||
118 : | $rtype = "no error"; | ||
119 : | } | ||
120 : | if ($options->{phone}) { | ||
121 : | my $msgID = Tracer::SendSMS($options->{phone}, "FIG_Config Fixup terminated with $rtype."); | ||
122 : | if ($msgID) { | ||
123 : | Trace("Phone message sent with ID $msgID.") if T(2); | ||
124 : | } else { | ||
125 : | Trace("Phone message not sent.") if T(2); | ||
126 : | } | ||
127 : | } | ||
128 : | |||
129 : | |||
130 : | |||
131 : | 1; |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |