| … | |
… | |
| 12 | #################### initialization |
12 | #################### initialization |
| 13 | |
13 | |
| 14 | require 5.000; |
14 | require 5.000; |
| 15 | use Cwd; |
15 | use Cwd; |
| 16 | use File::Copy; |
16 | use File::Copy; |
| 17 | use File::Find; |
|
|
| 18 | use FindBin; |
|
|
| 19 | |
|
|
| 20 | # get the base (webwork/) directory |
|
|
| 21 | my $BASE_DIR = $FindBin::Bin; |
|
|
| 22 | |
17 | |
| 23 | # define built-in defaults |
18 | # define built-in defaults |
| 24 | my $DEFAULT_PERL_PATH = '/usr/bin/perl'; |
19 | my $DEFAULT_PERL_PATH = '/usr/bin/perl'; |
| 25 | my $DEFAULT_CGI_URL = '/cgi-bin/webwork/system/'; |
20 | my $DEFAULT_CGI_URL = '/cgi-bin/webwork/system/'; |
| 26 | my $DEFAULT_HTML_URL = '/webwork_system_html/'; |
21 | my $DEFAULT_HTML_URL = '/webwork_system_html/'; |
| … | |
… | |
| 68 | initialization files, set groups and permissions for files and directories, |
63 | initialization files, set groups and permissions for files and directories, |
| 69 | and modify files. A "demo" or "working" version of the system can be setup. |
64 | and modify files. A "demo" or "working" version of the system can be setup. |
| 70 | |
65 | |
| 71 | You will need the following information: |
66 | You will need the following information: |
| 72 | |
67 | |
| 73 | 1) The path to perl on your system. Usually this is something like |
68 | 1) The location of your WeBWorK system directory. |
| 74 | /usr/bin/perl or /usr/local/bin/perl |
69 | Example: /usr/local/webwork/system/ |
|
|
70 | Example: /var/www/webwork/system/ |
| 75 | |
71 | |
| 76 | 2) The group (e.g. wwadmin) containing the user names of anyone who has the |
72 | 2) The path to perl on your system. |
| 77 | authority to modify the webwork system files. Who ever runs this script must |
73 | Example: /usr/bin/perl |
| 78 | be a member of this group. This should be set up by your system |
74 | Example: /usr/local/bin/perl |
| 79 | administrator before running this script. (Note: This is not required for a |
|
|
| 80 | demo version.) |
|
|
| 81 | |
75 | |
| 82 | 3) The cgi WeBWorK URL. Usually this is something like |
76 | 3) The group containing the users who have the authority to modify the |
| 83 | http://webwork.math.rochester.edu/cgi-bin/webwork/system. In the above |
77 | webwork system files. Who ever runs this script must be a member of |
| 84 | cases, you can just enter /cgi-bin/webwork/system which is prefered but |
78 | this group. (Note: This is not required for the demo mode.) |
| 85 | if you do, don't forget the initial / . |
79 | Example: wwadmin |
| 86 | |
80 | |
| 87 | 4) The html WeBWorK URL. Usually this is something like |
81 | 4) The URL to the WeBWorK CGI scripts. |
| 88 | http://webwork.math.rochester.edu/webwork_system_html. Again in this |
82 | Example: /cgi-bin/webwork/system/ (preferred) |
| 89 | case /webwork_system_html is prefered. |
83 | |
|
|
84 | 5) The URL to the static system_html files. |
|
|
85 | Example: /webwork_system_html/ |
| 90 | |
86 | |
| 91 | }; |
87 | }; |
| 92 | |
88 | |
| 93 | my $MODE_TEXT = q{ |
89 | my $MODE_TEXT = q{ |
| 94 | |
90 | |
| … | |
… | |
| 123 | |
119 | |
| 124 | my $CGI_URL_TEXT = q{ |
120 | my $CGI_URL_TEXT = q{ |
| 125 | |
121 | |
| 126 | In order for generated HTML to be able to invoke CGI scripts, WeBWorK |
122 | In order for generated HTML to be able to invoke CGI scripts, WeBWorK |
| 127 | needs to know the URL which points to the main WeBWorK system cgi |
123 | needs to know the URL which points to the main WeBWorK system cgi |
| 128 | subdirectory. For example, |
|
|
| 129 | http://webwork.math.rochester.edu.edu/cgi-bin/webwork/system might be a |
|
|
| 130 | valid CGI URL. If both static HTML and CGIs reside on the same host |
124 | subdirectory. If both static HTML and CGIs reside on the same host |
| 131 | (which is true in most cases), you can omit the |
125 | (which is true in most cases), you can omit the http://hostname section |
| 132 | http://webwork.math.rochester.edu section of the URL. Make sure to |
126 | of the URL, but make sure the leading slash is present. |
| 133 | include a leading slash in this case. |
|
|
| 134 | |
127 | |
| 135 | }; |
128 | }; |
| 136 | |
129 | |
| 137 | my $HTML_URL_TEXT = q{ |
130 | my $HTML_URL_TEXT = q{ |
| 138 | |
131 | |
| 139 | WeBWorK also needs to know the URL of the main HTML directory, the |
132 | WeBWorK also needs to know the URL of the main HTML directory, the |
| 140 | system html subdirectory. For example, |
133 | system_html subdirectory. If both static HTML and CGIs reside on the |
| 141 | http://webwork.math.rochester.edu/webwork_system_html or |
134 | same host (which is true in most cases), you can omit the |
| 142 | /webwork_system_html. |
135 | http://hostname section of the URL, but make sure the leading slash is |
|
|
136 | present. |
| 143 | |
137 | |
| 144 | }; |
138 | }; |
| 145 | |
139 | |
| 146 | my $GROUP_TEXT = q{ |
140 | my $GROUP_TEXT = q{ |
| 147 | |
141 | |
| … | |
… | |
| 228 | |
222 | |
| 229 | #################### main directory |
223 | #################### main directory |
| 230 | |
224 | |
| 231 | unless(defined $mainDir) { |
225 | unless(defined $mainDir) { |
| 232 | page($MAIN_DIR_TEXT); |
226 | page($MAIN_DIR_TEXT); |
| 233 | $mainDir = questionString("Where is the WeBWorK system directory?", "$BASE_DIR/system/"); |
227 | $mainDir = questionString("Where is the WeBWorK system directory?", cwd()); |
| 234 | $mainDir .= '/' unless $mainDir =~ m|/$|; # ensure trailing slash |
228 | $mainDir .= '/' unless $mainDir =~ m|/$|; # ensure trailing slash |
| 235 | } |
229 | } |
| 236 | print "We'll use $mainDir as WeBWorK's system directory.\n"; |
230 | print "We'll use $mainDir as WeBWorK's system directory.\n"; |
| 237 | |
231 | |
| 238 | #################### perl path |
232 | #################### perl path |
| … | |
… | |
| 415 | # All rights reserved |
409 | # All rights reserved |
| 416 | ################################################################################ |
410 | ################################################################################ |
| 417 | |
411 | |
| 418 | \$mainDirectory = "$mainDir"; |
412 | \$mainDirectory = "$mainDir"; |
| 419 | \$htmlWebworkURL = "$htmlURL"; |
413 | \$htmlWebworkURL = "$htmlURL"; |
| 420 | \$cgiWebworkURL = "${cgiURL}"; |
414 | \$cgiWebworkURL = "$cgiURL"; |
| 421 | \$cgiWebworkURL .= "cgi-scripts/" unless \$cgiDebugMode; |
415 | \$cgiWebworkURL .= "cgi-scripts/" unless \$cgiDebugMode; |
| 422 | |
416 | |
| 423 | 1; |
417 | 1; |
| 424 | END_OF_CONFIG_FILE |
418 | END_OF_CONFIG_FILE |
| 425 | close CONFIG_FILE; |
419 | close CONFIG_FILE; |
| … | |
… | |
| 451 | # uses: $chgrp_files_and_dirs, $groupName |
445 | # uses: $chgrp_files_and_dirs, $groupName |
| 452 | |
446 | |
| 453 | if($chgrp_files_and_dirs) { |
447 | if($chgrp_files_and_dirs) { |
| 454 | print "Setting group on system files and directories...\n"; |
448 | print "Setting group on system files and directories...\n"; |
| 455 | system "chgrp -R $groupName $mainDir"; |
449 | system "chgrp -R $groupName $mainDir"; |
| 456 | system "chgrp -R $groupName $BASE_DIR/system_html"; |
450 | system "chgrp -R $groupName $mainDir/../system_html"; |
| 457 | print "Done setting group.\n\n"; |
451 | print "Done setting group.\n\n"; |
| 458 | } |
452 | } |
| 459 | |
453 | |
| 460 | #################### chmod system stuff |
454 | #################### chmod system stuff |
| 461 | # uses: $chmod_files_and_dirs |
455 | # uses: $chmod_files_and_dirs |
| 462 | |
456 | |
| 463 | if($chmod_files_and_dirs) { |
457 | if($chmod_files_and_dirs) { |
| 464 | print "Setting permissions on system files and directories for $system_setup_mode mode...\n"; |
458 | print "Setting permissions on system files and directories for $system_setup_mode mode...\n"; |
| 465 | if ($system_setup_mode eq "demo") { |
459 | if ($system_setup_mode eq "demo") { |
| 466 | # get some general permissions for files and directories |
460 | # get some general permissions for files and directories |
| 467 | system "find $mainDir $BASE_DIR/system_html -type d -print0 | xargs -0 chmod 0755"; |
461 | system "find $mainDir $mainDir/../system_html -type d -print0 | xargs -0 chmod 0755"; |
| 468 | system "find $mainDir $BASE_DIR/system_html -type f -print0 | xargs -0 chmod 0644"; |
462 | system "find $mainDir $mainDir/../system_html -type f -print0 | xargs -0 chmod 0644"; |
| 469 | # add executable privs to scripts |
463 | # add executable privs to scripts |
| 470 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print0 | xargs -0 chmod 0755"; |
464 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print0 | xargs -0 chmod 0755"; |
| 471 | } else { |
465 | } else { |
| 472 | # get some general permissions for files and directories |
466 | # get some general permissions for files and directories |
| 473 | system "find $mainDir $BASE_DIR/system_html -type d -print0 | xargs -0 chmod 0775"; |
467 | system "find $mainDir $mainDir/../system_html -type d -print0 | xargs -0 chmod 0775"; |
| 474 | system "find $mainDir $BASE_DIR/system_html -type f -print0 | xargs -0 chmod 0664"; |
468 | system "find $mainDir $mainDir/../system_html -type f -print0 | xargs -0 chmod 0664"; |
| 475 | # add executable privs to scripts |
469 | # add executable privs to scripts |
| 476 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print0 | xargs -0 chmod 0775"; |
470 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print0 | xargs -0 chmod 0775"; |
| 477 | } |
471 | } |
| 478 | print "done setting permissions.\n\n"; |
472 | print "done setting permissions.\n\n"; |
| 479 | } |
473 | } |
| … | |
… | |
| 481 | #################### update couses stuff |
475 | #################### update couses stuff |
| 482 | # uses: $update_stuff_in_courses |
476 | # uses: $update_stuff_in_courses |
| 483 | |
477 | |
| 484 | if($update_stuff_in_courses) { |
478 | if($update_stuff_in_courses) { |
| 485 | print "Setting permissions for ../courses directory.\n\n"; |
479 | print "Setting permissions for ../courses directory.\n\n"; |
| 486 | chmod(0755, "$BASE_DIR/courses") or warn "Warning: I can't set permissions for ../courses directory. It's possible that the directory doesn't exist or you don't have permission to change it.\n"; |
480 | chmod(0755, "$mainDir/../courses") or warn "Warning: I can't set permissions for ../courses directory. It's possible that the directory doesn't exist or you don't have permission to change it.\n"; |
| 487 | } |
481 | } |
| 488 | |
482 | |
| 489 | #################### run local postprocessor |
483 | #################### run local postprocessor |
| 490 | |
484 | |
| 491 | if(defined $local_postprocessor) { |
485 | if(defined $local_postprocessor) { |