| … | |
… | |
| 25 | my $DEFAULT_HTML_URL = '/webwork_system_html'; |
25 | my $DEFAULT_HTML_URL = '/webwork_system_html'; |
| 26 | |
26 | |
| 27 | # define code strings |
27 | # define code strings |
| 28 | my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL'; |
28 | my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL'; |
| 29 | my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL'; |
29 | my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL'; |
|
|
30 | my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine'; |
| 30 | my $MAIN_DIR_TAG = 'mainWeBWorKDirectory'; |
31 | my $MAIN_DIR_TAG = 'mainWeBWorKDirectory'; |
| 31 | |
32 | |
| 32 | # scope and undefine setup variables |
33 | # scope and undefine setup variables |
| 33 | our $no_prompts = undef; |
34 | our $no_prompts = undef; |
| 34 | our $system_setup_mode = undef; |
35 | our $system_setup_mode = undef; |
| … | |
… | |
| 369 | } |
370 | } |
| 370 | |
371 | |
| 371 | #################### update Global.pm |
372 | #################### update Global.pm |
| 372 | #needs: $mainDir, $cgiURL, $htmlURL |
373 | #needs: $mainDir, $cgiURL, $htmlURL |
| 373 | |
374 | |
| 374 | chdir "lib"; |
375 | #chdir "lib"; |
| 375 | |
376 | # |
| 376 | -e 'Global.pm' or die "Global.pm doesn't exist! There's no point in continuing.\n"; |
377 | #-e 'Global.pm' or die "Global.pm doesn't exist! There's no point in continuing.\n"; |
| 377 | if(-e 'Global.pm.bak1') { |
378 | #if(-e 'Global.pm.bak1') { |
| 378 | print "Copying Global.pm.bak1 -> Global.pm.bak2\n"; |
379 | # print "Copying Global.pm.bak1 -> Global.pm.bak2\n"; |
| 379 | copy('Global.pm.bak1', 'Global.pm.bak2'); |
380 | # copy('Global.pm.bak1', 'Global.pm.bak2'); |
| 380 | } |
381 | #} |
| 381 | print "Copying Global.pm -> Global.pm.bak1\n"; |
382 | #print "Copying Global.pm -> Global.pm.bak1\n"; |
| 382 | copy('Global.pm', 'Global.pm.bak1'); |
383 | #copy('Global.pm', 'Global.pm.bak1'); |
| 383 | |
384 | # |
| 384 | open OLD_GLOBAL, "Global.pm.bak1"; |
385 | #open OLD_GLOBAL, "Global.pm.bak1"; |
| 385 | open NEW_GLOBAL, ">Global.pm"; |
386 | #open NEW_GLOBAL, ">Global.pm"; |
| 386 | |
387 | # |
| 387 | while (<OLD_GLOBAL>) { |
388 | #while (<OLD_GLOBAL>) { |
| 388 | if (/^\$mainDirectory/) { |
389 | # if (/^\$mainDirectory/) { |
| 389 | print NEW_GLOBAL "\$mainDirectory = '$mainDir';\n"; |
390 | # print NEW_GLOBAL "\$mainDirectory = '$mainDir';\n"; |
| 390 | print "\$mainDirectory = '$mainDir';\n"; |
391 | # print "\$mainDirectory = '$mainDir';\n"; |
| 391 | } elsif (/\#$CGI_DEBUG_TAG$/) { |
392 | # } elsif (/\#$CGI_DEBUG_TAG$/) { |
| 392 | print NEW_GLOBAL "\#\$cgiWebworkURL = '$cgiURL'; \#$CGI_DEBUG_TAG\n"; |
393 | # print NEW_GLOBAL "\#\$cgiWebworkURL = '$cgiURL'; \#$CGI_DEBUG_TAG\n"; |
| 393 | print "\#\$cgiWebworkURL = '$cgiURL'; \#$CGI_DEBUG_TAG\n"; |
394 | # print "\#\$cgiWebworkURL = '$cgiURL'; \#$CGI_DEBUG_TAG\n"; |
| 394 | } elsif (/\#$CGI_NODEBUG_TAG$/) { |
395 | # } elsif (/\#$CGI_NODEBUG_TAG$/) { |
| 395 | print NEW_GLOBAL "\$cgiWebworkURL = '${cgiURL}cgi-scripts/'; \#$CGI_NODEBUG_TAG\n"; |
396 | # print NEW_GLOBAL "\$cgiWebworkURL = '${cgiURL}cgi-scripts/'; \#$CGI_NODEBUG_TAG\n"; |
| 396 | print "\$cgiWebworkURL = '${cgiURL}cgi-scripts/'; \#$CGI_NODEBUG_TAG\n"; |
397 | # print "\$cgiWebworkURL = '${cgiURL}cgi-scripts/'; \#$CGI_NODEBUG_TAG\n"; |
| 397 | } elsif (/^\$htmlWebworkURL/) { |
398 | # } elsif (/^\$htmlWebworkURL/) { |
| 398 | print NEW_GLOBAL "\$htmlWebworkURL = '$htmlURL';\n"; |
399 | # print NEW_GLOBAL "\$htmlWebworkURL = '$htmlURL';\n"; |
| 399 | print "\$htmlWebworkURL = '$htmlURL';\n"; |
400 | # print "\$htmlWebworkURL = '$htmlURL';\n"; |
| 400 | } else { |
401 | # } else { |
| 401 | print NEW_GLOBAL $_; |
402 | # print NEW_GLOBAL $_; |
| 402 | } |
403 | # } |
| 403 | } |
404 | #} |
| 404 | |
405 | # |
| 405 | close NEW_GLOGAL; |
406 | #close NEW_GLOGAL; |
| 406 | close OLD_GLOBAL; |
407 | #close OLD_GLOBAL; |
| 407 | |
408 | # |
| 408 | chmod(0644, "Global.pm"); |
409 | #chmod(0644, "Global.pm"); |
| 409 | chdir ".."; |
410 | #chdir ".."; |
| 410 | print "Done updating Global.pm\n\n"; |
411 | #print "Done updating Global.pm\n\n"; |
| 411 | |
412 | |
| 412 | #################### update couses stuff |
413 | #################### update couses stuff |
| 413 | # uses: $update_stuff_in_courses |
414 | # uses: $update_stuff_in_courses |
| 414 | |
415 | |
| 415 | if($update_stuff_in_courses) { |
416 | if($update_stuff_in_courses) { |
| … | |
… | |
| 421 | # uses: $mainDir, $perlPath |
422 | # uses: $mainDir, $perlPath |
| 422 | # i must fix this some day |
423 | # i must fix this some day |
| 423 | |
424 | |
| 424 | print "Fixing #! and \"use\" lines...\n"; |
425 | print "Fixing #! and \"use\" lines...\n"; |
| 425 | |
426 | |
| 426 | my $USE_LINE = "use lib '${mainDir}lib/'; \# $MAIN_DIR_TAG\n"; |
427 | my $USE_LINE = "use lib '.'; use webworkInit; \# $LIB_INIT_LINE_TAG\n"; |
| 427 | |
428 | |
| 428 | # fix up the *.pl files |
429 | # fix up the *.pl files |
| 429 | foreach my $dir ('cgi/cgi-scripts', 'scripts', 'courseScripts') { |
430 | foreach my $dir ('cgi/cgi-scripts', 'scripts', 'courseScripts') { |
| 430 | foreach my $file (<${dir}/*.pl>) { |
431 | foreach my $file (<${dir}/*.pl>) { |
| 431 | fixFile($file, $USE_LINE); |
432 | fixFile($file, $USE_LINE); |
| … | |
… | |
| 452 | # fix perl path |
453 | # fix perl path |
| 453 | my $num = 0; |
454 | my $num = 0; |
| 454 | $num = $lines[0] =~ s/^#!.*/#!$perlPath/g; # fix #!... line |
455 | $num = $lines[0] =~ s/^#!.*/#!$perlPath/g; # fix #!... line |
| 455 | warn "couldn't fix #! line in $file\n" unless $num; |
456 | warn "couldn't fix #! line in $file\n" unless $num; |
| 456 | |
457 | |
| 457 | # fix use lines |
458 | # # fix use lines |
| 458 | if($use_line) { |
459 | # if($use_line) { |
| 459 | $num = 0; |
460 | # $num = 0; |
| 460 | foreach (@lines) { |
461 | # foreach (@lines) { |
| 461 | if (/^.*\#\s*\Q$MAIN_DIR_TAG\E.*$/) { |
462 | # if (/^.*\#\s*\Q$MAIN_DIR_TAG\E.*$/) { |
| 462 | $num++; |
463 | # $num++; |
| 463 | $_ = $use_line; |
464 | # $_ = $use_line; |
| 464 | } |
465 | # } |
| 465 | } |
466 | # } |
| 466 | warn "fixed $num 'use lib' lines in $file\n" if $num > 1; |
467 | # warn "fixed $num 'use lib' lines in $file\n" if $num > 1; |
| 467 | } |
468 | # } |
| 468 | |
469 | |
| 469 | # write the file |
470 | # write the file |
| 470 | open FILE, ">$file" || die "CAN'T WRITE $file!\n Fix the problem and run the setup script again"; |
471 | open FILE, ">$file" || die "CAN'T WRITE $file!\n Fix the problem and run the setup script again"; |
| 471 | print FILE @lines; |
472 | print FILE @lines; |
| 472 | close FILE || die "CAN'T CLOSE (writing) $file!\n Fix the problem and run the setup script again"; |
473 | close FILE || die "CAN'T CLOSE (writing) $file!\n Fix the problem and run the setup script again"; |
| 473 | } |
474 | } |
| 474 | |
475 | |
| 475 | print "done fixing #! and \"use\" lines.\n\n"; |
476 | print "done fixing #! and \"use\" lines.\n\n"; |
|
|
477 | |
|
|
478 | #################### create webworkInit.pm files |
|
|
479 | # uses: $mainDir |
|
|
480 | |
|
|
481 | foreach my $dir ('cgi/cgi-scripts/', 'scripts/') { |
|
|
482 | open INIT_FILE, ">$mainDir${dir}webworkInit.pm"; |
|
|
483 | print INIT_FILE "use lib '${mainDir}lib/';\n1;\n"; |
|
|
484 | close INIT_FILE; |
|
|
485 | } |
| 476 | |
486 | |
| 477 | #################### chgrp system stuff |
487 | #################### chgrp system stuff |
| 478 | # uses: $chgrp_files_and_dirs, $groupName |
488 | # uses: $chgrp_files_and_dirs, $groupName |
| 479 | |
489 | |
| 480 | if($chgrp_files_and_dirs) { |
490 | if($chgrp_files_and_dirs) { |