Parent Directory
|
Revision Log
Revision 1.2 - (view) (download) (as text)
1 : | parrello | 1.1 | #!/usr/bin/perl -w |
2 : | |||
3 : | =head1 NMPDR Setup Script | ||
4 : | |||
5 : | This script sets up a new version of the NMPDR web complex. It takes a single | ||
6 : | positional parameter-- the numeric ID of the new version. So, for example | ||
7 : | |||
8 : | NMPDRSetup 07 | ||
9 : | |||
10 : | would set up version 7. | ||
11 : | |||
12 : | The script should run as part of the previous version. It will set up a new | ||
13 : | version on the same machine. At some later point we may want to make it more | ||
14 : | flexible. | ||
15 : | |||
16 : | To run this script in the background, use something like | ||
17 : | |||
18 : | nohup NMPDRSetup -background -user=You 07 >null & | ||
19 : | |||
20 : | This will cause the output, error, and trace files to be produced in the | ||
21 : | FIG temporary directory. The output file will be C<outYou.log>, the | ||
22 : | error file will be C<errYou.log>, and the trace file C<traceYou.log>. | ||
23 : | |||
24 : | Currently, the development NMPDR runs on the nmpdr-1 server, while | ||
25 : | the production NMPDR runs on the nmpdr-3 server. When copying files | ||
26 : | between servers for purposes of synchronization, it is important that | ||
27 : | the rsync originate from the destination server so that the ownership is | ||
28 : | not all messed up. | ||
29 : | |||
30 : | =over 4 | ||
31 : | |||
32 : | =item trace | ||
33 : | |||
34 : | Numeric trace level. A higher trace level causes more messages to appear. The | ||
35 : | default trace level is 2. | ||
36 : | |||
37 : | =item user | ||
38 : | |||
39 : | User name to append to trace and output file names. If none is specified, the | ||
40 : | PID is used. | ||
41 : | |||
42 : | =item envDir | ||
43 : | |||
44 : | Fully-qualified name of the environment directory. The default is | ||
45 : | C<$FIG_Config::nmpdr_base/env>. | ||
46 : | |||
47 : | =item relName | ||
48 : | |||
49 : | Name to use for the release created. The default is C<nmpdr_XX>, where XX is the vesion | ||
50 : | number. In general, any use of C<XX> in the release name will be replaced by the two- | ||
51 : | digit version number in the positional parameters. | ||
52 : | |||
53 : | =item blastMAT | ||
54 : | |||
55 : | Location of the BLAST tar file. The default is C<$FIG_Config::nmpdr_base/BLASTMAT.tgz>. If | ||
56 : | C<copy> is specified, the BLAST directory is copied from this version to the new version. | ||
57 : | |||
58 : | =item h | ||
59 : | |||
60 : | Display this command's parameters and options. | ||
61 : | |||
62 : | =item dataDir | ||
63 : | |||
64 : | Path for the SEED data directory. The default is C<0>, which indicates the most | ||
65 : | recently-modified directory will be used. | ||
66 : | |||
67 : | =item force | ||
68 : | |||
69 : | Delete any existing SEED. If this option is not specified, the program will fail | ||
70 : | if it finds a SEED already at the location of the new NMPDR. | ||
71 : | |||
72 : | =item test | ||
73 : | |||
74 : | If specified, information is displayed but nothing is changed. | ||
75 : | |||
76 : | =item stage | ||
77 : | |||
78 : | Specify the stage at which to start. The current stages are as follows | ||
79 : | |||
80 : | =over 4 | ||
81 : | |||
82 : | =item 1 Set up directories and check out the source. | ||
83 : | |||
84 : | =item 2 Bootstrap and build the new FIG. | ||
85 : | |||
86 : | =item 3 Perform configuration fixes. | ||
87 : | |||
88 : | =item 4 Fix file permissions. | ||
89 : | |||
90 : | parrello | 1.2 | =item 5 Copy the cover pages. |
91 : | |||
92 : | =item 6 Copy the drug target files. | ||
93 : | parrello | 1.1 | |
94 : | =back | ||
95 : | |||
96 : | =item group | ||
97 : | |||
98 : | Name of the group to be given write permission for all the files. The default | ||
99 : | is C<figadmin>. | ||
100 : | |||
101 : | =item server | ||
102 : | |||
103 : | Name of the server that contains the NMPDR cover pages. | ||
104 : | |||
105 : | =back | ||
106 : | |||
107 : | =head2 Maintenance Notes | ||
108 : | |||
109 : | This script will need to be updated if the default directories change. In addition, | ||
110 : | the CVS information is hard-coded. | ||
111 : | |||
112 : | Currently the FIG_Config is set up to use the NEXT pointer in the proxy URL system. | ||
113 : | This means it has to be edited manually during the cutover. | ||
114 : | |||
115 : | =cut | ||
116 : | |||
117 : | use strict; | ||
118 : | use Tracer; | ||
119 : | use DocUtils; | ||
120 : | use TestUtils; | ||
121 : | use Cwd; | ||
122 : | use File::Copy; | ||
123 : | use File::Path; | ||
124 : | use File::stat; | ||
125 : | use POSIX; | ||
126 : | use IO::Handle; | ||
127 : | |||
128 : | # Get the command-line options. | ||
129 : | my ($options, @parameters) = StandardSetup(['Sprout', 'DocUtils'], | ||
130 : | { envDir => ["$FIG_Config::nmpdr_base/FIGdisk/env", | ||
131 : | 'environment directory containing pointers to applications and development tools'], | ||
132 : | blastMAT => ["copy", | ||
133 : | 'BLASTMAT TAR file or "copy" to copy the source BLASTMAT directory'], | ||
134 : | dataDir => ["0", | ||
135 : | 'fully-qualified name of the SEED data directory to use; default is most recent'], | ||
136 : | relName => ["nmpdr_XX", | ||
137 : | 'name to use for the release created (default "nmpdr_XX")'], | ||
138 : | test => [0, | ||
139 : | 'print some data but do not run'], | ||
140 : | stage => [0, | ||
141 : | 'stage at which to start'], | ||
142 : | force => [0, | ||
143 : | 'force an update over a possible existing SEED'], | ||
144 : | group => ['fig', | ||
145 : | 'group to be given write permission for the new files'], | ||
146 : | server => ['nmpdr-1.nmpdr.org', | ||
147 : | 'name of the server containing the development NMPDR cover pages'], | ||
148 : | }, | ||
149 : | '<versionID>', | ||
150 : | @ARGV); | ||
151 : | |||
152 : | # Get the main directory names. | ||
153 : | my $arch = $FIG_Config::arch; | ||
154 : | my $env_dir = $options->{envDir}; | ||
155 : | my $blastmat_tarfile = $options->{blastMAT}; | ||
156 : | my $base_dir = $FIG_Config::nmpdr_base; | ||
157 : | |||
158 : | parrello | 1.2 | # Get the new version number. |
159 : | parrello | 1.1 | my $version = $parameters[0]; |
160 : | parrello | 1.2 | # Compute the current version number. |
161 : | $FIG_Config::nmpdr_version =~ /(\d+)/; | ||
162 : | my $old_version = $1; | ||
163 : | parrello | 1.1 | |
164 : | # Set up the CVS data. Note that we are using an anonymous login. You can | ||
165 : | # update from the NMPDR server but you can't commit! | ||
166 : | my $cvsroot = ":pserver:anonymous\@biocvs.mcs.anl.gov:/disks/cvs/bio"; | ||
167 : | my $cvs_packages = "seed_base GBrowse Sprout NmpdrConfigs FigSeedViewer PPO SubsystemEditor WebApplication"; | ||
168 : | |||
169 : | # Check the parameters. Note that if the starting stage is 5 (display instructions), we don't need to do any of this. | ||
170 : | if ($options->{stage} < 5) { | ||
171 : | if (! $FIG_Config::nmpdr_base) { | ||
172 : | Confess("Please specify a value for FIG_Config::nmpdr_base."); | ||
173 : | } elsif (! -d $FIG_Config::nmpdr_base) { | ||
174 : | Confess("NMPDR base directory \"$FIG_Config::nmpdr_base\" not found."); | ||
175 : | } elsif ($blastmat_tarfile ne 'copy' && ! -e $blastmat_tarfile) { | ||
176 : | Confess("BlastMAT TAR file not found at $blastmat_tarfile."); | ||
177 : | } elsif (! -d $env_dir) { | ||
178 : | Confess("Environment directory $env_dir not found."); | ||
179 : | } elsif (! $version) { | ||
180 : | Confess("No version number specified."); | ||
181 : | } elsif ($version !~ /^\d+$/) { | ||
182 : | Confess("Invalid (non-numeric) version number $version."); | ||
183 : | } | ||
184 : | } | ||
185 : | # Make the version number pretty. | ||
186 : | $version = sprintf("%02d", $version); | ||
187 : | # Add the version number to the release name. | ||
188 : | my $version_rel = $options->{relName}; | ||
189 : | $version_rel =~ s/XX/$version/e; | ||
190 : | # Now we can start the setup. | ||
191 : | Trace("Creating NMPDR version $version with name $version_rel."); | ||
192 : | # Get the directory for the version-specific stuff. | ||
193 : | my $version_dir = "$base_dir/v$version"; | ||
194 : | Insure($version_dir); | ||
195 : | # This will be the directory of FIG stuff. | ||
196 : | my $target_dir = "$version_dir/FIGdisk"; | ||
197 : | # Compute the Sprout database name. | ||
198 : | my $sprout_db_name = "nmpdr_v${version}_sprout"; | ||
199 : | Trace("Starting at stage $options->{stage}.") if T(2); | ||
200 : | # | ||
201 : | # Stage 1: SEED directories and CVS source. | ||
202 : | # | ||
203 : | if ($options->{stage} <= 1) { | ||
204 : | # Insure we're not wiping out an old SEED. | ||
205 : | if (-e $target_dir) { | ||
206 : | if ($options->{force}) { | ||
207 : | # Here we have an old seed but we want to build over the | ||
208 : | # top of it. | ||
209 : | Trace("Deleting SEED already in place.") if T(2); | ||
210 : | if ($options->{test}) { | ||
211 : | Trace("Tree $target_dir would be deleted.") if T(2); | ||
212 : | } else { | ||
213 : | rmtree($target_dir); | ||
214 : | } | ||
215 : | } else { | ||
216 : | Confess("A SEED was already found at $target_dir. Use \"-force\" to force an update anyway."); | ||
217 : | } | ||
218 : | } | ||
219 : | # At this point, if we're still alive, there's no target directory, so | ||
220 : | # we want to create it. | ||
221 : | Insure($target_dir); | ||
222 : | # Build the main FIG directory. | ||
223 : | Insure("$target_dir/FIG"); | ||
224 : | # Build the temporary directory. | ||
225 : | Insure("$target_dir/FIG/Tmp"); | ||
226 : | # Build the sprout data directory. | ||
227 : | Insure("$target_dir/FIG/SproutData"); | ||
228 : | # Now we create the code directories. | ||
229 : | Insure("$target_dir/dist"); | ||
230 : | Insure("$target_dir/dist/releases"); | ||
231 : | parrello | 1.2 | # Finally, we create the directory that holds the cover pages. |
232 : | parrello | 1.1 | Insure("$version_dir/html"); |
233 : | # Change to the target directory. This means we're inside FIGdisk and above | ||
234 : | # FIG. | ||
235 : | ChDir($target_dir); | ||
236 : | # Symbolically link to the environment directory. | ||
237 : | if ($options->{test}) { | ||
238 : | Trace("Symlink from env to $env_dir would have been created.") if T(2); | ||
239 : | } else { | ||
240 : | do_symlink($env_dir, "env"); | ||
241 : | } | ||
242 : | # Create the BLASTMat directory. | ||
243 : | if ($blastmat_tarfile eq 'copy') { | ||
244 : | # Here we are copying the BLAST data from the previous version. | ||
245 : | my $new_blastmat = "$target_dir/BLASTMAT"; | ||
246 : | Insure($new_blastmat); | ||
247 : | if ($options->{test}) { | ||
248 : | Trace("BLASTMAT data will be copied from $FIG_Config::blastmat to $target_dir/BLASTMAT.") if T(2); | ||
249 : | } else { | ||
250 : | Trace("Copying BLASTMAT directory from $FIG_Config::blastmat to $new_blastmat.") if T(2); | ||
251 : | for my $fileName (OpenDir($FIG_Config::blastmat)) { | ||
252 : | copy "$FIG_Config::blastmat/$fileName", "$new_blastmat/$fileName"; | ||
253 : | } | ||
254 : | } | ||
255 : | } else { | ||
256 : | # Here we are extracting the BLAST data from a TAR file. | ||
257 : | if ($options->{test}) { | ||
258 : | Trace("BLASTMAT would have been pulled from $blastmat_tarfile.") if T(2); | ||
259 : | } else { | ||
260 : | do_untar($blastmat_tarfile); | ||
261 : | } | ||
262 : | } | ||
263 : | # Next we copy the Sprout group file. | ||
264 : | my $newSproutDataDir = "$target_dir/FIG/SproutData"; | ||
265 : | if ($options->{test}) { | ||
266 : | Trace("Sprout groups table would be copied from $FIG_Config::sproutData to $newSproutDataDir.") if T(2); | ||
267 : | } else { | ||
268 : | Trace("Copying Sprout groups table from $FIG_Config::sproutData to $newSproutDataDir.") if T(2); | ||
269 : | copy "$FIG_Config::sproutData/groups.tbl", "$newSproutDataDir/groups.tbl"; | ||
270 : | } | ||
271 : | # Now we need to symbolically link the data directory to the NMPDR master SEED. | ||
272 : | my $best_data = ""; | ||
273 : | if ($options->{dataDir} ne "0") { | ||
274 : | # Here the user specified a particular directory. | ||
275 : | $best_data = $options->{dataDir}; | ||
276 : | } else { | ||
277 : | # Here we want the most recently-modified data directory under | ||
278 : | # $base_dir/FIGdisk/FIG. | ||
279 : | my $data_base = "$base_dir/FIGdisk/FIG"; | ||
280 : | my @possibleDatas = grep { $_ =~ /^Data/ } OpenDir("$data_base"); | ||
281 : | my $best_time = 0; | ||
282 : | Trace(scalar(@possibleDatas) . " subdirectories found under $data_base.") if T(2); | ||
283 : | for my $possibleData (@possibleDatas) { | ||
284 : | # Note we're using the File::stat thing here, which returns a hash of the | ||
285 : | # file info, instead of the built-in function. | ||
286 : | my $this_data = "$data_base/$possibleData"; | ||
287 : | my $fileInfo = stat $this_data; | ||
288 : | Trace("Directory $this_data has modify time " . $fileInfo->mtime . ".") if T(3); | ||
289 : | if ($fileInfo->mtime >= $best_time) { | ||
290 : | Trace("Directory $this_data selected.") if T(3); | ||
291 : | $best_data = $this_data; | ||
292 : | $best_time = $fileInfo->mtime; | ||
293 : | } | ||
294 : | } | ||
295 : | # If we didn't find any data, it's an error. | ||
296 : | if (! $best_data) { | ||
297 : | Confess("Could not find a data directory under $data_base."); | ||
298 : | } | ||
299 : | } | ||
300 : | # Verify that we have a directory. | ||
301 : | if (! -d $best_data) { | ||
302 : | Confess("Cannot use $best_data because it is not a directory."); | ||
303 : | } | ||
304 : | # Symlink to the data directory we found. Now it will appear to be a part | ||
305 : | # of the normal FIG data structure tree. | ||
306 : | if ($options->{test}) { | ||
307 : | Trace("Directory $best_data will be used for FIG/Data.") if T(2); | ||
308 : | } else { | ||
309 : | do_symlink($best_data, "FIG/Data"); | ||
310 : | } | ||
311 : | # Change to the code directory. | ||
312 : | ChDir("dist/releases"); | ||
313 : | # Create a directory to hold the release. | ||
314 : | my $rel = $version_rel; | ||
315 : | Insure($rel); | ||
316 : | ChDir($rel); | ||
317 : | # Set up the CVS log file. Note it will be in the same directory as | ||
318 : | # our other log files with the same suffix. | ||
319 : | my $lf = "$FIG_Config::temp/CVS$options->{user}.log"; | ||
320 : | if ($options->{test}) { | ||
321 : | Trace("CVS checkout would be to " . getcwd() . ".") if T(2); | ||
322 : | } else { | ||
323 : | Trace("Checking out from CVS.") if T(2); | ||
324 : | my $rc = system("cvs -d $cvsroot co $cvs_packages >$lf 2>&1 "); | ||
325 : | if ($? != 0) { | ||
326 : | # Here the checkout failed. | ||
327 : | Confess("Error during CVS checkout for $cvsroot."); | ||
328 : | } else { | ||
329 : | Trace("CVS checkout log is in $lf.") if T(2); | ||
330 : | } | ||
331 : | # Now copy the configuration script and make it executable. | ||
332 : | copy("FigCommon/configure", "$target_dir/configure") || | ||
333 : | Confess("Could not copy configuration script."); | ||
334 : | chmod 0775, "$target_dir/configure"; | ||
335 : | # Copy the make file. | ||
336 : | copy("ReleaseTools/Makefile.top", "Makefile") || | ||
337 : | Confess("Could not copy master make file."); | ||
338 : | # Write out the release name. | ||
339 : | Open(\*RELFILE, ">$target_dir/DEFAULT_RELEASE"); | ||
340 : | print RELFILE "$rel\n"; | ||
341 : | close(RELFILE); | ||
342 : | # Hack out the PostGres initialization. NMPDR is MySQL-only. | ||
343 : | unlink("FigCommon/env.$arch.pl"); | ||
344 : | } | ||
345 : | Trace("Stage 1 complete.") if T(2); | ||
346 : | } | ||
347 : | # | ||
348 : | # STAGE 2: Bootstrap and build the new FIG. | ||
349 : | # | ||
350 : | if ($options->{stage} <= 2) { | ||
351 : | # Change to the target FIG directory. We'll run the configuration | ||
352 : | # script from here, and it requires another log file. | ||
353 : | ChDir($target_dir); | ||
354 : | if ($options->{test}) { | ||
355 : | Trace("Configuration script would be executed from $target_dir.") if T(2); | ||
356 : | } else { | ||
357 : | delete $ENV{PERL5LIB}; | ||
358 : | my $lf = "$FIG_Config::temp/Config$options->{user}.log"; | ||
359 : | Trace("Executing configuration script from $target_dir.") if T(2); | ||
360 : | system("./configure $arch >$lf 2>&1"); | ||
361 : | if ($? != 0) { | ||
362 : | Trace("Error during configuration script.") if T(0); | ||
363 : | } | ||
364 : | } | ||
365 : | Trace("Stage 2 complete.") if T(2); | ||
366 : | } | ||
367 : | # | ||
368 : | parrello | 1.2 | # STAGE 3: Configure FIG_Config and the config script |
369 : | # and protect from updates. | ||
370 : | parrello | 1.1 | # |
371 : | if ($options->{stage} <= 3) { | ||
372 : | # Switch to the configuration directory. | ||
373 : | Insure("$target_dir/config"); | ||
374 : | ChDir("$target_dir/config"); | ||
375 : | # Create a hash of the changes that need to be made. | ||
376 : | my %changes = ( | ||
377 : | temp_url => "\$nmpdr_site_url/FIG-Tmp", | ||
378 : | cgi_url => "\$nmpdr_site_url/FIG", | ||
379 : | template_url => "\$nmpdr_site_url/templates", | ||
380 : | java => $FIG_Config::java, | ||
381 : | dbms => "mysql", | ||
382 : | sproutDbms => "mysql", | ||
383 : | db => $FIG_Config::db, | ||
384 : | dbuser => $FIG_Config::dbuser, | ||
385 : | dbpass => $FIG_Config::dbpass, | ||
386 : | dbsock => $FIG_Config::dbsock, | ||
387 : | dbport => $FIG_Config::dbport, | ||
388 : | sproutDB => $sprout_db_name, | ||
389 : | oldSproutDB => $FIG_Config::sproutDB, | ||
390 : | oldSproutDBD => "$FIG_Config::fig/SproutDBD.xml", | ||
391 : | sproutUser => "seed", | ||
392 : | sproutPass => "", | ||
393 : | sproutSock => "", | ||
394 : | sproutPort => 3306, | ||
395 : | nmpdr_version => $version_rel, | ||
396 : | nmpdr_base => $FIG_Config::nmpdr_base, | ||
397 : | nmpdr_pages => "$version_dir/html", | ||
398 : | preIndex => 1, | ||
399 : | otherGroup => "(supporting)", | ||
400 : | feature_types => "peg rna pp pi", | ||
401 : | results_per_page => 50, | ||
402 : | blast_limit => 1000, | ||
403 : | prop_search_limit => 4, | ||
404 : | drug_directory => "\$var/DrugTargets", | ||
405 : | dockLimit => "00000030", | ||
406 : | advanced_class => "FidSearch BlastSearch", | ||
407 : | splitter => " : ", | ||
408 : | attrURL => "http://anno-3.nmpdr.org/attrib_server/AttribXMLRPC.cgi", | ||
409 : | attrDbms => "mysql", | ||
410 : | attrDbName => "fig_v5_attributes", | ||
411 : | attrHost => undef, | ||
412 : | attrUser => "seed", | ||
413 : | attrPass => "", | ||
414 : | attrPort => 3306, | ||
415 : | attrSock => undef, | ||
416 : | attrDBD => "/disks/nmpdr/v$version/FIGdisk/FIG/AttributesDBD.xml", | ||
417 : | parrello | 1.2 | phone => "{ user => 'BruceTheHumanPet', password => 'STARl00k', api_id => '2561022' }", |
418 : | nmpdr_mode => 1, | ||
419 : | parrello | 1.1 | ); |
420 : | parrello | 1.2 | # Pull forward the server values from the current version. |
421 : | for my $serverKey (qw(bbh_server_url sim_server_url pin_server_url pch_server_url use_pch_server)) { | ||
422 : | my $value = eval("\$FIG_Config::$serverKey"); | ||
423 : | if (defined $value) { | ||
424 : | $changes{$serverKey} = $value; | ||
425 : | } | ||
426 : | } | ||
427 : | |||
428 : | parrello | 1.1 | # Create a list of lines to be added to the front. |
429 : | my $inserts = [ | ||
430 : | "", | ||
431 : | "\$nmpdr_site_url = \"http://$options->{server}/next\";", | ||
432 : | ]; | ||
433 : | if ($options->{test}) { | ||
434 : | Trace("Configuration file update would run from " . getcwd() . ".") if T(2); | ||
435 : | } else { | ||
436 : | Trace("Updating configuration file in " . getcwd() . ".") if T(2); | ||
437 : | DocUtils::ModifyConfigFile("FIG_Config.pm", \%changes, $inserts); | ||
438 : | } | ||
439 : | # The next step is to update the shell script. We need to add CVS information and | ||
440 : | # the temp directory. | ||
441 : | my %elims = (CVSROOT => $cvsroot, | ||
442 : | CVS_RSH => 'ssh', | ||
443 : | TMPDIR => "$target_dir/FIG/Tmp", | ||
444 : | ); | ||
445 : | # Switch to the configuration directory. | ||
446 : | ChDir("$target_dir/config"); | ||
447 : | # Check to see if we're in test mode. | ||
448 : | if ($options->{test}) { | ||
449 : | Trace("File fig-user-env.sh would be updated.") if T(2); | ||
450 : | for my $elim (keys %elims) { | ||
451 : | Trace("export $elim = \"$elims{$elim}\"") if T(2); | ||
452 : | } | ||
453 : | } else { | ||
454 : | # Slurp in the entire file. | ||
455 : | my @lines = Tracer::GetFile("fig-user-env.sh"); | ||
456 : | # Loop through the variables. | ||
457 : | for my $elim (keys %elims) { | ||
458 : | # Remove any existing lines for the variable. | ||
459 : | @lines = grep { $_ !~ /(export $elim)|($elim=)/ } @lines; | ||
460 : | # Add the new lines. | ||
461 : | Trace("Updating $elim in fig-user-env.sh."); | ||
462 : | push @lines, "$elim=\"$elims{$elim}\""; | ||
463 : | push @lines, "export $elim"; | ||
464 : | } | ||
465 : | # Write the file back out. | ||
466 : | Open(\*FIGOUT, ">fig-user-env.sh~"); | ||
467 : | for my $line (@lines) { | ||
468 : | print FIGOUT "$line\n"; | ||
469 : | } | ||
470 : | close FIGOUT; | ||
471 : | rename "fig-user-env.sh~", "fig-user-env.sh"; | ||
472 : | } | ||
473 : | parrello | 1.2 | # Copy the WebApplication configuration subdirectory from the |
474 : | # current version to the next version. First, we get our current | ||
475 : | # configuration directory. | ||
476 : | my $currentConfig = "$FIG_Config::fig_disk/config"; | ||
477 : | # Now we create the web-application subdirectory in the target directory. | ||
478 : | mkdir "WebApplication"; | ||
479 : | # Copy across the files inside. | ||
480 : | my @lines = `cp -r $currentConfig/WebApplication/* $target_dir/config/WebApplication`; | ||
481 : | Trace("WebApplication configuration files copied:\n" . join("\n", @lines)) if T(2); | ||
482 : | parrello | 1.1 | # Finally, create a marker file to protect this installation from |
483 : | # automatic updates. | ||
484 : | my $marker_file = "$target_dir/config/DISABLE_P2P"; | ||
485 : | if ($options->{test}) { | ||
486 : | Trace("Marker file $marker_file would be created.") if T(2); | ||
487 : | } else { | ||
488 : | Trace("Creating marker file $marker_file.") if T(2); | ||
489 : | Open(\*FIGOUT, ">$marker_file"); | ||
490 : | print FIGOUT "\n"; | ||
491 : | close FIGOUT; | ||
492 : | } | ||
493 : | # We're done. | ||
494 : | Trace("Stage 3 complete.") if T(2); | ||
495 : | } | ||
496 : | # | ||
497 : | # STAGE 4: fix the file permissions. | ||
498 : | # | ||
499 : | if ($options->{stage} <= 4) { | ||
500 : | # Get the group name and ID. | ||
501 : | my $gname = $options->{group}; | ||
502 : | my $gid = getgrnam($gname); | ||
503 : | if ($options->{test}) { | ||
504 : | Trace("Permission fix would occur in $version_dir. Group $gname has ID $gid.") if T(2); | ||
505 : | } else { | ||
506 : | # Set the permissions. | ||
507 : | Tracer::SetPermissions($version_dir, $options->{group}, 02664, tmp => 02777); | ||
508 : | } | ||
509 : | parrello | 1.2 | Trace("Stage 4 complete.") if T(2); |
510 : | } | ||
511 : | # | ||
512 : | # STAGE 5: Copy the cover pages. | ||
513 : | # | ||
514 : | if ($options->{stage} <= 5) { | ||
515 : | Trace("Copying cover pages.") if T(2); | ||
516 : | my @syncData = `rsync --archive --recursive /disks/nmpdr/$old_version/html /disks/nmpdr/$version_dir/`; | ||
517 : | Trace("Copy results\n" . join("\n", @syncData)) if T(3); | ||
518 : | # Create the version number file for the wiki. | ||
519 : | my $text = join("\n", "<?php", | ||
520 : | "\$wgNmpdrVersion = $version;", | ||
521 : | "?>", | ||
522 : | ""); | ||
523 : | my $fh = Tracer::Open(undef, ">/disks/nmpdr/$version_dir/html/wiki/extensions/NmpdrVersion.php"); | ||
524 : | print "$fh", $text; | ||
525 : | close $fh; | ||
526 : | Trace("Version file created for wiki.") if T(2); | ||
527 : | parrello | 1.1 | Trace("Stage 5 complete.") if T(2); |
528 : | } | ||
529 : | # | ||
530 : | parrello | 1.2 | # STAGE 6: Copy the drug target files. |
531 : | parrello | 1.1 | # |
532 : | parrello | 1.2 | if ($options->{stage} <= 6) { |
533 : | Trace("Copying drug target files.") if T(2); | ||
534 : | my @syncData = ` rsync --archive --recursive /disks/nmpdr/$old_version/FIGdisk/FIG/var/DrugTargetData /disks/nmpdr/$version_dir/`; | ||
535 : | Trace("Copy results\n" . join("\n", @syncData)) if T(3); | ||
536 : | Trace("Stage 6 complete.") if T(2); | ||
537 : | parrello | 1.1 | } |
538 : | parrello | 1.2 | |
539 : | parrello | 1.1 | Trace("Processing complete.") if T(0); |
540 : | |||
541 : | # Forge a symbolic Link. | ||
542 : | sub do_symlink { | ||
543 : | my($from, $to) = @_; | ||
544 : | # Erase the old link if necessary. | ||
545 : | if (-e $to) { | ||
546 : | Trace("Erasing old link $to.") if T(3); | ||
547 : | unlink $to; | ||
548 : | } | ||
549 : | symlink($from, $to) || | ||
550 : | Confess("Symlink $from $to failed: $!"); | ||
551 : | } | ||
552 : | |||
553 : | # Untar a bunch of files. | ||
554 : | sub do_untar { | ||
555 : | my($file) = @_; | ||
556 : | my $args = "-x -f $file"; | ||
557 : | if ($file =~ /gz$/) { | ||
558 : | $args .= " -z"; | ||
559 : | } elsif ($file =~ /bz2/) { | ||
560 : | $args .= " -j"; | ||
561 : | } | ||
562 : | my $cmd = "tar $args"; | ||
563 : | my $rc = system($cmd); | ||
564 : | if ($rc != 0) { | ||
565 : | Confess("tar failed with rc=$rc: $cmd"); | ||
566 : | } | ||
567 : | } | ||
568 : | |||
569 : | 1; |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |