[system] / trunk / webwork / system / system_webwork_setup.pl Repository:
ViewVC logotype

Annotation of /trunk/webwork/system/system_webwork_setup.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2552 - (view) (download) (as text)

1 : sh002i 1532 #!/usr/bin/env perl
2 : sh002i 168
3 :     ################################################################################
4 :     # WeBWorK
5 : apizer 1082 #
6 : apizer 2552 # Copyright (c) 1995-2004 WeBWorK Team, University of Rochester
7 : sh002i 168 # All rights reserved
8 : apizer 1082 #
9 : sh002i 168 # $Id$
10 :     ################################################################################
11 :    
12 :     #################### initialization
13 :    
14 :     require 5.000;
15 :     use Cwd;
16 :     use File::Copy;
17 :    
18 :     # define built-in defaults
19 : sh002i 1532 my $DEFAULT_PERL_PATH = '/usr/bin/env perl';
20 : sh002i 168 my $DEFAULT_CGI_URL = '/cgi-bin/webwork/system/';
21 :     my $DEFAULT_HTML_URL = '/webwork_system_html/';
22 :     my $DEFAULT_ADMIN_GROUP = 'wwadmin';
23 :    
24 :     # define code strings
25 :     my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL';
26 :     my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL';
27 :     my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine';
28 :    
29 :     # scope and undefine setup variables
30 :     $no_prompts = undef;
31 :     $system_setup_mode = undef;
32 :     $mainDir = undef;
33 :     $perlPath = undef;
34 :     $cgiURL = undef;
35 :     $htmlURL = undef;
36 : sh002i 1521 $htmlDir = undef;
37 : sh002i 168 $groupName = undef;
38 :     $update_stuff_in_courses = undef;
39 :     $chgrp_files_and_dirs = undef;
40 :     $chmod_files_and_dirs = undef;
41 :     $local_preprocessor = undef;
42 :     $local_postprocessor = undef;
43 :    
44 :     # read defaults in from defaults file
45 :     my $DEFAULTS_FILE;
46 :     if($ARGV[0] and $ARGV[0] eq '-d') {
47 :     if($ARGV[1]) { $DEFAULTS_FILE = $ARGV[1]; }
48 :     else { $DEFAULTS_FILE = ((getpwuid $<)[7]) . '/system_webwork_setup.defaults'; }
49 :     if(-e $DEFAULTS_FILE) {
50 :     print "Reading defaults file...";
51 :     require $DEFAULTS_FILE;
52 :     print " done.\n";
53 :     }
54 :     }
55 :    
56 :     #################### text strings
57 :    
58 :     my $INTRO_TEXT = q{
59 :     +----------------------+
60 :     | System Webwork Setup |
61 :     +----------------------+
62 :    
63 : apizer 1082 This script is used to setup the main WeBWorK system. It will create
64 :     initialization files, set groups and permissions for files and directories,
65 : sh002i 168 and modify files. A "demo" or "working" version of the system can be setup.
66 :    
67 :     You will need the following information:
68 :    
69 : sh002i 174 1) The location of your WeBWorK system directory.
70 :     Example: /usr/local/webwork/system/
71 :     Example: /var/www/webwork/system/
72 : sh002i 168
73 : sh002i 174 2) The path to perl on your system.
74 :     Example: /usr/bin/perl
75 :     Example: /usr/local/bin/perl
76 : sh002i 168
77 : sh002i 174 3) The group containing the users who have the authority to modify the
78 :     webwork system files. Who ever runs this script must be a member of
79 :     this group. (Note: This is not required for the demo mode.)
80 :     Example: wwadmin
81 : sh002i 168
82 : sh002i 174 4) The URL to the WeBWorK CGI scripts.
83 :     Example: /cgi-bin/webwork/system/ (preferred)
84 : sh002i 168
85 : sh002i 174 5) The URL to the static system_html files.
86 :     Example: /webwork_system_html/
87 :    
88 : sh002i 168 };
89 :    
90 :     my $MODE_TEXT = q{
91 :    
92 : apizer 1082 You can set up a "working" or a "demo" WeBWorK system. A "demo" system
93 :     should only be used as a sample system, never for a system that will be used
94 :     with actual courses with real students. The main difference between a
95 :     "working" version and a "demo" version is that in a "working" version you
96 :     will be promped to enter a group (e.g. wwadmin) where as in a "demo"
97 :     version, the group will be set yo your own default group (e.g. fac). Anyone
98 :     in the group will have permission to modify all webwork files. You can set
99 :     up "working" and "demo" courses under either a "working" or a "demo" system,
100 : sh002i 168 but normally you would not set up a "working" course under a "demo" system.
101 :    
102 :     };
103 :    
104 :     my $MAIN_DIR_TEXT = q{
105 :    
106 :     The directory containing the WeBWorK system files (as well as this
107 :     script) is known as the system directory. In order to modify system
108 :     files, I need to know the location of the system directory for this
109 :     installation.
110 :    
111 :     };
112 :    
113 :     my $PERL_TEXT = q{
114 :    
115 :     WeBWorK needs to know the path of your perl binary, so that this
116 :     information can be used in the headers of cgi scripts. Please make sure
117 :     that the version of perl you specify is 5.004 or later.
118 :    
119 : sh002i 1532 If you have commit access to the WeBWorK system repository, you MUST
120 :     leave this as "/usr/bin/env perl".
121 :    
122 : sh002i 168 };
123 :    
124 :     my $CGI_URL_TEXT = q{
125 :    
126 :     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
128 : sh002i 174 subdirectory. If both static HTML and CGIs reside on the same host
129 :     (which is true in most cases), you can omit the http://hostname section
130 :     of the URL, but make sure the leading slash is present.
131 : sh002i 168
132 :     };
133 :    
134 : sh002i 1521 my $HTML_DIR_TEXT = q{
135 :    
136 :     The directory containing the WeBWorK system HTML files is known as the system
137 :     HTML directory. In order to dynamically generate system-wide public resources, I
138 :     need to know the location of the system HTML directory for this installation.
139 :    
140 :     };
141 :    
142 : sh002i 168 my $HTML_URL_TEXT = q{
143 :    
144 :     WeBWorK also needs to know the URL of the main HTML directory, the
145 : sh002i 174 system_html subdirectory. If both static HTML and CGIs reside on the
146 :     same host (which is true in most cases), you can omit the
147 :     http://hostname section of the URL, but make sure the leading slash is
148 :     present.
149 : sh002i 168
150 :     };
151 :    
152 :     my $GROUP_TEXT = q{
153 :    
154 : apizer 1082 WeBWorK needs to know what the admin group is. This group should have been
155 :     set up by your system administrator and must contain at least your user ID.
156 : sh002i 168 All files and directories created will have this as their group.
157 :    
158 :     };
159 :    
160 :     my $COURSE_PERMS_TEXT = q{
161 :    
162 : apizer 1082 You have the option to set permissions for the courses directory. If this is
163 :     an inital setup, you should probably do so. If this is not an initial setup,
164 :     the courses directory is already set up, or the courses directory is shared
165 : sh002i 168 between WeBWorK installations, your probably shouldn't.
166 :    
167 :     };
168 :    
169 :     my $CHGRP_TEXT = q{
170 :    
171 : apizer 1082 You have to option to set the group for all system files and directories. If
172 :     this is an initial setup, you should probably do this. If this is not an
173 :     initial setup, or you have customized the way system files should be
174 : sh002i 168 grouped, you probably shoudn't.
175 :    
176 :     };
177 :    
178 :     my $CHMOD_TEXT = q{
179 :    
180 : apizer 1082 You have to option to set the permissions for all system files and
181 :     directories. If this is an initial setup, you should probably do this. If
182 :     this is not an initial setup, or you have customized the permissions for the
183 : sh002i 168 system files, you probably shoudn't.
184 :    
185 :     };
186 :    
187 :     my $CONFIRM_TEXT = q{
188 :    
189 : apizer 1082 Now that I have the necessary information, I can begin modifying the WeBWorK
190 : sh002i 168 system files.
191 :    
192 :     };
193 :    
194 :     my $DONE_TEXT = q{
195 :    
196 :     The system setup script is done. Please read the above messages
197 :     carefully to determine if there have been any errors. If so, correct the
198 :     problem (usually a permissions problem) and run this script again.
199 :    
200 :     };
201 :    
202 :    
203 :    
204 :    
205 :    
206 :     ################################################################################
207 :     ########## Ask some questions, perform some logic. #############################
208 :     ################################################################################
209 :    
210 :    
211 :    
212 :    
213 :    
214 :     #################### introduction
215 :    
216 :     my $temp;
217 :    
218 :     unless($no_prompts) {
219 :     page($INTRO_TEXT);
220 :     $temp = questionChar("Do you want to continue with setup?", 'y', 'y', 'n');
221 :     exit unless $temp eq 'y';
222 :     }
223 :     print "Okay, here we go...\n";
224 :    
225 :     #################### working or demo?
226 :    
227 :     unless(defined $system_setup_mode) {
228 :     page($MODE_TEXT);
229 :     $temp = questionChar("Shall we set up a working version or a demo version?", 'w', 'w', 'd');
230 :     $system_setup_mode = "working" if $temp eq 'w';
231 :     $system_setup_mode = "demo" if $temp eq 'd';
232 :     }
233 :     print "System setup mode is: $system_setup_mode\n";
234 :    
235 :     #################### main directory
236 :    
237 :     unless(defined $mainDir) {
238 :     page($MAIN_DIR_TEXT);
239 : sh002i 174 $mainDir = questionString("Where is the WeBWorK system directory?", cwd());
240 : sh002i 168 $mainDir .= '/' unless $mainDir =~ m|/$|; # ensure trailing slash
241 :     }
242 :     print "We'll use $mainDir as WeBWorK's system directory.\n";
243 :    
244 :     #################### perl path
245 :    
246 :     unless(defined $perlPath) {
247 :     page($PERL_TEXT);
248 :     $perlPath = questionString("What is the full path to PERL?", $DEFAULT_PERL_PATH);
249 :     }
250 :     print "Path to PERL binary is: $perlPath\n";
251 :    
252 :     #################### CGI URL
253 :    
254 :     unless(defined $cgiURL) {
255 :     page($CGI_URL_TEXT);
256 :     while (1) {
257 :     $cgiURL = questionString("What is the CGI URL?", $DEFAULT_CGI_URL);
258 :     if( ($cgiURL =~ m|^/|) or ($cgiURL =~ m|^http://|) ) {
259 :     last;
260 :     } else {
261 :     $temp = questionChar("That doesn't look like a valid URL. Would you like to use it anyway?", 'n', 'y', 'n');
262 :     last if $temp eq 'y';
263 :     }
264 :     }
265 :     $cgiURL .= "/" unless $cgiURL =~ m"/$"; # ensure trailing slash
266 :     }
267 :     print "CGI URL is: $cgiURL\n";
268 :    
269 : sh002i 1521 #################### system HTML directory
270 :    
271 :     unless(defined $htmlDir) {
272 :     page($HTML_DIR_TEXT);
273 : sh002i 1532 my $htmlDirGuess = ${mainDir};
274 :     $htmlDirGuess =~ s|[^/]+/$|system_html/|;
275 :     $htmlDir = questionString("Where is the WeBWorK system HTML directory?", $htmlDirGuess);
276 : sh002i 1521 $htmlDir .= '/' unless $htmlDir =~ m|/$|; # ensure trailing slash
277 :     }
278 :     print "We'll use $htmlDir as WeBWorK's system HTML directory.\n";
279 :    
280 : sh002i 168 #################### HTML URL
281 :    
282 :     unless(defined $htmlURL) {
283 :     page($HTML_URL_TEXT);
284 :     while (1) {
285 :     $htmlURL = questionString("What is the HTML URL?", $DEFAULT_HTML_URL);
286 :     if( ($htmlURL =~ m|^/|) or ($htmlURL =~ m|^http://|) ) {
287 :     last;
288 :     } else {
289 :     $temp = questionChar("That doesn't look like a valid URL. Would you like to use it anyway?", 'n', 'y', 'n');
290 :     last if $temp eq 'y';
291 :     }
292 :     }
293 :     $htmlURL .= "/" unless $htmlURL =~ m"/$" ;
294 :     }
295 :     print "HTML URL is: $htmlURL\n";
296 :    
297 :     #################### admin group
298 :    
299 :     unless(defined $groupName) {
300 :     my ($userName, $userGID) = (getpwuid $<)[0,3];
301 :     my $userGroupName = (getgrgid $userGID)[0];
302 : apizer 1082
303 : sh002i 168 if ($system_setup_mode eq 'demo') {
304 :     # in demo mode, the group is set to the user's primary group
305 :     $groupName = $userGroupName;
306 :     } else {
307 :     # in working mode, we get to chose
308 :     page($GROUP_TEXT);
309 :     while(1) {
310 :     $groupName = questionString("What is the admin group name?", $DEFAULT_ADMIN_GROUP);
311 : sh002i 417 my @group = getgrnam $groupName;
312 :     unless(@group) {
313 :     print "$groupName does not exist.\n";
314 :     next;
315 :     }
316 :     my @members = split / /, $group[3];
317 : sh002i 168 if($groupName eq $userGroupName) {
318 :     print "$groupName is ${userName}'s primary group. Good.\n";
319 : sh002i 417 last;
320 :     } elsif(grep { $_ eq $userName } @members) {
321 : sh002i 168 print "$userName is a member of $groupName. Good.\n";
322 :     last;
323 :     } elsif($< == 0) { # we're root!
324 :     print "$userName isn't a member of $groupName, but you're root, so who cares?\n";
325 :     last;
326 :     } else {
327 : sh002i 417 print "$groupName is not a valid group. Please make sure the group exists and $userName are a member.\n";
328 : sh002i 168 }
329 :     }
330 :     }
331 :     }
332 :     print "Admin group is: $groupName\n";
333 :    
334 :     #################### chmod courses directory
335 :    
336 :     unless(defined $update_stuff_in_courses) {
337 :     page($COURSE_PERMS_TEXT);
338 :     $temp = questionChar("Do you want to set default $system_setup_mode permissions for the courses directory?", 'y', 'y', 'n');
339 :     $update_stuff_in_courses = ($temp eq 'y');
340 :     }
341 :     print "Permissions ", ($update_stuff_in_courses ? "will" : "will not"), " be set for the courses directory.\n";
342 :    
343 :    
344 :     #################### chgrp files/directories
345 :    
346 :     $system_setup_mode eq "demo" and $chgrp_files_and_dirs = 1;
347 :     unless(defined $chgrp_files_and_dirs) {
348 :     page($CHGRP_TEXT);
349 :     $temp = questionChar("Do you want to set the group for system files and directories?", 'y', 'y', 'n');
350 :     $chgrp_files_and_dirs = ($temp eq 'y');
351 :     }
352 :     print "Group ", ($chgrp_files_and_dirs ? "will" : "will not"), " be set for system files and directories.\n";
353 :    
354 :     #################### chmod files/directories
355 :    
356 :     $system_setup_mode eq "demo" and $chmod_files_and_dirs = 1;
357 :     unless(defined $chmod_files_and_dirs) {
358 :     page($CHMOD_TEXT);
359 :     $temp = questionChar("Do you want to set the permissions for system files and directories?", 'y', 'y', 'n');
360 :     $chmod_files_and_dirs = ($temp eq 'y');
361 :     }
362 :     print "Permissions ", ($chmod_files_and_dirs ? "will" : "will not"), " be set for system files and directories.\n";
363 :    
364 :     #################### make sure we want to actually do this
365 :    
366 :     unless($no_prompts) {
367 :     print $CONFIRM_TEXT;
368 :     $temp = questionChar("Do you want to continue with setup?", 'y', 'y', 'n');
369 :     exit unless $temp eq 'y';
370 :     }
371 :     print "\Going to make changes now...\n\n";
372 :    
373 :    
374 :    
375 :    
376 :    
377 :     ################################################################################
378 :     ########## Now we start changing things... #####################################
379 :     ################################################################################
380 :    
381 :    
382 :    
383 :    
384 :    
385 :     #################### run local preprocessor
386 :    
387 :     if(defined $local_preprocessor) {
388 :     print "Executing local preprocessor...\n";
389 :     &$local_preprocessor;
390 :     print "Done with local preprocessor.\n";
391 :     }
392 :    
393 :     #################### update #! and use lines
394 :     # uses: $mainDir, $perlPath
395 :    
396 :     print "Fixing #! lines...\n";
397 :    
398 :     foreach my $dir ("${mainDir}cgi/cgi-scripts", "${mainDir}scripts", "${mainDir}courseScripts") {
399 :     foreach my $file (<${dir}/*.pl>) {
400 :     fixFile($file);
401 :     }
402 :     }
403 :    
404 :     sub fixFile
405 :     {
406 :     my ($file) = @_;
407 : apizer 1082
408 : sh002i 168 # read the file
409 :     open FILE, $file || die "Couldn't open $file for reading.";
410 :     my @lines = <FILE>;
411 :     close FILE || die "Couldn't close $file after reading.";
412 : apizer 1082
413 : sh002i 168 # fix perl path
414 : sh002i 1526 $lines[0] =~ m/^#!(.*)$/;
415 : sh002i 168 if($1 ne $perlPath) {
416 : sh002i 1526 $lines[0] =~ s/^#!.*$/#!$perlPath/;
417 : sh002i 168 open FILE, ">$file" || die "Couldn't open $file for writing.";
418 :     print FILE @lines;
419 :     close FILE || die "Couldn't close $file for writing.";
420 :     }
421 :     }
422 :    
423 :     print "done fixing #! and \"use\" lines.\n\n";
424 :    
425 :     #################### write webworkConfig.pm file
426 : sh002i 1521 # uses: $mainDir, $cgiURL, $htmlDir, $htmlURL
427 : sh002i 168
428 :     print "Writing lib/webworkConfig.pm file...\n";
429 :     open CONFIG_FILE, ">${mainDir}lib/webworkConfig.pm";
430 :     print CONFIG_FILE<<END_OF_CONFIG_FILE;
431 :     package Global;
432 :    
433 :     ################################################################################
434 :     # WeBWorK
435 : apizer 1082 #
436 : sh002i 168 # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester
437 :     # All rights reserved
438 :     ################################################################################
439 :    
440 : apizer 228 # \$cgiDebugMode, if enabled, will call the debug wrapper scripts instead of the
441 : apizer 217 # cgi scripts themselves, allowing for header output, etc. In addition to
442 : apizer 228 # setting \$cgiDebugMode =1, you will also need to enable debugging in the
443 :     # wrapper scripts that you wish to debug, by setting \$debug = 1. Wrapper
444 :     # scripts are found in the directory referred to by \$cgiWebworkURL, which is
445 : apizer 217 # usually webwork/system/cgi.
446 :     \$cgiDebugMode = 0;
447 :    
448 : sh002i 168 \$mainDirectory = "$mainDir";
449 : sh002i 1521 \$htmlWebworkDir = "$htmlDir";
450 : sh002i 168 \$htmlWebworkURL = "$htmlURL";
451 : sh002i 174 \$cgiWebworkURL = "$cgiURL";
452 : sh002i 168 \$cgiWebworkURL .= "cgi-scripts/" unless \$cgiDebugMode;
453 :    
454 :     1;
455 :     END_OF_CONFIG_FILE
456 :     close CONFIG_FILE;
457 :     print "Done writing lib/webworkConfig.pm file.\n\n";
458 :    
459 :     #################### write webworkInit.pm files
460 :     # uses: $mainDir
461 :    
462 :     print "Writing webworkInit.pm files...\n";
463 : apizer 1172 foreach my $dir ('cgi/', 'cgi/cgi-scripts/', 'scripts/') {
464 : sh002i 168 open INIT_FILE, ">$mainDir${dir}webworkInit.pm";
465 :     print INIT_FILE<<END_OF_INIT_FILE;
466 :     ################################################################################
467 :     # WeBWorK
468 : apizer 1082 #
469 : sh002i 168 # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester
470 :     # All rights reserved
471 :     ################################################################################
472 :    
473 :     use lib '${mainDir}lib/';
474 : sh002i 1521 use lib '${mainDir}courseScripts/';
475 : sh002i 168
476 :     1;
477 :     END_OF_INIT_FILE
478 :     close INIT_FILE;
479 :     }
480 :     print "Done writing webworkInit.pm files.\n\n";
481 :    
482 :     #################### chgrp system stuff
483 :     # uses: $chgrp_files_and_dirs, $groupName
484 :    
485 :     if($chgrp_files_and_dirs) {
486 :     print "Setting group on system files and directories...\n";
487 :     system "chgrp -R $groupName $mainDir";
488 : sh002i 174 system "chgrp -R $groupName $mainDir/../system_html";
489 : sh002i 1813 # Don't do this.
490 :     #system "chgrp -R $groupName $mainDir/../pg";
491 : sh002i 168 print "Done setting group.\n\n";
492 :     }
493 :    
494 :     #################### chmod system stuff
495 :     # uses: $chmod_files_and_dirs
496 :    
497 :     if($chmod_files_and_dirs) {
498 :     print "Setting permissions on system files and directories for $system_setup_mode mode...\n";
499 :     if ($system_setup_mode eq "demo") {
500 :     # get some general permissions for files and directories
501 : apizer 231 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0755";
502 :     system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0644";
503 : sh002i 1813 # Don't do this.
504 :     #system "find $mainDir $mainDir/../pg -type d -print | xargs chmod 0755";
505 :     #system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0644";
506 : sh002i 168 # add executable privs to scripts
507 : apizer 231 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0755";
508 : sh002i 168 } else {
509 :     # get some general permissions for files and directories
510 : apizer 231 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0775";
511 :     system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0664";
512 : sh002i 1813 # Don't do this.
513 :     #system "find $mainDir $mainDir/../pg -type d -print | xargs chmod 0775";
514 :     #system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0664";
515 : sh002i 168 # add executable privs to scripts
516 : apizer 231 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0775";
517 : sh002i 168 }
518 : apizer 225 # make the log files group writable
519 : apizer 1082 system "find $mainDir/logs -type f -print | xargs chmod 0664";
520 : apizer 224 # make the error_log file world writable
521 : apizer 231 system "find $mainDir/logs/error_log -print | xargs chmod 0666";
522 : apizer 224
523 : sh002i 168 print "done setting permissions.\n\n";
524 :     }
525 :    
526 :     #################### update couses stuff
527 :     # uses: $update_stuff_in_courses
528 :    
529 :     if($update_stuff_in_courses) {
530 : sh002i 177 print "Setting permissions for ../courses directory...\n";
531 :     if ($system_setup_mode eq "demo") {
532 :     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";
533 :     } else {
534 :     chmod(0775, "$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";
535 :     }
536 :     print "done permissions.\n\n";
537 : sh002i 168 }
538 :    
539 :     #################### run local postprocessor
540 :    
541 :     if(defined $local_postprocessor) {
542 :     print "Executing local postprocessor...\n";
543 :     &$local_postprocessor;
544 :     print "Done with local postprocessor.\n";
545 :     }
546 :    
547 :     #################### finish up
548 :    
549 :     page($DONE_TEXT);
550 :    
551 :     ################################################################################
552 :    
553 :     sub page
554 :     {
555 :     my @string_lines = split /^/, shift; #/
556 :     # not really optimal, but we're going to assume a constant screen height.
557 :     my $SCREEN_HEIGHT = 20;
558 :     while(@string_lines) {
559 :     print join "", @string_lines[0..($SCREEN_HEIGHT>scalar @string_lines ? (scalar @string_lines)-1 : $SCREEN_HEIGHT-1)];
560 :     if(scalar @string_lines >= $SCREEN_HEIGHT) {
561 :     print "\n[Press ENTER to continues...]";
562 :     <STDIN>;
563 :     print "\n";
564 :     }
565 :     @string_lines = @string_lines[$SCREEN_HEIGHT..$#string_lines];
566 :     }
567 :     }
568 :    
569 :     sub questionChar
570 :     {
571 :     my ($question, $default, @valid) = @_;
572 :     my $answer;
573 :     do {
574 :     print $question, " ";
575 :     foreach (@valid) {
576 :     $_ eq $default and print "[";
577 :     print $_;
578 :     $_ eq $default and print "]";
579 :     }
580 :     print " ";
581 :     $answer = <STDIN>;
582 :     $answer =~ s/^\s*//;
583 :     $answer = substr $answer, 0, 1;
584 :     $answer = lc $answer;
585 :     $answer or $answer = $default;
586 :     } while (not grep(/$answer/, @valid));
587 :     return $answer;
588 :     }
589 :    
590 :     sub questionString
591 :     {
592 :     my ($question, $default, $emptyOK) = @_;
593 :     my $answer;
594 :     print $question, " [", $default, "] ";
595 :     $answer = <STDIN>;
596 :     chomp $answer;
597 :     $answer =~ s/^\s*//;
598 :     $answer or $answer = $default;
599 :     return $answer;
600 :     }
601 :    
602 :     __END__
603 :    
604 :     =head1 NAME
605 :    
606 :     system_webwork_setup.pl - set up the WeBWorK system
607 :    
608 :     =head1 SYNOPSIS
609 :    
610 :     system_webwork_setup.pl [B<-d> [defaults-file]]
611 :    
612 :     =head1 DESCRIPTION
613 :    
614 :     B<system_webwork_setup.pl> gathers the information necessary for configuration of the WeBWorK system. It then edits several WeBWorK system files, and creates F<webworkInit.pm> modules and the F<webworkConfig.pm> module based on the information gathered. It can optionally read defaults from a file specified on the command line or from the file F<$HOME/system_webwork_setup.defaults>.
615 :    
616 :     =head1 OPTIONS
617 :    
618 :     =over 4
619 :    
620 :     =item B<-d>
621 :    
622 :     enables defaults-file processing. If no defaults-file is specified, the file F<$HOME/system_webwork_setup.defaults> will be used.
623 :    
624 :     =head1 DEFAULTS
625 :    
626 :     The F<system_webwork_setup.defaults> file is intended to be used in a situation where B<system_webwork_setup.pl> must be executed frequently, such as in the case of use with CVS, in which the it must be executed after a checkout and some updates. The defaults file is a perl script that will be require'd by B<system_webwork_setup.pl>. It can set any of the following variables in the usual way:
627 :    
628 :     =over 4
629 :    
630 :     =item $no_prompts
631 :    
632 :     Refrain from prompting at the beginning of the script and before making changes. Also supresses the introductory text.
633 :    
634 :     =item $system_setup_mode
635 :    
636 :     Can be set to "working" or "demo". This affects how system file permissions and group ownership are set. In "working" mode, system files are group owned by a webwork admin group (see I<$groupName>) and group writeable while in "demo" mode files are group owned by the current user's default group and are not group writeable.
637 :    
638 :     =item $mainDir
639 :    
640 :     Specify WeBWorK's main directory, which should contain the directories cgi/ scripts/ courseScripts/ and lib/.
641 :    
642 :     =item $perlPath
643 :    
644 :     Specify the path to the perl interpreter which should be used. This is used to set the shebang line in cgi-scripts and scripts.
645 :    
646 :     =item $cgiURL
647 :    
648 :     Specify the externally visible URL to the CGI directory (typically cgi/cgi-scripts/). This will be used when scripts call other scripts.
649 :    
650 :     =item $htmlURL
651 :    
652 :     Specify the externally visible URL to the HTML directory (typically system_html/). This will be used when scripts refer to static graphics and text.
653 :    
654 :     =item $groupName
655 :    
656 :     When in "working" mode, I<$groupName> is the name of the WeBWorK admin group, members of which should have write access to the system files. (The web server should not be in this group!)
657 :    
658 :     =item $update_stuff_in_courses
659 :    
660 :     If true, B<system_webwork_setup.pl> will set permissions in the courses directory and prepare the B<course_webwork_setup.pl> script for execution.
661 :    
662 :     =item $chgrp_files_and_dirs, $chmod_files_and_dirs
663 :    
664 :     If true, the group and/or permissions on system files will be set according to I<$system_setup_mode>.
665 :    
666 :     =item $local_preprocessor, $local_postprocessor
667 :    
668 :     If set, these variables will be called as subroutine references. I<$local_preprocessor> is called before any changes take place, while I<$local_postprocessor> is called after all changes have taken place.
669 :    
670 :     =back
671 :    
672 :     =head1 FILES
673 :    
674 :     $HOME/system_webwork_setup.defaults
675 :    
676 :     =head1 AUTHOR
677 :    
678 :     Samuel Hathaway <sh002i@math.rochester.edu>

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9