… | |
… | |
15 | |
15 | |
16 | # define built-in defaults |
16 | # define built-in defaults |
17 | my $DEFAULT_PERL_PATH = '/usr/bin/perl'; |
17 | my $DEFAULT_PERL_PATH = '/usr/bin/perl'; |
18 | my $DEFAULT_CGI_URL = '/cgi-bin/webwork/system/'; |
18 | my $DEFAULT_CGI_URL = '/cgi-bin/webwork/system/'; |
19 | my $DEFAULT_HTML_URL = '/webwork_system_html'; |
19 | my $DEFAULT_HTML_URL = '/webwork_system_html'; |
|
|
20 | my $DEFAULT_SERVER_GROUP = 'webwork'; |
20 | |
21 | |
21 | # define code strings |
22 | # define code strings |
22 | my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL'; |
23 | my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL'; |
23 | my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL'; |
24 | my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL'; |
24 | my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine'; |
25 | my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine'; |
… | |
… | |
29 | $mainDir = undef; |
30 | $mainDir = undef; |
30 | $perlPath = undef; |
31 | $perlPath = undef; |
31 | $cgiURL = undef; |
32 | $cgiURL = undef; |
32 | $htmlURL = undef; |
33 | $htmlURL = undef; |
33 | $groupName = undef; |
34 | $groupName = undef; |
|
|
35 | $serverGroupName = undef; |
34 | $update_stuff_in_courses = undef; |
36 | $update_stuff_in_courses = undef; |
35 | $chgrp_files_and_dirs = undef; |
37 | $chgrp_files_and_dirs = undef; |
36 | $chmod_files_and_dirs = undef; |
38 | $chmod_files_and_dirs = undef; |
37 | $local_preprocessor = undef; |
39 | $local_preprocessor = undef; |
38 | $local_postprocessor = undef; |
40 | $local_postprocessor = undef; |
… | |
… | |
141 | my $GROUP_TEXT = q{ |
143 | my $GROUP_TEXT = q{ |
142 | |
144 | |
143 | WeBWorK needs to know what the admin group is. This group should have been |
145 | WeBWorK needs to know what the admin group is. This group should have been |
144 | set up by your system administrator and must contain at least your user ID. |
146 | set up by your system administrator and must contain at least your user ID. |
145 | All files and directories created will have this as their group. |
147 | All files and directories created will have this as their group. |
|
|
148 | |
|
|
149 | }; |
|
|
150 | |
|
|
151 | my $SERVER_GROUP_TEXT = q{ |
|
|
152 | |
|
|
153 | In order to give the webserver access to the logs directory, WeBWorK |
|
|
154 | must know the group under which the web server will run. If you are |
|
|
155 | running this script as a user other than root, you will need to be a |
|
|
156 | member of the server's group in order to set the group on the logs |
|
|
157 | directory. If you are not running as root and you are not a member of |
|
|
158 | the server's group, you can skip this step and change the group manually |
|
|
159 | later. To skip this step, type SKIP below. |
146 | |
160 | |
147 | }; |
161 | }; |
148 | |
162 | |
149 | my $COURSE_PERMS_TEXT = q{ |
163 | my $COURSE_PERMS_TEXT = q{ |
150 | |
164 | |
… | |
… | |
300 | } |
314 | } |
301 | } |
315 | } |
302 | } |
316 | } |
303 | } |
317 | } |
304 | print "Admin group is: $groupName\n"; |
318 | print "Admin group is: $groupName\n"; |
|
|
319 | |
|
|
320 | #################### server group |
|
|
321 | |
|
|
322 | unless(defined $serverGroupName) { |
|
|
323 | page($SERVER_GROUP_TEXT); |
|
|
324 | my ($userName, $userGID) = (getpwuid $<)[0,3]; |
|
|
325 | my $userGroupName = (getgrgid $userGID)[0]; |
|
|
326 | $serverGroupName = $DEFAULT_SERVER_GROUP; |
|
|
327 | my $validGroup = 0; |
|
|
328 | while(1) { |
|
|
329 | $serverGroupName = questionString("What is the webserver group name?", $serverGroupName); |
|
|
330 | $serverGroupName eq "SKIP" and last; |
|
|
331 | my @members = split / /, (getgrnam $serverGroupName)[3]; |
|
|
332 | if($serverGroupName eq $userGroupName) { |
|
|
333 | print "$serverGroupName is ${userName}'s primary group. Weird.\n"; |
|
|
334 | } elsif(grep /$userName/, @members) { |
|
|
335 | print "$userName is a member of $serverGroupName. Good.\n"; |
|
|
336 | last; |
|
|
337 | } elsif($< == 0) { # we're root! |
|
|
338 | print "$userName isn't a member of $serverGroupName, but you're root, so who cares?\n"; |
|
|
339 | last; |
|
|
340 | } else { |
|
|
341 | print "That group is not valid. Please make sure the group exists and you are a member.\n"; |
|
|
342 | } |
|
|
343 | } |
|
|
344 | } |
|
|
345 | print "Server group is: $serverGroupName\n"; |
305 | |
346 | |
306 | #################### chmod courses directory |
347 | #################### chmod courses directory |
307 | |
348 | |
308 | unless(defined $update_stuff_in_courses) { |
349 | unless(defined $update_stuff_in_courses) { |
309 | page($COURSE_PERMS_TEXT); |
350 | page($COURSE_PERMS_TEXT); |
… | |
… | |
465 | close INIT_FILE; |
506 | close INIT_FILE; |
466 | } |
507 | } |
467 | print "Done writing webworkInit.pm files.\n\n"; |
508 | print "Done writing webworkInit.pm files.\n\n"; |
468 | |
509 | |
469 | #################### chgrp system stuff |
510 | #################### chgrp system stuff |
470 | # uses: $chgrp_files_and_dirs, $groupName |
511 | # uses: $chgrp_files_and_dirs, $groupName, $serverGroupName |
471 | |
512 | |
472 | if($chgrp_files_and_dirs) { |
513 | if($chgrp_files_and_dirs) { |
473 | print "Setting group on system files and directories...\n"; |
514 | print "Setting group on system files and directories...\n"; |
474 | # R=recursive, P=don't follow symlinks |
515 | # R=recursive, P=don't follow symlinks |
475 | system "chgrp -PR $groupName ."; |
516 | system "chgrp -PR $groupName ."; |
|
|
517 | system "chgrp -PR $serverGroupName logs/" unless $serverGroupName eq "SKIP"; |
476 | print "Done setting group.\n\n"; |
518 | print "Done setting group.\n\n"; |
477 | } |
519 | } |
478 | |
520 | |
479 | #################### chmod system stuff |
521 | #################### chmod system stuff |
480 | # uses: $chmod_files_and_dirs |
522 | # uses: $chmod_files_and_dirs |