| 1 | #!/usr/local/bin/perl |
1 | #!/usr/local/bin/perl |
| 2 | |
2 | |
| 3 | ################################################################################ |
3 | ################################################################################ |
| 4 | # WeBWorK |
4 | # WeBWorK |
| 5 | # |
5 | # |
| 6 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
6 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
| 7 | # All rights reserved |
7 | # All rights reserved |
| 8 | # |
8 | # |
| 9 | # $Id$ |
9 | # $Id$ |
| 10 | ################################################################################ |
10 | ################################################################################ |
| 11 | |
11 | |
| 12 | #################### initialization |
12 | #################### initialization |
| 13 | |
13 | |
| … | |
… | |
| 57 | my $INTRO_TEXT = q{ |
57 | my $INTRO_TEXT = q{ |
| 58 | +----------------------+ |
58 | +----------------------+ |
| 59 | | System Webwork Setup | |
59 | | System Webwork Setup | |
| 60 | +----------------------+ |
60 | +----------------------+ |
| 61 | |
61 | |
| 62 | This script is used to setup the main WeBWorK system. It will create |
62 | This script is used to setup the main WeBWorK system. It will create |
| 63 | initialization files, set groups and permissions for files and directories, |
63 | initialization files, set groups and permissions for files and directories, |
| 64 | 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. |
| 65 | |
65 | |
| 66 | You will need the following information: |
66 | You will need the following information: |
| 67 | |
67 | |
| 68 | 1) The location of your WeBWorK system directory. |
68 | 1) The location of your WeBWorK system directory. |
| … | |
… | |
| 86 | |
86 | |
| 87 | }; |
87 | }; |
| 88 | |
88 | |
| 89 | my $MODE_TEXT = q{ |
89 | my $MODE_TEXT = q{ |
| 90 | |
90 | |
| 91 | You can set up a "working" or a "demo" WeBWorK system. A "demo" system |
91 | You can set up a "working" or a "demo" WeBWorK system. A "demo" system |
| 92 | should only be used as a sample system, never for a system that will be used |
92 | should only be used as a sample system, never for a system that will be used |
| 93 | with actual courses with real students. The main difference between a |
93 | with actual courses with real students. The main difference between a |
| 94 | "working" version and a "demo" version is that in a "working" version you |
94 | "working" version and a "demo" version is that in a "working" version you |
| 95 | will be promped to enter a group (e.g. wwadmin) where as in a "demo" |
95 | will be promped to enter a group (e.g. wwadmin) where as in a "demo" |
| 96 | version, the group will be set yo your own default group (e.g. fac). Anyone |
96 | version, the group will be set yo your own default group (e.g. fac). Anyone |
| 97 | in the group will have permission to modify all webwork files. You can set |
97 | in the group will have permission to modify all webwork files. You can set |
| 98 | up "working" and "demo" courses under either a "working" or a "demo" system, |
98 | up "working" and "demo" courses under either a "working" or a "demo" system, |
| 99 | but normally you would not set up a "working" course under a "demo" system. |
99 | but normally you would not set up a "working" course under a "demo" system. |
| 100 | |
100 | |
| 101 | }; |
101 | }; |
| 102 | |
102 | |
| 103 | my $MAIN_DIR_TEXT = q{ |
103 | my $MAIN_DIR_TEXT = q{ |
| … | |
… | |
| 137 | |
137 | |
| 138 | }; |
138 | }; |
| 139 | |
139 | |
| 140 | my $GROUP_TEXT = q{ |
140 | my $GROUP_TEXT = q{ |
| 141 | |
141 | |
| 142 | WeBWorK needs to know what the admin group is. This group should have been |
142 | WeBWorK needs to know what the admin group is. This group should have been |
| 143 | set up by your system administrator and must contain at least your user ID. |
143 | set up by your system administrator and must contain at least your user ID. |
| 144 | All files and directories created will have this as their group. |
144 | All files and directories created will have this as their group. |
| 145 | |
145 | |
| 146 | }; |
146 | }; |
| 147 | |
147 | |
| 148 | my $COURSE_PERMS_TEXT = q{ |
148 | my $COURSE_PERMS_TEXT = q{ |
| 149 | |
149 | |
| 150 | You have the option to set permissions for the courses directory. If this is |
150 | You have the option to set permissions for the courses directory. If this is |
| 151 | an inital setup, you should probably do so. If this is not an initial setup, |
151 | an inital setup, you should probably do so. If this is not an initial setup, |
| 152 | the courses directory is already set up, or the courses directory is shared |
152 | the courses directory is already set up, or the courses directory is shared |
| 153 | between WeBWorK installations, your probably shouldn't. |
153 | between WeBWorK installations, your probably shouldn't. |
| 154 | |
154 | |
| 155 | }; |
155 | }; |
| 156 | |
156 | |
| 157 | my $CHGRP_TEXT = q{ |
157 | my $CHGRP_TEXT = q{ |
| 158 | |
158 | |
| 159 | You have to option to set the group for all system files and directories. If |
159 | You have to option to set the group for all system files and directories. If |
| 160 | this is an initial setup, you should probably do this. If this is not an |
160 | this is an initial setup, you should probably do this. If this is not an |
| 161 | initial setup, or you have customized the way system files should be |
161 | initial setup, or you have customized the way system files should be |
| 162 | grouped, you probably shoudn't. |
162 | grouped, you probably shoudn't. |
| 163 | |
163 | |
| 164 | }; |
164 | }; |
| 165 | |
165 | |
| 166 | my $CHMOD_TEXT = q{ |
166 | my $CHMOD_TEXT = q{ |
| 167 | |
167 | |
| 168 | You have to option to set the permissions for all system files and |
168 | You have to option to set the permissions for all system files and |
| 169 | directories. If this is an initial setup, you should probably do this. If |
169 | directories. If this is an initial setup, you should probably do this. If |
| 170 | this is not an initial setup, or you have customized the permissions for the |
170 | this is not an initial setup, or you have customized the permissions for the |
| 171 | system files, you probably shoudn't. |
171 | system files, you probably shoudn't. |
| 172 | |
172 | |
| 173 | }; |
173 | }; |
| 174 | |
174 | |
| 175 | my $CONFIRM_TEXT = q{ |
175 | my $CONFIRM_TEXT = q{ |
| 176 | |
176 | |
| 177 | Now that I have the necessary information, I can begin modifying the WeBWorK |
177 | Now that I have the necessary information, I can begin modifying the WeBWorK |
| 178 | system files. |
178 | system files. |
| 179 | |
179 | |
| 180 | }; |
180 | }; |
| 181 | |
181 | |
| 182 | my $DONE_TEXT = q{ |
182 | my $DONE_TEXT = q{ |
| … | |
… | |
| 274 | #################### admin group |
274 | #################### admin group |
| 275 | |
275 | |
| 276 | unless(defined $groupName) { |
276 | unless(defined $groupName) { |
| 277 | my ($userName, $userGID) = (getpwuid $<)[0,3]; |
277 | my ($userName, $userGID) = (getpwuid $<)[0,3]; |
| 278 | my $userGroupName = (getgrgid $userGID)[0]; |
278 | my $userGroupName = (getgrgid $userGID)[0]; |
| 279 | |
279 | |
| 280 | if ($system_setup_mode eq 'demo') { |
280 | if ($system_setup_mode eq 'demo') { |
| 281 | # in demo mode, the group is set to the user's primary group |
281 | # in demo mode, the group is set to the user's primary group |
| 282 | $groupName = $userGroupName; |
282 | $groupName = $userGroupName; |
| 283 | } else { |
283 | } else { |
| 284 | # in working mode, we get to chose |
284 | # in working mode, we get to chose |
| … | |
… | |
| 379 | } |
379 | } |
| 380 | |
380 | |
| 381 | sub fixFile |
381 | sub fixFile |
| 382 | { |
382 | { |
| 383 | my ($file) = @_; |
383 | my ($file) = @_; |
| 384 | |
384 | |
| 385 | # read the file |
385 | # read the file |
| 386 | open FILE, $file || die "Couldn't open $file for reading."; |
386 | open FILE, $file || die "Couldn't open $file for reading."; |
| 387 | my @lines = <FILE>; |
387 | my @lines = <FILE>; |
| 388 | close FILE || die "Couldn't close $file after reading."; |
388 | close FILE || die "Couldn't close $file after reading."; |
| 389 | |
389 | |
| 390 | # fix perl path |
390 | # fix perl path |
| 391 | $lines[0] =~ m/^#!(\S*)/; |
391 | $lines[0] =~ m/^#!(\S*)/; |
| 392 | if($1 ne $perlPath) { |
392 | if($1 ne $perlPath) { |
| 393 | $lines[0] =~ s/^#!\S*/#!$perlPath/; |
393 | $lines[0] =~ s/^#!\S*/#!$perlPath/; |
| 394 | open FILE, ">$file" || die "Couldn't open $file for writing."; |
394 | open FILE, ">$file" || die "Couldn't open $file for writing."; |
| … | |
… | |
| 407 | print CONFIG_FILE<<END_OF_CONFIG_FILE; |
407 | print CONFIG_FILE<<END_OF_CONFIG_FILE; |
| 408 | package Global; |
408 | package Global; |
| 409 | |
409 | |
| 410 | ################################################################################ |
410 | ################################################################################ |
| 411 | # WeBWorK |
411 | # WeBWorK |
| 412 | # |
412 | # |
| 413 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
413 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
| 414 | # All rights reserved |
414 | # All rights reserved |
| 415 | ################################################################################ |
415 | ################################################################################ |
| 416 | |
416 | |
| 417 | # \$cgiDebugMode, if enabled, will call the debug wrapper scripts instead of the |
417 | # \$cgiDebugMode, if enabled, will call the debug wrapper scripts instead of the |
| … | |
… | |
| 439 | foreach my $dir ('cgi/', 'cgi/cgi-scripts/', 'scripts/', 'courseScripts/') { |
439 | foreach my $dir ('cgi/', 'cgi/cgi-scripts/', 'scripts/', 'courseScripts/') { |
| 440 | open INIT_FILE, ">$mainDir${dir}webworkInit.pm"; |
440 | open INIT_FILE, ">$mainDir${dir}webworkInit.pm"; |
| 441 | print INIT_FILE<<END_OF_INIT_FILE; |
441 | print INIT_FILE<<END_OF_INIT_FILE; |
| 442 | ################################################################################ |
442 | ################################################################################ |
| 443 | # WeBWorK |
443 | # WeBWorK |
| 444 | # |
444 | # |
| 445 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
445 | # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester |
| 446 | # All rights reserved |
446 | # All rights reserved |
| 447 | ################################################################################ |
447 | ################################################################################ |
| 448 | |
448 | |
| 449 | use lib '${mainDir}lib/'; |
449 | use lib '${mainDir}lib/'; |
| … | |
… | |
| 459 | |
459 | |
| 460 | if($chgrp_files_and_dirs) { |
460 | if($chgrp_files_and_dirs) { |
| 461 | print "Setting group on system files and directories...\n"; |
461 | print "Setting group on system files and directories...\n"; |
| 462 | system "chgrp -R $groupName $mainDir"; |
462 | system "chgrp -R $groupName $mainDir"; |
| 463 | system "chgrp -R $groupName $mainDir/../system_html"; |
463 | system "chgrp -R $groupName $mainDir/../system_html"; |
|
|
464 | system "chgrp -R $groupName $mainDir/../pg"; |
| 464 | print "Done setting group.\n\n"; |
465 | print "Done setting group.\n\n"; |
| 465 | } |
466 | } |
| 466 | |
467 | |
| 467 | #################### chmod system stuff |
468 | #################### chmod system stuff |
| 468 | # uses: $chmod_files_and_dirs |
469 | # uses: $chmod_files_and_dirs |
| … | |
… | |
| 471 | print "Setting permissions on system files and directories for $system_setup_mode mode...\n"; |
472 | print "Setting permissions on system files and directories for $system_setup_mode mode...\n"; |
| 472 | if ($system_setup_mode eq "demo") { |
473 | if ($system_setup_mode eq "demo") { |
| 473 | # get some general permissions for files and directories |
474 | # get some general permissions for files and directories |
| 474 | system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0755"; |
475 | system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0755"; |
| 475 | system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0644"; |
476 | system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0644"; |
|
|
477 | system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0644"; |
| 476 | # add executable privs to scripts |
478 | # add executable privs to scripts |
| 477 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0755"; |
479 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0755"; |
| 478 | } else { |
480 | } else { |
| 479 | # get some general permissions for files and directories |
481 | # get some general permissions for files and directories |
| 480 | system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0775"; |
482 | system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0775"; |
| 481 | system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0664"; |
483 | system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0664"; |
|
|
484 | system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0664"; |
| 482 | # add executable privs to scripts |
485 | # add executable privs to scripts |
| 483 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0775"; |
486 | system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0775"; |
| 484 | } |
487 | } |
| 485 | # make the log files group writable |
488 | # make the log files group writable |
| 486 | system "find $mainDir/logs -type f -print | xargs chmod 0664"; |
489 | system "find $mainDir/logs -type f -print | xargs chmod 0664"; |
| 487 | # make the error_log file world writable |
490 | # make the error_log file world writable |
| 488 | system "find $mainDir/logs/error_log -print | xargs chmod 0666"; |
491 | system "find $mainDir/logs/error_log -print | xargs chmod 0666"; |
| 489 | |
492 | |
| 490 | print "done setting permissions.\n\n"; |
493 | print "done setting permissions.\n\n"; |
| 491 | } |
494 | } |