Parent Directory
|
Revision Log
minor changes
1 #!/usr/local/bin/webwork-perl 2 use strict; 3 4 5 ################################################################################ 6 ## 7 ## File: course_webwork_setup.pl (for WeBWorK course installation) 8 ## 9 ## this file changes the permissions to the correct ones in each of the 10 ## subdirectories and the main course directory. It also creates the 11 ## webworkCourse.ph file. 12 ## It prompts the user to enter the correct cgiURL and htmlURL 13 ## The default values for these variables and for the variables pointing 14 ## to the main directory can be set in the file defaults.cws. 15 ## 16 ############################################################################### 17 18 sub getAns { 19 my $ans = <STDIN>; 20 $ans =~ s/^\s*//; 21 $ans = substr($ans, 0, 1); 22 return lc($ans); 23 } 24 25 ################# Prompt to run this script ######################### 26 print qq{ 27 This script is used to setup a WeBWorK course. 28 29 A "demo" or "working" version of the course can be setup. 30 31 This script will create initialization files, directories, 32 and set groups and default permissions. It will make backups 33 of files that are changed. For a "working" version it will 34 not make any changes without prompting. \n 35 36 This script must be run from the base course directory, for 37 example from /www/webwork-root/webwork/courses/mth140a 38 39 You will need the following information:\n 40 1) The course URL (e.g. http://webwork.math.rochester.edu/mth140a/) 41 2) The cgi WeBWorK URL. It is listed in the Global.pm file as \$cgiWebworkURL. 42 Global.pm is a file in the .../webwork/system/lib directory. 43 3) The symbolic link (e.g. mth140a) pointing to the course (we call this the CLASS_ID). 44 It appears in the courses subdirectory of the main WeBWorK system directory. 45 4) The group (e.g. MTH140A) containing the webserver, your loginID, and the loginID's 46 of anyone else who will creating and editing WeBWorK problems for your course. 47 YOU DO NOT NEED THIS WHEN SETTING UP A "DEMO" VERSION. 48 49 Hit [Enter] to continue... 50 }; 51 my $garbage; 52 $garbage = <STDIN>; 53 54 print qq{ 55 Items 3) and 4) should be set up by your system administrator before running this script. 56 57 In our example the classID and the group name are different, but they can be the same. 58 59 See the html document .../docs/techdescription/usingwebwork.html for detailed 60 explainations. The examples here are taken from those directions. docs is a 61 subdirectory of the main WeBWorK system directory. 62 63 Do you wish to continue\? (y or n) 64 }; 65 66 exit(0) if &getAns ne 'y'; 67 68 69 ################## Find out if setting up a demo or working course ########################## 70 my $course_setup_mode = 'working'; 71 my $file_creation_mode = 'working'; 72 73 print qq{ 74 75 76 You can set up a "working" or a "demo" version of a course. A "demo" version 77 should only be used as a sample course, never for an actual course. In a "demo" 78 version all the system type files specific to the course (e.g. webworkCourse.ph) 79 are world readable and many files are world writable. 80 Other than that, "working" or "demo" versions function the same. 81 82 Do you wish to setup a "working" or a "demo" version? (w or d) 83 }; 84 85 if (&getAns eq 'd') { 86 $course_setup_mode = 'demo'; 87 $file_creation_mode = 'demo'; 88 } 89 90 print qq{ 91 92 Setting up a $course_setup_mode version. 93 94 }; 95 96 ################## read + process defaults file ###################### 97 98 my ($htmlurldefault,$cgiurldefault,$courselinkdefault); 99 open(DEFAULTS, "defaults.cws"); 100 while(<DEFAULTS>) 101 { 102 chomp($_); 103 $_ =~ s/^ //g; 104 if($_ =~ /^#/ || $_ eq "") ## comment line or blank line 105 {} 106 else 107 { 108 $_ =~ /^\s*(\w+)\s*=\s*([-,\s\/\w\.:]*)/; ## does this include everything that can be in a filename or a URL??? 109 if ($1 eq "htmlURL") 110 {$htmlurldefault = $2;} 111 if ($1 eq "cgiURL") 112 {$cgiurldefault = $2;} 113 if ($1 eq "courseLink") 114 {$courselinkdefault = $2;} 115 } 116 } 117 118 close(DEFAULTS); 119 # done with defaults 120 121 122 123 ################### Create directories if they don't exist. ################### 124 my $ans; 125 if ($course_setup_mode eq 'demo') {$ans = 'y';} 126 else { 127 print "\nDefault directory and file permissions are set assuming\n"; 128 print "the webserver is in the group.\n\n"; 129 print "Do you want to create missing directories (if any)\? (y or n)\n"; 130 $ans = &getAns; 131 } 132 if ($ans eq 'y') 133 { 134 print "\n"; 135 unless(-e 'scoring') 136 { 137 mkdir('scoring', 0770); 138 chmod(0770, 'scoring') || die "Can't do chmod on scoring directory"; 139 print 'directory scoring'.", 0770 created.\n"; 140 } 141 unless(-e 'scoring/scoring.log') 142 { 143 open(TEMPCREATEFILE, ">scoring/scoring.log") || die "Can't open scoring/scoring.log"; 144 close(TEMPCREATEFILE); 145 chmod(0660,"scoring/scoring.log") || die "Can't do chmod(0660, scoring/scoring.log)"; 146 print 'file scoring/scoring.log'.", 0660 created.\n"; 147 } 148 unless(-e 'DATA') 149 { 150 mkdir('DATA', 0770); 151 chmod(0770, 'DATA') || die "Can't do chmod on DATA directory"; 152 print 'directory DATA'.", 0770 created.\n"; 153 } 154 unless(-e 'DATA/.auth') 155 { 156 mkdir('DATA/.auth', 0770); 157 chmod(0770, 'DATA/.auth') || die "Can't do chmod on DATA/.auth directory"; 158 print 'directory DATA/.auth'.", 0770 created.\n"; 159 } 160 unless(-e 'html') 161 { 162 mkdir('html', 0770); 163 chmod(0770, 'html') || die "Can't do chmod on html directory"; 164 print 'directory html'.", 0770 created.\n"; 165 } 166 unless(-e 'html/images') 167 { 168 mkdir('html/images', 0770); 169 chmod(0770, 'html/images') || die "Can't do chmod on html/images/ directory"; 170 print 'directory html/images'.", 0770 created.\n"; 171 } 172 unless(-e 'html/tmp') 173 { 174 mkdir('html/tmp', 0770); 175 chmod(0770, 'html/tmp') || die "Can't do chmod on html/tmp/ directory"; 176 print 'directory html/tmp'.", 0770 created.\n"; 177 } 178 unless(-e 'html/tmp/l2h') 179 { 180 mkdir('html/tmp/l2h', 0770); 181 chmod(0770, 'html/tmp/l2h') || die "Can't do chmod on html/tmp/l2h directory"; 182 print 'directory html/tmp/l2h'.", 0770 created.\n"; 183 } 184 unless(-e 'html/tmp/eps') 185 { 186 mkdir('html/tmp/eps', 0770); 187 chmod(0770, 'html/tmp/eps') || die "Can't do chmod on html/tmp/eps directory"; 188 print 'directory html/tmp/eps'.", 0770 created.\n"; 189 } 190 unless(-e 'html/tmp/images') 191 { 192 mkdir('html/tmp/images', 0770); 193 chmod(0770, 'html/tmp/images') || die "Can't do chmod on html/tmp/images directory"; 194 print 'directory html/tmp/images'.", 0770 created.\n"; 195 } 196 unless(-e 'html/tmp/gif') 197 { 198 mkdir('html/tmp/gif', 0770); 199 chmod(0770, 'html/tmp/gif') || die "Can't do chmod on html/tmp/gif directory"; 200 print 'directory html/tmp/gif'.", 0770 created.\n"; 201 } 202 unless(-e 'html/tmp/html') 203 { 204 mkdir('html/tmp/html', 0770); 205 chmod(0770, 'html/tmp/html') || die "Can't do chmod on html/tmp/html directory"; 206 print 'directory html/tmp/html'.", 0770 created.\n"; 207 } 208 unless(-e 'templates') 209 { 210 mkdir('templates', 0770); 211 chmod(0770, 'templates') || die "Can't do chmod on templates directory"; 212 print 'directory templates'.", 0770 created.\n"; 213 } 214 unless(-e 'templates/email') 215 { 216 mkdir('templates/email', 0770); 217 chmod(0770, 'templates/email') || die "Can't do chmod on templates/email directory"; 218 print 'directory templates/email'.", 0770 created.\n"; 219 } 220 unless(-e 'templates/macros') 221 { 222 mkdir('templates/macros', 0750); 223 chmod(0750, 'templates/macros') || die "Can't do chmod on templates/macros directory"; 224 print 'directory templates/macros'.", 0750 created.\n"; 225 } 226 unless(-e 'logs') 227 { 228 mkdir('logs', 0770); 229 chmod(0770, 'logs') || die "Can't do chmod on logs directory"; 230 print 'logs'.", 0770 created.\n"; 231 } 232 unless(-e 'logs/login.log') 233 { 234 open(TEMPCREATEFILE, ">logs/login.log") || die "Can't open logs/login.log"; 235 close(TEMPCREATEFILE); 236 chmod(0660,"logs/login.log") || die "Can't do chmod(0660, logs/login.log)"; 237 print 'file logs/login.log'.", 0660 created.\n"; 238 } 239 } 240 241 242 243 ##################### get base directory ############################### 244 245 use Cwd; ## module for getting current wording directory 246 247 my $current_dir = cwd(); 248 $current_dir .= '/' unless $current_dir =~ m|/$|; 249 $current_dir =~ m|([^/]+/)$|; 250 my $courseDirectory = $1; 251 252 ####################### Prompt for htmlURL ############################### 253 print "\n\n"; 254 255 print <<MSG1,"--------->"; 256 257 ------------> ENTER course URL <------------- 258 259 This html-URL should be a link in the webserver's htdocs tree which points 260 to the html subdirectory of the course you are creating. See documentation 261 for help. 262 263 (e.g. $htmlurldefault) 264 265 default = $htmlurldefault 266 MSG1 267 268 my $HTML_URL=<STDIN>; 269 chomp($HTML_URL); 270 if ($HTML_URL eq '') 271 { 272 $HTML_URL = $htmlurldefault; 273 } 274 275 $HTML_URL = check_URL('html-URL',$HTML_URL); 276 277 $HTML_URL .= "/" unless $HTML_URL =~ m"/$" ; 278 print qq(\nhtmlURL set to: "$HTML_URL"\n); 279 280 #################### Prompt for cgiURL ################################### 281 print "\n\n\n\n"; 282 283 print <<MSG2,"--------->"; 284 285 ------------> ENTER cgi WeBWorK URL <------------- 286 287 This cgi-URL should be point to the url of the main WeBWorK 288 cgi subdirectory. It is listed in the Global.pm file of the 289 main WeBWorK system as \$cgiWebworkURL . If you use a relative 290 path name (e.g. "/cgi-bin/system/"), don't forget the first "/". 291 292 (e.g. $cgiurldefault) 293 294 default = $cgiurldefault 295 MSG2 296 297 my $CGI_URL=<STDIN>; 298 chomp($CGI_URL); 299 if ($CGI_URL eq '') 300 { 301 $CGI_URL = $cgiurldefault; 302 } 303 304 $CGI_URL = check_URL('cgi-URL',$CGI_URL); 305 306 $CGI_URL .= "/" unless $CGI_URL =~ m"/$" ; 307 print qq(\ncgiURL set to: "$CGI_URL"\n); 308 309 ################## Prompt for courseLink ############################### 310 print "\n\n\n\n"; 311 312 print <<MSG3,"--------->"; 313 314 ------------> ENTER course link (i.e. classID) name <------------- 315 316 This symbolic link (i.e. the classID) points to the course directory. It 317 appears in the courses subdirectory of the main WeBWorK system. (If 318 instead of a link, you have put the actual course directory under 319 .../system/courses/, enter the course directory name.) 320 321 (e.g. mth140a) 322 323 default = $courselinkdefault 324 MSG3 325 my $CLASS_ID=<STDIN>; 326 chomp($CLASS_ID); 327 if ($CLASS_ID eq "") 328 { 329 $CLASS_ID = $courselinkdefault; 330 } 331 print qq(\ncourse link (i.e. the classID) set to: "$CLASS_ID"\n); 332 333 334 ################## Prompt for group ############################### 335 336 my ($name, $passwd, $gid, $members, @info,$groupName); 337 338 if ($course_setup_mode eq 'demo') { 339 @info = getpwuid($<); 340 $gid =$info[3]; 341 $groupName = (getgrgid($gid))[0]; 342 } 343 344 else { 345 print "\n\n\n\n"; 346 347 print <<MSG4,"--------->"; 348 349 ------------> ENTER group name <------------- 350 351 352 This group should have been set up by your systen administrator 353 and must contain at least your userID and (for a "working" version) 354 the userID of the webserver. All files and directories created will 355 have this as their group. 356 357 Enter the group name: 358 MSG4 359 $groupName = <STDIN>; 360 chomp($groupName); 361 362 unless ((defined($groupName)) and ($groupName =~ /\w+/)){ 363 my @info = getpwuid($<); 364 $gid =$info[3]; 365 $groupName = (getgrgid($gid))[0]; 366 } 367 368 print qq(\ngroup will be set to: "$groupName"\n); 369 ($name, $passwd, $gid, $members) = getgrnam ($groupName); 370 371 # check that the group name is valid 372 # should probably check that the webserver is also a member of this group XXXXXXX 373 374 $members = " ".$members." "; ## put a spaces arround string 375 my $username = getpwuid($<); 376 if($members =~ /\s+$username\s+/) 377 { 378 print "\n\nGood. $username is a member of the group $groupName.\n\n"; 379 } 380 else 381 { 382 print "\n\nSorry. $username is NOT a member of the group $groupName.\n"; 383 print "The group for all directories and files will not be changed.\n"; 384 print "Ask your system administrator to set up the group. Then you can\n"; 385 print "change the group by hand (see instructions) or run this script again.\n\n"; 386 die; 387 } 388 } 389 390 ################## BEGIN new webworkCourse.ph ######################### 391 392 open(COURSETMP, ">webworkCourse.ph.tmp"); 393 print COURSETMP <<"ENDCOURSETMP"; 394 395 # file webworkCourse.ph 396 # contains variables specific to a course 397 398 # The variables defined in Global.pm set defaults and 399 # parameters for the whole WeBWorK system. These defaults can 400 # be over ridden for this individual course by redefining 401 # the variables in this webworkCourse.ph file. 402 # For example the default feedback address set in Global.pm as: 403 # \$feedbackAddress = 'webwork\@math.rochester.edu'; 404 # can (and should) be over ridden by entering 405 # \$Global::feedbackAddress = 'apizer\@math.rochester.edu,gage\@math.rochester.edu'; 406 # below where of course you should substitute your own email address 407 # for that of Pizer and Gage (and uncomment the line). 408 409 # \$Global::feedbackAddress = 'apizer\@math.rochester.edu,gage\@math.rochester.edu'; 410 411 # In addition, the smtp mail server (defined in Global.pm) requires a valid single 412 # email address. Normally this is set to the address of the course administrator. 413 # Undeliverable email from the Send Mail page will be returned to the smtpSender address. 414 # Uncomment the line below and enter a valid email address (if you leave it commented 415 # out the webmaster's email address from Global.pm will be used). 416 417 # \$Global::smtpSender = 'apizer\@math.rochester.edu'; 418 419 420 # You should customize the following three items for your course. 421 422 # If you want to write essay type problems or questionnaires where the results are 423 # emailed back, you have to authorize the email addresses here by uncommenting and 424 # editing the next line. 425 426 # \$PG_environment{'ALLOW_MAIL_TO'} = ['apizer\@math.rochester.edu','gage\@math.rochester.edu']; 427 428 429 # On the Professor page, one can view statistical data on problem sets for 430 # the whole course and section by section or by recitation. You may want to 431 # exclude certain sections or recitations (e.g. those containing practice users, 432 # TA's, or professors) from the overall statistics. Statistics for excluded 433 # sections are reported separately. List the names of all sections and 434 # recitations to be excluded in a coma separated list, e.g. 435 # \@excluse_these_sections_from_overall_statistics = ('', 'T.A.', 'Prof section'); 436 # \@excluse_these_recitations_from_overall_statistics = (''); 437 # If this list is empty or commented out, no sections will be excluded. 438 439 \@excluse_these_sections_from_overall_statistics = (''); 440 \@excluse_these_recitations_from_overall_statistics = (''); 441 442 443 # If the following line is uncommented, when the user(s) listed view 444 # a problem or download a set, the file names of the source files will be 445 # listed. Replace 'leeza', etc. by appropiate login names. It is very 446 # useful for professors to be able to see these file names. 447 448 #\$PG_environment{'PRINT_FILE_NAMES_FOR'} = ['leeza','apizer','gage']; 449 450 451 # Finally, when sending bulk email to students from the sendmail page, the following 452 # default values are used for the From and Reply-To fields. Normally these fields 453 # are filled in and these default values are not used. More importanly, the 454 # defaultReply value is also used in the Reply-To field on feedback email which students 455 # can send to the feedbackAddress by hitting the feedback button. The format is the same 456 # as for the feedbackAddress above. 457 458 \$Global::defaultFrom = \$Global::feedbackAddress; 459 \$Global::defaultReply = \$Global::feedbackAddress; 460 461 ###################################################################################### 462 ###################################################################################### 463 464 # NORMALLY, THERE SHOULD BE NO NEED FOR CHANGES BELOW THIS LINE. RUN THE SCRIPT 465 # course_webwork_setup.pl AND EVERYTHING SHOULD BE SETUP CORRECTLY. IF YOU DO 466 # EDIT THIS FILE BY HAND, WORK CAREFULLY. REMEMBER THAT ALL DIRECTORY NAMES MUST 467 # END IN A TRALING DIRECTORY DELIMITER. 468 469 470 471 # To make it easier to edit and change these directories we define 472 # the classDirectory. This variable is not used outside this file 473 # and while it is common for all of these directories to reside inside 474 # one directory, it is not necessary. 475 476 \$classDirectory = "\${mainDirectory}courses/$courseDirectory"; 477 478 # The database directory contains data describing the students in the course 479 # and their scores on homework. The cgi scripts run by the webserver must 480 # be able to access the contents of this directory. 481 482 \$databaseDirectory = "\${classDirectory}DATA/"; 483 484 # The templates directory contains the class list, the problem set definition 485 # files and the problem templates. 486 487 \$templateDirectory = "\${classDirectory}templates/"; 488 489 # The email directory contains (templates of) emails which can be sent to everyone 490 # on the classlist. 491 492 \$emailDirectory = "\${templateDirectory}email/"; 493 494 # The macros directory contains macros for the problems files and the 495 # problem templates. These are usually macro files which are particular to the course. 496 # Macro files are searched for first in the \$macroDirectory and then 497 # in the system's courseScript directory. If it is commented out, the macro files are 498 # only searched for in the system's courseScript directory. 499 500 \$macroDirectory = "\${templateDirectory}macros/"; 501 502 # The scoring directory contains files used by the scoring programs. These 503 # files contain scoring information for the whole class and are used for 504 # calculating semester grades, etc. 505 506 \$scoringDirectory = "\${classDirectory}scoring/"; 507 508 # The html directory contains the first page for the course (index.html), 509 # course documentation, and also subdirectories (e.g. tmp/) 510 # (e.g. tmp/) containing latex2html problems, gifs, etc. The webserver has 511 # direct access to the html directory and the courseURL points to this 512 # directory. 513 514 \$htmlDirectory = "\${classDirectory}html/"; 515 516 # The logs directory contains log fies, e.g. login.log, backup psvn 517 # logs and logs of datamunger activity. 518 519 \$logsDirectory = "\${classDirectory}logs/"; 520 521 # This is the temp directory used by downloadPS, etc. It is used for temporary storage of 522 # html files, images, etc. that have to accessible to the webserver. This directory 523 # contains the subdirectories l2h, gif, eps, png, and html (not the \${classDirectory}html 524 # directory). All these subdirectories and their files will be recreated if deleted 525 # (althought recreating l2h files is time consuming). The location of this directory 526 # may be changed to a fast disk which is not backed up. 527 528 \$courseTempDirectory = "\${classDirectory}html/tmp/"; 529 530 # This is the URL of the course html directory. It points to the \$htmlDirectory 531 # above and it should have been set up correctly by the course_webwork_setup.pl 532 # script. See the documentatiom (run the script or read 533 # .../docs/techdescription/settingupcourse.html). Note that the URL depends on 534 # links in you webserver's htdocs directory and must end in a trailing directory 535 # delimiter (/ for unix). 536 537 \$htmlURL = "$HTML_URL"; 538 539 # This is the URL of the course tmp directory. It points to the \$courseTempDirectory 540 # above and it should have been set up correctly by the course_webwork_setup.pl 541 # script. See the documentatiom (run the script or read 542 # .../docs/techdescription/settingupcourse.html). Note that the URL depends on 543 # links in you webserver's htdocs directory and must end in a trailing directory 544 # delimiter (/ for unix). 545 546 \$courseTempURL = "\${htmlURL}tmp/"; 547 548 # This is the classID, i.e the symbolic link (or directory) that points to the base 549 # course directory. It appears in the courses subdirectory of the main WeBWorK system. 550 551 \$classID = "$CLASS_ID"; 552 553 # This is the name of the default classlist file which resides in the 554 # templateDirectory. This default name is used to edit the classlist file over 555 # the web. 556 557 \$classlistFilename = "\${classID}.lst"; 558 559 # This is the name of the group and the numerical gid. (some) Files created by 560 # the WeBWorK system will have their group set to "\$groupID". Normally this 561 # group will contain the webserver, your loginID, and the loginID's of anyone 562 # else who will creating and editing WeBWorK problems for your course. If you 563 # are editing this file by hand and know the \$groupID but not the \$numericalGroupID, 564 # ask your systems administrator or run course_webwork_setup.pl and look at the 565 # webworkCourse.ph it produces. You may also be able to get this information by 566 # looking at the group file usually: /etc/group 567 # Finally, if you have set up a "demo" version, the "\$numericalGroupID" will be 568 # set to -1 which means maintain the current (default) group. 569 ENDCOURSETMP 570 571 if ($file_creation_mode eq 'demo') 572 { 573 print COURSETMP <<"ENDCOURSETMP"; 574 575 \$groupID = "$groupName"; 576 \$numericalGroupID = -1; 577 578 ## this sets the header file over riding the Global setting 579 580 \$Global::SET_HEADER = "paperSetHeader.pg"; 581 582 ENDCOURSETMP 583 } 584 585 else 586 { 587 print COURSETMP <<"ENDCOURSETMP"; 588 589 \$groupID = "$groupName"; 590 \$numericalGroupID = $gid; 591 592 ## this sets the header file over riding the Global setting 593 \$Global::SET_HEADER = "paperSetHeader.pg"; 594 595 ## If uncommented, this sets the default mode for displayed problems 596 ## over riding the Global setting. 597 #\$htmlModeDefault = 'HTML_tth'; # The default mode for displayed problems 598 # (either 'HTML','Latex2HTML', or 'HTML_tth') 599 600 # This sets the default for grading multipart problems. The choices at present are 601 # std_problem_grader or avg_problem_grader. The std_problem_grader gives credit for 602 # a mutipart problem only if all parts are answers correctly. The avg_problem_grader 603 # gives partial credit for a mutipart problems. 604 605 \$PG_environment{PROBLEM_GRADER_TO_USE} = 'avg_problem_grader'; 606 #\$PG_environment{PROBLEM_GRADER_TO_USE} = 'std_problem_grader'; 607 608 609 # This allows or dissallows Destroy and Rebuild. Set to 0 or 1. If set to 1 a 610 # professor can destroy and rebuild problems sets in one operation. This is very 611 # convenient and powerful, but also very dangerous. Usually this is not allowed 612 # in courses students are using. It is often set to 1 in a private course being 613 # used only for developing problem sets. 614 615 \$allowDestroyRebuildProbSets = 0; 616 617 ENDCOURSETMP 618 } 619 620 621 if ($file_creation_mode eq 'demo') 622 { 623 print COURSETMP <<"ENDCOURSETMP"; 624 625 ## File and Directory permissions 626 627 ## These permissions over ride the permissions set in 628 ## Global.pm 629 630 ## e.g. S1-1521.sco in (base course directory)/DATA 631 \$sco_files_permission = 0666; 632 633 ## tie permissions (used in tie commands) 634 ## The database, password, and permissions files 635 ## always take their permissions from the Global 636 ## vaiables below. The important keys file 637 ## takes its permission from \$restricted_tie_permission. 638 \$restricted_tie_permission = 0666; 639 \$standard_tie_permission = 0666; 640 641 ## webwork-database in (base course directory)/DATA 642 \$webwork_database_permission = 0666; 643 644 ## password in (base course directory)/DATA/.auth 645 \$password_permission = 0666; 646 647 ## permissions in (base course directory)/DATA/.auth 648 \$permissions_permission = 0666; 649 650 ## e.g. s1ful.csv in (base course directory)/scoring 651 \$scoring_files_permission = 0666; 652 653 ## e.g. s1bak1.csv in (base course directory)/scoring 654 \$scoring_bak_files_permission = 0666; 655 656 ## e.g. 8587l2h.log in (base course directory)/html/tmp/l2h 657 \$l2h_logs_permission = 0666; 658 659 ## e.g set1/ in (base course directory)/html/tmp/l2h 660 \$l2h_set_directory_permission = 0777; 661 662 ## e.g. 1-1082/ in (base course directory)/html/tmp/l2h/set1 663 \$l2h_prob_directory_permission = 0777; 664 665 ## e.g. 1082output.html in (base course directory)/html/tmp/l2h/set1/1-1082 666 \$l2h_data_permission = 0777; 667 668 ENDCOURSETMP 669 } 670 671 print COURSETMP <<"ENDCOURSETMP"; 672 673 674 ## This (if uncommented) overrides the setting in Global.pm. Use 'db_tie.pl' for the 675 ## DB database and 'gdbm_tie.pl' for the GDBM database. For a "new" database type, 676 ## you will have to write a 'newdb_tie.pl' file. These reside in the scripts directory. 677 678 #\$Global::DBtie_file = 'db_tie.pl'; 679 680 681 ## This tells WeBWorK where to find the file that connects it to a physical database. 682 683 require "\${Global::scriptDirectory}\$Global::DBtie_file"; 684 685 ## These are the file names for the various databases associated with this course. 686 ## These names override the generic names given in Global.pm 687 688 \$CL_Database = "\${classID}_classlist_DB"; 689 \$passwordFilename = "\${classID}_password_DB"; 690 \$permissionsFilename = "\${classID}_permissions_DB"; 691 \$database = "\${classID}_webwork_DB"; 692 693 # The following line is required by perl 694 1; 695 696 ENDCOURSETMP 697 close(COURSETMP); 698 699 ############# END new webworkCourse.ph ######################### 700 701 ###################### BEGIN new index.html ######################### 702 703 open(INDEXTMP, ">index.html.tmp"); 704 print INDEXTMP <<"ENDINDEXTMP"; 705 <HTML> 706 <HEAD> 707 <TITLE>Welcome to WeBWorK</TITLE> 708 </HEAD> 709 710 <BODY BGCOLOR="#FFFFFF"> 711 712 <P ALIGN=CENTER> 713 <IMG SRC="/webwork_system_html/images/webwork.gif" ALIGN=CENTER BORDER=1 ALT="WeBWorK Logo"> 714 </P> 715 716 <BLOCKQUOTE> 717 <H1>WeBWorK Generic Course Login Page for $CLASS_ID</H1> 718 <HR> 719 720 <H2>Log in as "practice" user</H2> 721 722 You may test out WeBWorK by logging in as a 723 "practice" user. To begin, choose the <B>login</B> button below; 724 Use <B><KBD>practice1</KBD></B> as your login name and password. 725 726 <FORM ACTION= "${CGI_URL}login.pl" METHOD="POST"> 727 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$CLASS_ID"> 728 <B><INPUT TYPE=SUBMIT VALUE="Login"></B> 729 </FORM> 730 731 <P> 732 <STRONG>For more information on WeBWorK: </STRONG> 733 <A HREF="http://webwork.math.rochester.edu/docs/docs">Webwork docs</A>. 734 735 <HR> 736 737 738 <FORM ACTION="${CGI_URL}feedback.pl" METHOD="POST"> 739 <INPUT TYPE="image" SRC="/webwork_system_html/images/ww_feedback.gif" BORDER=1 ALT="[Feedback]" VALUE="Feedback"> 740 741 Last updated: <STRONG>22 August 2000</STRONG><BR> 742 <TT>${HTML_URL}index.html</TT> 743 744 </BLOCKQUOTE> 745 746 </BODY></HTML> 747 748 ENDINDEXTMP 749 close(INDEXTMP); 750 ############# END new index.html ######################### 751 752 #################### prompt for creating webworkCourse.ph ################# 753 print "\n\n"; 754 if (-e 'webworkCourse.ph') 755 { 756 if ($course_setup_mode eq 'demo') {$ans = 'y';} 757 else { 758 print "An old webworkCourse.ph exists. Do you want to create a new\n"; 759 print "webworkCourse.ph and save the old file as webworkCourse.ph.bak1?\n"; 760 print "If you answer y, and webworkCourse.ph.bak1 already exits, it\n"; 761 print "will be saved as webworkCourse.ph.bak2. Only two backups are kept. (y or n)\n"; 762 $ans=&getAns; 763 } 764 765 if ($ans eq 'y') 766 { 767 rename('webworkCourse.ph.bak1', 'webworkCourse.ph.bak2'); 768 rename('webworkCourse.ph', 'webworkCourse.ph.bak1'); 769 rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp"; 770 chmod 0664, 'webworkCourse.ph'; 771 } 772 else 773 { 774 print "\nThe old webworkCourse.ph has not been changed. You can look\n"; 775 print "at webworkCourse.ph.tmp to see what the new version would have been.\n"; 776 } 777 } 778 else 779 { 780 if ($course_setup_mode eq 'demo') {$ans = 'y';} 781 else { 782 print "Do you want to create a webworkCourse.ph file (we recommmend that\n"; 783 print "you do as it is required for WeBWorK to function)? (y or n)\n"; 784 $ans=&getAns; 785 } 786 if ($ans eq 'y') 787 { 788 rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp. 789 Fix the problem and run the setup script again. Stopped "; 790 chmod 0644, 'webworkCourse.ph'; 791 } 792 else 793 { 794 print "\nA webworkCourse.ph file has not been created. You will need to\n"; 795 print "create such a file. You can look at webworkCourse.ph.tmp to see\n"; 796 print "what the file would have looked like.\n"; 797 } 798 } 799 800 #################### prompt for creating index.html ################# 801 802 print "\n\n"; 803 if (-e 'html/index.html') 804 { 805 if ($course_setup_mode eq 'demo') {$ans = 'y';} 806 else { 807 print "An old index.html exists. Do you want to create a new\n"; 808 print "index.html and save the old file as index.html.bak1\?\n"; 809 print "If you answer y, and index.html.bak1 already exits, it\n"; 810 print "will be saved as index.html.bak2. Only two backups are kept. (y or n)\n"; 811 $ans= &getAns; 812 } 813 814 if ($ans eq 'y') 815 { 816 rename('html/index.html.bak1', 'html/index.html.bak2'); 817 rename('html/index.html', 'html/index.html.bak1'); 818 rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped "; 819 chmod 0664, 'html/index.html'; 820 } 821 else 822 { 823 print "\nThe old index.html has not been changed. You can look\n"; 824 print "at index.html.tmp to see what the new version would have been.\n"; 825 } 826 } 827 else 828 { 829 if ($course_setup_mode eq 'demo') {$ans = 'y';} 830 else { 831 print "Do you want to create an index.html file (we recommmend that\n"; 832 print "you do as it is required for WeBWorK to function)? (y or n)\n"; 833 834 $ans= &getAns; 835 } 836 if ($ans eq 'y') 837 { 838 rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped "; 839 chmod 0664, 'html/index.html'; 840 } 841 else 842 { 843 print "\nA index.html file has not been created. You will need to\n"; 844 print "create such a file. You can look at index.html.tmp to see\n"; 845 print "what the file would have looked like.\n"; 846 } 847 } 848 849 850 ################### Prompt to change the group ########################## 851 if ($course_setup_mode eq 'demo') {$ans = 'y';} 852 else { 853 print qq{ 854 Do you want to set the group for all directories and files\? 855 It is highly recommended that you do so. Note that the default 856 permissions for "working" version assumes the webserver is in 857 the group. (y or n) 858 }; 859 860 861 $ans= &getAns; 862 } 863 { ## bare block to make breaking out easy 864 if ($ans eq 'y') 865 { 866 867 868 chown(-1, $gid, '.'); 869 chown(-1, $gid, <*>); 870 chown(-1, $gid, <logs/*>); 871 chown(-1, $gid, <DATA/*>); 872 chown(-1, $gid, <DATA/.auth>); 873 chown(-1, $gid, <DATA/.auth/*>); 874 chown(-1, $gid, <html/*>); 875 chown(-1, $gid, <html/tmp/*>); 876 chown(-1, $gid, <html/tmp/l2h/*>); 877 chown(-1, $gid, <html/tmp/l2h/*/*>); 878 chown(-1, $gid, <html/tmp/l2h/*/*/*>); 879 chown(-1, $gid, <scoring/*>); 880 chown(-1, $gid, <templates/*>); 881 chown(-1, $gid, <templates/*/*>); 882 chown(-1, $gid, <templates/*/*/*>); 883 print qq(\n The group has been set to "$groupName"\n\n); 884 } 885 } ##end of bare block 886 887 888 ######################### Prompt file permission changes ###################### 889 if ($course_setup_mode eq 'demo') {$ans = 'y';} 890 else { 891 print "\n\n\n\n"; 892 print qq( 893 Do you want to set default "$course_setup_mode" permissions for 894 all directories and files\? It is highly recommended that you do so. 895 The default permissions for a "working" version assume the webserver 896 is in the group. 897 Set permissions\? (y or n) 898 ); 899 $ans= &getAns; 900 901 } 902 if ($ans eq 'y') 903 {if ($course_setup_mode eq "demo") 904 { ####demo mode 905 chmod(0755, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped "; 906 chmod(0755, <*.pl>); ## perl files 907 chmod(0644, <*.ph>); ## ph files 908 chmod(0777, 'scoring') || die "Can't set permissions correctly for scoring directory. Fix the problem and run the setup script again. Stopped "; 909 chmod(0666, <scoring/*>) ; # files in scoring - 600, there may be no files 910 chmod(0777, 'logs') || die "Can't set permissions correctly for logs directory. Fix the problem and run the setup script again. Stopped "; 911 chmod(0666, <logs/*>) ; # files in logs - 660, there may be no files 912 chmod(0777, 'DATA') || die "Can't set permissions correctly for DATA directory. Fix the problem and run the setup script again. Stopped "; 913 chmod(0666, <DATA/*>) ; # files in DATA - 660, there may be no files 914 chmod(0777, 'DATA/.auth') || die "Can't set permissions correctly for DATA/.auth directory. Fix the problem and run the setup script again. Stopped "; 915 chmod(0666, <DATA/.auth/*>) ; # files in DATA/.auth - 660, there may be no files 916 chmod(0775, 'html') || die "Can't set permissions correctly for html directory. Fix the problem and run the setup script again. Stopped "; # html subdir - 750 917 chmod(0664, <html/*>) ; 918 chmod(0777, 'html/images') || die "Can't set permissions correctly for html/images/ directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/ subdir - 775 919 chmod(0777, 'html/tmp') || die "Can't set permissions correctly for html/tmp/ directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/ subdir - 775 920 chmod(0777, 'html/tmp/l2h') || die "Can't set permissions correctly for html/tmp/l2h directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 921 chmod(0777, <html/tmp/l2h/*>); # html/tmp/l2h/ subdir - 775 922 chmod(0777, <html/tmp/l2h/*/*>) ; # html/tmp/l2h/ subdir - 775 923 chmod(0777, <html/tmp/l2h/*/*/*>) ; # html/tmp/l2h/ subdir - 775 924 chmod(0777, 'html/tmp/eps') || die "Can't set permissions correctly for html/tmp/eps directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 925 chmod(0777, 'html/tmp/images') || die "Can't set permissions correctly for html/tmp/images directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 926 chmod(0777, 'html/tmp/gif') || die "Can't set permissions correctly for html/tmp/gif directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 927 chmod(0777, 'html/tmp/html') || die "Can't set permissions correctly for html/tmp/html directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 928 # chmod(0755, 'courseScripts') || die "Can't set permissions correctly for courseScripts directory. Fix the problem and run the setup script again. Stopped "; # courseScripts subdir - 750 929 # chmod(0755, <courseScripts/*>) ; 930 chmod(0777, 'templates') || die "Can't set permissions correctly for templates directory. Fix the problem and run the setup script again. Stopped "; # templates subdir - 750 931 chmod(0777, <templates/*>) ; # files and directories in templates - 777, there may be no files 932 chmod(0777, <templates/*/*>) ; # files and directories in templates - 777, there may be no files 933 chmod(0777, <templates/*/*/*>) ; # files and directories in templates - 777, there may be no files 934 chmod(0755, 'templates/macros') || die "Can't set permissions correctly for templates/macros directory. Fix the problem and run the setup script again. Stopped "; # templates/macros subdir - 750 935 chmod(0755, <templates/macros/*>) ; # files in templates/macros - 640, there may be no files 936 print "\n Permissions set to default values.\n"; 937 } 938 else #####working mode 939 { 940 chmod(0750, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped "; 941 chmod(0750, <*.pl>); ## perl files 942 chmod(0640, <*.ph>); ## ph files 943 chmod(0770, 'scoring') || die "Can't set permissions correctly for scoring directory. Fix the problem and run the setup script again. Stopped "; 944 chmod(0660, <scoring/*>) ; # files in scoring - 600, there may be no files 945 chmod(0770, 'logs') || die "Can't set permissions correctly for logs directory. Fix the problem and run the setup script again. Stopped "; 946 chmod(0660, <logs/*>) ; # files in logs - 660, there may be no files 947 chmod(0770, 'DATA') || die "Can't set permissions correctly for DATA directory. Fix the problem and run the setup script again. Stopped "; 948 chmod(0660, <DATA/*>) ; # files in DATA - 660, there may be no files 949 chmod(0770, 'DATA/.auth') || die "Can't set permissions correctly for DATA/.auth directory. Fix the problem and run the setup script again. Stopped "; 950 chmod(0660, <DATA/.auth/*>) ; # files in DATA/.auth - 660, there may be no files 951 chmod(0770, 'html') || die "Can't set permissions correctly for html directory. Fix the problem and run the setup script again. Stopped "; # html subdir - 750 952 chmod(0660, <html/*>) ; 953 chmod(0770, 'html/images') || die "Can't set permissions correctly for html/images/ directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/ subdir - 775 954 chmod(0770, 'html/tmp') || die "Can't set permissions correctly for html/tmp/ directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/ subdir - 775 955 chmod(0770, 'html/tmp/l2h') || die "Can't set permissions correctly for html/tmp/l2h directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 956 chmod(0770, <html/tmp/l2h/*>); # html/tmp/l2h/ subdir - 775 957 chmod(0770, <html/tmp/l2h/*/*>) ; # html/tmp/l2h/ subdir - 775 958 chmod(0770, <html/tmp/l2h/*/*/*>) ; # html/tmp/l2h/ subdir - 775 959 chmod(0770, 'html/tmp/eps') || die "Can't set permissions correctly for html/tmp/eps directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 960 chmod(0770, 'html/tmp/images') || die "Can't set permissions correctly for html/tmp/images directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 961 chmod(0770, 'html/tmp/gif') || die "Can't set permissions correctly for html/tmp/gif directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 962 chmod(0770, 'html/tmp/html') || die "Can't set permissions correctly for html/tmp/html directory. Fix the problem and run the setup script again. Stopped "; # html/tmp/l2h/ subdir - 775 963 # chmod(0750, 'courseScripts') || die "Can't set permissions correctly for courseScripts directory. Fix the problem and run the setup script again. Stopped "; # courseScripts subdir - 750 964 # chmod(0750, <courseScripts/*>) ; 965 chmod(0770, 'templates') || die "Can't set permissions correctly for templates directory. Fix the problem and run the setup script again. Stopped "; # templates subdir - 750 966 chmod(0770, <templates/*>) ; # files and directories in templates - 770, there may be no files 967 chmod(0770, <templates/*/*>) ; # files and directories in templates - 770, there may be no files 968 chmod(0770, <templates/*/*/*>) ; # files and directories in templates - 770, there may be no files 969 chmod(0750, 'templates/macros') || die "Can't set permissions correctly for templates/macros directory. Fix the problem and run the setup script again. Stopped "; # templates/macros subdir - 750 970 chmod(0750, <templates/macros/*>) ; # files in templates/macros - 640, there may be no files 971 print "\n Permissions set to default values.\n"; 972 } 973 } 974 975 if (-e 'DATA/.auth/keys') { 976 unlink 'DATA/.auth/keys' || warn "Can't remove the DATA/.auth/keys file. You do not have to run the setup script again, but you should remove this file by hand/n"; 977 } 978 979 print qq{ 980 The WeBWorK Course setup script has finished. 981 982 983 In order to complete the setup, please continue reading the instructions about: 984 985 1) using chmod g+s to set the group setid properly. 986 2) running import_classlist-database.pl in order to set up the classlist, password and permissions databases. 987 3) running setProfPermissions.pl in order to give someone (probably yourself) professor privileges. 988 4) building problem sets (initially just go to the professor's page and click on 'Enter Build 989 Problem set Page). 990 }; 991 992 993 994 995 sub check_URL { 996 my ($name_URL,$var_URL) = @_; 997 my $response = 'y'; 998 while ($response eq 'y') { 999 if (($var_URL =~ m|^/|) or ($var_URL =~ m|^http://|)) { 1000 $response = 'n'; 1001 } 1002 else { 1003 print qq{\nThe $name_URL you entered, $var_URL , does not begin with either \n 1004 a slash (/) or with http:// . This is almost certainly an error. \n 1005 Do you want to enter the $name_URL again? (y or n)}; 1006 $response =&getAns; 1007 if ($response ne 'n') { 1008 print "\n Enter the $name_URL:\n"; 1009 $var_URL=<STDIN>; 1010 chomp($var_URL); 1011 $response = 'y'; 1012 } 1013 else { 1014 $response = 'n'; 1015 } 1016 } 1017 } 1018 $var_URL; 1019 }
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |