#!/usr/bin/perl use strict; ################################################################################ ## ## File: course_webwork_setup.pl (for WeBWorK course installation) ## ## this file changes the permissions to the correct ones in each of the ## subdirectories and the main course directory. It also creates the ## webworkCourse.ph file. ## It prompts the user to enter the correct cgiURL and htmlURL ## The default values for these variables and for the variables pointing ## to the main directory can be set in the file defaults.cws. ## ############################################################################### sub getAns { my $ans = ; $ans =~ s/^\s*//; $ans = substr($ans, 0, 1); return lc($ans); } ################# Prompt to run this script ######################### print qq{ This script is used to setup a WeBWorK course. A "demo" or "working" version of the course can be setup. This script will create initialization files, directories, and set groups and default permissions. It will make backups of files that are changed. For a "working" version it will not make any changes without prompting. \n This script must be run from the base course directory, for example from /www/webwork-root/webwork/courses/mth140a You will need the following information:\n 1) The course URL (e.g. http://webwork.math.rochester.edu/mth140a/) 2) The cgi WeBWorK URL. It is listed in the Global.pm file as \$cgiWebworkURL. Global.pm is a file in the main WeBWorK system directory. 3) The symbolic link (e.g. mth140a) pointing to the course (we call this the CLASS_ID). It appears in the courses subdirectory of the main WeBWorK system directory. 4) The group (e.g. MTH140A) containing the webserver, your loginID, and the loginID's of anyone else who will creating and editing WeBWorK problems for your course. YOU DO NOT NEED THIS WHEN SETTING UP A "DEMO" VERSION. Hit [Enter] to continue... }; my $garbage; $garbage = ; print qq{ Items 3) and 4) should be set up by your system administrator before running this script. In our example the classID and the group name are different, but they can be the same. See the html document .../docs/techdescription/usingwebwork.html for detailed explainations. The examples here are taken from those directions. docs is a subdirectory of the main WeBWorK system directory. Do you wish to continue\? (y or n) }; exit(0) if &getAns ne 'y'; ################## Find out if setting up a demo or working course ########################## my $course_setup_mode = 'working'; my $file_creation_mode = 'working'; print qq{ You can set up a "working" or a "demo" version of a course. A "demo" version should only be used as a sample course, never for an actual course. In a "demo" version all the system type files specific to the course (e.g. webworkCourse.ph) are world readable and many files are world writable. Other than that, "working" or "demo" versions function the same. Do you wish to setup a "working" or a "demo" version? (w or d) }; if (&getAns eq 'd') { $course_setup_mode = 'demo'; $file_creation_mode = 'demo'; } print qq{ Setting up a $course_setup_mode version. }; ################## read + process defaults file ###################### my ($htmlurldefault,$cgiurldefault,$courselinkdefault); open(DEFAULTS, "defaults.cws"); while() { chomp($_); $_ =~ s/^ //g; if($_ =~ /^#/ || $_ eq "") ## comment line or blank line {} else { $_ =~ /^\s*(\w+)\s*=\s*([-,\s\/\w\.:]*)/; ## does this include everything that can be in a filename or a URL??? if ($1 eq "htmlURL") {$htmlurldefault = $2;} if ($1 eq "cgiURL") {$cgiurldefault = $2;} if ($1 eq "courseLink") {$courselinkdefault = $2;} } } close(DEFAULTS); # done with defaults ################### Create directories if they don't exist. ################### my $ans; if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "\nDefault directory and file permissions are set assuming\n"; print "the webserver is in the group.\n\n"; print "Do you want to create missing directories (if any)\? (y or n)\n"; $ans = &getAns; } if ($ans eq 'y') { print "\n"; unless(-e 'scoring') { mkdir('scoring', 0770); chmod(0770, 'scoring') || die "Can't do chmod on scoring directory"; print 'directory scoring'.", 0770 created.\n"; } unless(-e 'scoring/scoring.log') { open(TEMPCREATEFILE, ">scoring/scoring.log") || die "Can't open scoring/scoring.log"; close(TEMPCREATEFILE); chmod(0660,"scoring/scoring.log") || die "Can't do chmod(0660, scoring/scoring.log)"; print 'file scoring/scoring.log'.", 0660 created.\n"; } unless(-e 'DATA') { mkdir('DATA', 0770); chmod(0770, 'DATA') || die "Can't do chmod on DATA directory"; print 'directory DATA'.", 0770 created.\n"; } unless(-e 'DATA/.auth') { mkdir('DATA/.auth', 0770); chmod(0770, 'DATA/.auth') || die "Can't do chmod on DATA/.auth directory"; print 'directory DATA/.auth'.", 0770 created.\n"; } unless(-e 'html') { mkdir('html', 0770); chmod(0770, 'html') || die "Can't do chmod on html directory"; print 'directory html'.", 0770 created.\n"; } unless(-e 'html/images') { mkdir('html/images', 0770); chmod(0770, 'html/images') || die "Can't do chmod on html/images/ directory"; print 'directory html/images'.", 0770 created.\n"; } unless(-e 'html/tmp') { mkdir('html/tmp', 0770); chmod(0770, 'html/tmp') || die "Can't do chmod on html/tmp/ directory"; print 'directory html/tmp'.", 0770 created.\n"; } unless(-e 'html/tmp/l2h') { mkdir('html/tmp/l2h', 0770); chmod(0770, 'html/tmp/l2h') || die "Can't do chmod on html/tmp/l2h directory"; print 'directory html/tmp/l2h'.", 0770 created.\n"; } unless(-e 'html/tmp/eps') { mkdir('html/tmp/eps', 0770); chmod(0770, 'html/tmp/eps') || die "Can't do chmod on html/tmp/eps directory"; print 'directory html/tmp/eps'.", 0770 created.\n"; } unless(-e 'html/tmp/images') { mkdir('html/tmp/images', 0770); chmod(0770, 'html/tmp/images') || die "Can't do chmod on html/tmp/images directory"; print 'directory html/tmp/images'.", 0770 created.\n"; } unless(-e 'html/tmp/gif') { mkdir('html/tmp/gif', 0770); chmod(0770, 'html/tmp/gif') || die "Can't do chmod on html/tmp/gif directory"; print 'directory html/tmp/gif'.", 0770 created.\n"; } unless(-e 'html/tmp/html') { mkdir('html/tmp/html', 0770); chmod(0770, 'html/tmp/html') || die "Can't do chmod on html/tmp/html directory"; print 'directory html/tmp/html'.", 0770 created.\n"; } unless(-e 'courseScripts') { mkdir('courseScripts', 0750); chmod(0750, 'courseScripts') || die "Can't do chmod on courseScripts directory"; print 'directory courseScripts'.", 0750 created.\n"; } unless(-e 'templates') { mkdir('templates', 0770); chmod(0770, 'templates') || die "Can't do chmod on templates directory"; print 'directory templates'.", 0770 created.\n"; } unless(-e 'templates/email') { mkdir('templates/email', 0770); chmod(0770, 'templates/email') || die "Can't do chmod on templates/email directory"; print 'directory templates/email'.", 0770 created.\n"; } unless(-e 'templates/macros') { mkdir('templates/macros', 0750); chmod(0750, 'templates/macros') || die "Can't do chmod on templates/macros directory"; print 'directory templates/macros'.", 0750 created.\n"; } unless(-e 'logs') { mkdir('logs', 0770); chmod(0770, 'logs') || die "Can't do chmod on logs directory"; print 'logs'.", 0770 created.\n"; } unless(-e 'logs/login.log') { open(TEMPCREATEFILE, ">logs/login.log") || die "Can't open logs/login.log"; close(TEMPCREATEFILE); chmod(0660,"logs/login.log") || die "Can't do chmod(0660, logs/login.log)"; print 'file logs/login.log'.", 0660 created.\n"; } } ##################### get base directory ############################### use Cwd; ## module for getting current wording directory my $current_dir = cwd(); $current_dir .= '/' unless $current_dir =~ m|/$|; $current_dir =~ m|([^/]+/)$|; my $courseDirectory = $1; ####################### Prompt for htmlURL ############################### print "\n\n"; print <"; ------------> ENTER course URL <------------- This html-URL should be a link in the webserver's htdocs tree which points to the html subdirectory of the course you are creating. See documentation for help. (e.g. $htmlurldefault) default = $htmlurldefault MSG1 my $HTML_URL=; chomp($HTML_URL); if ($HTML_URL eq '') { $HTML_URL = $htmlurldefault; } $HTML_URL = check_URL('html-URL',$HTML_URL); $HTML_URL .= "/" unless $HTML_URL =~ m"/$" ; print qq(\nhtmlURL set to: "$HTML_URL"\n); #################### Prompt for cgiURL ################################### print "\n\n\n\n"; print <"; ------------> ENTER cgi WeBWorK URL <------------- This cgi-URL should be point to the url of the main WeBWorK cgi subdirectory. It is listed in the Global.pm file of the main WeBWorK system as \$cgiWebworkURL . If you use a relative path name (e.g. "/cgi-bin/system/"), don't forget the first "/". (e.g. $cgiurldefault) default = $cgiurldefault MSG2 my $CGI_URL=; chomp($CGI_URL); if ($CGI_URL eq '') { $CGI_URL = $cgiurldefault; } $CGI_URL = check_URL('cgi-URL',$CGI_URL); $CGI_URL .= "/" unless $CGI_URL =~ m"/$" ; print qq(\ncgiURL set to: "$CGI_URL"\n); ################## Prompt for courseLink ############################### print "\n\n\n\n"; print <"; ------------> ENTER course link (i.e. classID) name <------------- This symbolic link (i.e. the classID) points to the course directory. It appears in the courses subdirectory of the main WeBWorK system. (If instead of a link, you have put the actual course directory under .../system/courses/, enter the course directory name.) (e.g. mth140a) default = $courselinkdefault MSG3 my $CLASS_ID=; chomp($CLASS_ID); if ($CLASS_ID eq "") { $CLASS_ID = $courselinkdefault; } print qq(\ncourse link (i.e. the classID) set to: "$CLASS_ID"\n); ################## Prompt for group ############################### my ($name, $passwd, $gid, $members, @info,$groupName); if ($course_setup_mode eq 'demo') { @info = getpwuid($<); $gid =$info[3]; $groupName = (getgrgid($gid))[0]; } else { print "\n\n\n\n"; print <"; ------------> ENTER group name <------------- This group should have been set up by your systen administrator and must contain at least your userID and (for a "working" version) the userID of the webserver. All files and directories created will have this as their group. Enter the group name: MSG4 $groupName = ; chomp($groupName); unless ((defined($groupName)) and ($groupName =~ /\w+/)){ my @info = getpwuid($<); $gid =$info[3]; $groupName = (getgrgid($gid))[0]; } print qq(\ngroup will be set to: "$groupName"\n); ($name, $passwd, $gid, $members) = getgrnam ($groupName); # check that the group name is valid # should probably check that the webserver is also a member of this group XXXXXXX $members = " ".$members." "; ## put a spaces arround string my $username = getpwuid($<); if($members =~ /\s+$username\s+/) { print "\n\nGood. $username is a member of the group $groupName.\n\n"; } else { print "\n\nSorry. $username is NOT a member of the group $groupName.\n"; print "The group for all directories and files will not be changed.\n"; print "Ask your system administrator to set up the group. Then you can\n"; print "change the group by hand (see instructions) or run this script again.\n\n"; die; } } ################## BEGIN new webworkCourse.ph ######################### open(COURSETMP, ">webworkCourse.ph.tmp"); print COURSETMP <<"ENDCOURSETMP"; # file webworkCourse.ph # contains variables specific to a course # The variables defined in Global.pm set defaults and # parameters for the whole WeBWorK system. These defaults can # be over ridden for this individual course by redefining # the variables in this webworkCourse.ph file. # For example the default feedback address set in Global.pm as: # \$feedbackAddress = 'webwork\@math.rochester.edu'; # can (and should) be over ridden by entering # \$Global::feedbackAddress = 'apizer\@math.rochester.edu,gage\@math.rochester.edu'; # below where of course you should substitute your own email address # for that of Pizer and Gage (and uncomment the line). # \$Global::feedbackAddress = 'apizer\@math.rochester.edu,gage\@math.rochester.edu'; ## In addition, you should customize the following three items for your course # If you want to write essay type problems or questionnaires where the results are # emailed back, you have to authorize the email addresses here by uncommenting and # editing the next line. # \$PG_environment{'ALLOW_MAIL_TO'} = ['apizer\@math.rochester.edu','gage\@math.rochester.edu']; # On the Professor page, one can view statistical data on problem sets for # the whole course and section by section or by recitation. You may want to # exclude certain sections or recitations (e.g. those containing practice users, # TA's, or professors) from the overall statistics. Statistics for excluded # sections are reported separately. List the names of all sections and # recitations to be excluded in a coma separated list, e.g. # \@excluse_these_sections_from_overall_statistics = ('', 'T.A.', 'Prof section'); # \@excluse_these_recitations_from_overall_statistics = (''); # If this list is empty or commented out, no sections will be excluded. \@excluse_these_sections_from_overall_statistics = (''); \@excluse_these_recitations_from_overall_statistics = (''); # If the following line is uncommented, when the user(s) listed view # a problem or download a set, the file names of the source files will be # listed. Replace 'leeza', etc. by appropiate login names #\$PG_environment{'PRINT_FILE_NAMES_FOR'} = ['leeza','apizer','gage']; ###################################################################################### ###################################################################################### # NORMALLY, THERE SHOULD BE NO NEED FOR CHANGES BELOW THIS LINE. RUN THE SCRIPT # course_webwork_setup.pl AND EVERYTHING SHOULD BE SETUP CORRECTLY. IF YOU DO # EDIT THIS FILE BY HAND, WORK CAREFULLY. REMEMBER THAT ALL DIRECTORY NAMES MUST # END IN A TRALING DIRECTORY DELIMITER. # To make it easier to edit and change these directories we define # the classDirectory. This variable is not used outside this file # and while it is common for all of these directories to reside inside # one directory, it is not necessary. \$classDirectory = "\${mainDirectory}courses/$courseDirectory"; # The database directory contains data describing the students in the course # and their scores on homework. The cgi scripts run by the webserver must # be able to access the contents of this directory. \$databaseDirectory = "\${classDirectory}DATA/"; # The templates directory contains the class list, the problem set definition # files and the problem templates. \$templateDirectory = "\${classDirectory}templates/"; # The email directory contains (templates of) emails which can be sent to everyone # on the classlist. \$emailDirectory = "\${templateDirectory}email/"; # The macros directory contains macros for the problems # files and the problem templates. If it is commented out, the macro files in # "\${mainDirectory}courseScripts/" are used by default. # \$macroDirectory = "\${templateDirectory}macros/"; # The scoring directory contains files used by the scoring programs. These # files contain scoring information for the whole class and are used for # calculating semester grades, etc. \$scoringDirectory = "\${classDirectory}scoring/"; # The html directory contains the first page for the course (index.html), # course documentation, and also subdirectories (e.g. tmp/) # (e.g. tmp/) containing latex2html problems, gifs, etc. The webserver has # direct access to the html directory and the courseURL points to this # directory. \$htmlDirectory = "\${classDirectory}html/"; # The logs directory contains log fies, e.g. login.log, backup psvn # logs and logs of datamunger activity. \$logsDirectory = "\${classDirectory}logs/"; # This is the temp directory used by downloadPS, etc \$courseTempDirectory = "\${classDirectory}html/tmp/"; # The courseScripts directory contains perl scripts local to the course, # e.g. displauMacros.pl . If it is commented out, the macro files in # "\${mainDirectory}courseScripts/" are used by default. # \$courseScriptsDirectory = "\${classDirectory}courseScripts/"; # This is the URL of the course html directory. It points to the \$htmlDirectory # above and it should have been set up correctly by the course_webwork_setup.pl # script. See the documentatiom (run the script or read # .../docs/techdescription/settingupcourse.html). Note that the URL depends on # links in you webserver's htdocs directory and must end in a trailing directory # delimiter (/ for unix). \$htmlURL = "$HTML_URL"; # This is the URL of the course tmp directory. This is for temporary storage of # html files, images, etc that have to accessible to the webserver. This directory # contains the subdirectories l2h, gif, eps, and html (not the \${classDirectory}html # directory). All these subdirectories and their files will be recreated if deleted # (althought recreating l2h files is time consuminmg). The location of this directory # may be changed fast disk which is not backed up. \$courseTempURL = "\${htmlURL}tmp/"; # This is the classID, i.e the symbolic link (or directory) that points to the base # course directory. It appears in the courses subdirectory of the main WeBWorK system. \$classID = "$CLASS_ID"; # This is the name of the default classlist file which resides in the # templateDirectory. This default name is used when students change their # own email addresses and also to edit the classlist file over the web. \$classlistFilename = "\${classID}.lst"; # This is the name of the group and the numerical gid. (some) Files created by # the WeBWorK system will have their group set to "\$groupID". Normally this # group will contain the webserver, your loginID, and the loginID's of anyone # else who will creating and editing WeBWorK problems for your course. If you # are editing this file by hand and know the \$groupID but not the \$numericalGroupID, # ask your systems administrator or run course_webwork_setup.pl and look at the # webworkCourse.ph it produces. You may also be able to get this information by # looking at the group file usually: /etc/group # Finally, if you have set up a "demo" version, the "\$numericalGroupID" will be # set to -1 which means maintain the current (default) group. ENDCOURSETMP if ($file_creation_mode eq 'demo') { print COURSETMP <<"ENDCOURSETMP"; \$groupID = "$groupName"; \$numericalGroupID = -1; ## this sets the header file over riding the Global setting \$Global::SET_HEADER = "paperSetHeader.pg"; ENDCOURSETMP } else { print COURSETMP <<"ENDCOURSETMP"; \$groupID = "$groupName"; \$numericalGroupID = $gid; ## this sets the header file over riding the Global setting \$Global::SET_HEADER = "paperSetHeader.pg"; ## If uncommented, this sets the default mode for displayed problems ## over riding the Global setting. #\$htmlModeDefault = 'HTML_tth'; # The default mode for displayed problems # (either 'HTML','Latex2HTML', or 'HTML_tth') # This sets the default for grading multipart problems. The choices at present are # std_problem_grader or avg_problem_grader. The std_problem_grader gives credit for # a mutipart problem only if all parts are answers correctly. The avg_problem_grader # gives partial credit for a mutipart problems. \$PG_environment{PROBLEM_GRADER_TO_USE} = 'avg_problem_grader'; #\$PG_environment{PROBLEM_GRADER_TO_USE} = 'std_problem_grader'; # This allows or dissallows Destroy and Rebuild. Set to 0 or 1. If set to 1 a # professor can destroy and rebuild problems sets in one operation. This is very # convenient and powerful, but also very dangerous. Usually this is not allowed # in courses students are using. It is often set to 1 in a private course being # used only for developing problem sets. \$allowDestroyRebuildProbSets = 0; ENDCOURSETMP } if ($file_creation_mode eq 'demo') { print COURSETMP <<"ENDCOURSETMP"; ## File and Directory permissions ## These permissions over ride the permissions set in ## Global.pm ## e.g. S1-1521.sco in (base course directory)/DATA \$sco_files_permission = 0666; ## tie permissions (used in tie commands) ## The database, password, and permissions files ## always take their permissions from the Global ## vaiables below. The important keys file ## takes its permission from \$restricted_tie_permission. \$restricted_tie_permission = 0666; \$standard_tie_permission = 0666; ## webwork-database in (base course directory)/DATA \$webwork_database_permission = 0666; ## password in (base course directory)/DATA/.auth \$password_permission = 0666; ## permissions in (base course directory)/DATA/.auth \$permissions_permission = 0666; ## e.g. s1ful.csv in (base course directory)/scoring \$scoring_files_permission = 0666; ## e.g. s1bak1.csv in (base course directory)/scoring \$scoring_bak_files_permission = 0666; ## e.g. 8587l2h.log in (base course directory)/html/tmp/l2h \$l2h_logs_permission = 0666; ## e.g set1/ in (base course directory)/html/tmp/l2h \$l2h_set_directory_permission = 0777; ## e.g. 1-1082/ in (base course directory)/html/tmp/l2h/set1 \$l2h_prob_directory_permission = 0777; ## e.g. 1082output.html in (base course directory)/html/tmp/l2h/set1/1-1082 \$l2h_data_permission = 0777; ENDCOURSETMP } print COURSETMP <<"ENDCOURSETMP"; ## This (if uncommented) overrides the setting in Global.pm. Use 'db_tie.pl' for the ## DB database and 'gdbm_tie.pl' for the GDBM database. For a "new" database type, ## you will have to write a 'newdb_tie.pl' file. These reside in the scripts directory. #\$Global::DBtie_file = 'db_tie.pl'; ## This tells WeBWorK where to find the file that connects it to a physical database. require "\${Global::scriptDirectory}\$Global::DBtie_file"; ## These are the file names for the various databases associated with this course. ## These names override the generic names given in Global.pm \$CL_Database = "\${classID}_classlist_DB"; \$passwordFilename = "\${classID}_password_DB"; \$permissionsFilename = "\${classID}_permissions_DB"; \$database = "\${classID}_webwork_DB"; # The following line is required by perl 1; ENDCOURSETMP close(COURSETMP); ############# END new webworkCourse.ph ######################### ###################### BEGIN new index.html ######################### open(INDEXTMP, ">index.html.tmp"); print INDEXTMP <<"ENDINDEXTMP"; Welcome to WeBWorK

WeBWorK Logo

WeBWorK Generic Course Login Page for $CLASS_ID


Log in as "practice" user

You may test out WeBWorK by logging in as a "practice" user. To begin, choose the login button below; Use practice1 as your login name and password.

For more information on WeBWorK: Webwork docs.


Last updated: 22 August 2000
${HTML_URL}index.html
ENDINDEXTMP close(INDEXTMP); ############# END new index.html ######################### #################### prompt for creating webworkCourse.ph ################# print "\n\n"; if (-e 'webworkCourse.ph') { if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "An old webworkCourse.ph exists. Do you want to create a new\n"; print "webworkCourse.ph and save the old file as webworkCourse.ph.bak1?\n"; print "If you answer y, and webworkCourse.ph.bak1 already exits, it\n"; print "will be saved as webworkCourse.ph.bak2. Only two backups are kept. (y or n)\n"; $ans=&getAns; } if ($ans eq 'y') { rename('webworkCourse.ph.bak1', 'webworkCourse.ph.bak2'); rename('webworkCourse.ph', 'webworkCourse.ph.bak1'); rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp"; chmod 0644, 'webworkCourse.ph'; } else { print "\nThe old webworkCourse.ph has not been changed. You can look\n"; print "at webworkCourse.ph.tmp to see what the new version would have been.\n"; } } else { if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "Do you want to create a webworkCourse.ph file (we recommmend that\n"; print "you do as it is required for WeBWorK to function)? (y or n)\n"; $ans=&getAns; } if ($ans eq 'y') { rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp. Fix the problem and run the setup script again. Stopped "; chmod 0644, 'webworkCourse.ph'; } else { print "\nA webworkCourse.ph file has not been created. You will need to\n"; print "create such a file. You can look at webworkCourse.ph.tmp to see\n"; print "what the file would have looked like.\n"; } } #################### prompt for creating index.html ################# print "\n\n"; if (-e 'html/index.html') { if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "An old index.html exists. Do you want to create a new\n"; print "index.html and save the old file as index.html.bak1\?\n"; print "If you answer y, and index.html.bak1 already exits, it\n"; print "will be saved as index.html.bak2. Only two backups are kept. (y or n)\n"; $ans= &getAns; } if ($ans eq 'y') { rename('html/index.html.bak1', 'html/index.html.bak2'); rename('html/index.html', 'html/index.html.bak1'); rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped "; chmod 0644, 'html/index.html'; } else { print "\nThe old index.html has not been changed. You can look\n"; print "at index.html.tmp to see what the new version would have been.\n"; } } else { if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "Do you want to create an index.html file (we recommmend that\n"; print "you do as it is required for WeBWorK to function)? (y or n)\n"; $ans= &getAns; } if ($ans eq 'y') { rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped "; chmod 0644, 'html/index.html'; } else { print "\nA index.html file has not been created. You will need to\n"; print "create such a file. You can look at index.html.tmp to see\n"; print "what the file would have looked like.\n"; } } ################### Prompt to change the group ########################## if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print qq{ Do you want to set the group for all directories and files\? It is highly recommended that you do so. Note that the default permissions for "working" version assumes the webserver is in the group. (y or n) }; $ans= &getAns; } { ## bare block to make breaking out easy if ($ans eq 'y') { chown(-1, $gid, '.'); chown(-1, $gid, <*>); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); chown(-1, $gid, ); print qq(\n The group has been set to "$groupName"\n\n); } } ##end of bare block ######################### Prompt file permission changes ###################### if ($course_setup_mode eq 'demo') {$ans = 'y';} else { print "\n\n\n\n"; print qq( Do you want to set default "$course_setup_mode" permissions for all directories and files\? It is highly recommended that you do so. The default permissions for a "working" version assume the webserver is in the group. Set permissions\? (y or n) ); $ans= &getAns; } if ($ans eq 'y') {if ($course_setup_mode eq "demo") { ####demo mode chmod(0755, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped "; chmod(0755, <*.pl>); ## perl files chmod(0644, <*.ph>); ## ph files chmod(0777, 'scoring') || die "Can't set permissions correctly for scoring directory. Fix the problem and run the setup script again. Stopped "; chmod(0666, ) ; # files in scoring - 600, there may be no files chmod(0777, 'logs') || die "Can't set permissions correctly for logs directory. Fix the problem and run the setup script again. Stopped "; chmod(0666, ) ; # files in logs - 660, there may be no files chmod(0777, 'DATA') || die "Can't set permissions correctly for DATA directory. Fix the problem and run the setup script again. Stopped "; chmod(0666, ) ; # files in DATA - 660, there may be no files chmod(0777, 'DATA/.auth') || die "Can't set permissions correctly for DATA/.auth directory. Fix the problem and run the setup script again. Stopped "; chmod(0666, ) ; # files in DATA/.auth - 660, there may be no files chmod(0755, 'html') || die "Can't set permissions correctly for html directory. Fix the problem and run the setup script again. Stopped "; # html subdir - 750 chmod(0644, ) ; 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 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 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 chmod(0777, ); # html/tmp/l2h/ subdir - 775 chmod(0777, ) ; # html/tmp/l2h/ subdir - 775 chmod(0777, ) ; # html/tmp/l2h/ subdir - 775 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 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 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 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 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 chmod(0755, ) ; 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 chmod(0777, ) ; # files and directories in templates - 777, there may be no files chmod(0777, ) ; # files and directories in templates - 777, there may be no files chmod(0777, ) ; # files and directories in templates - 777, there may be no files 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 chmod(0755, ) ; # files in templates/macros - 640, there may be no files print "\n Permissions set to default values.\n"; } else #####working mode { chmod(0750, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped "; chmod(0750, <*.pl>); ## perl files chmod(0640, <*.ph>); ## ph files chmod(0770, 'scoring') || die "Can't set permissions correctly for scoring directory. Fix the problem and run the setup script again. Stopped "; chmod(0660, ) ; # files in scoring - 600, there may be no files chmod(0770, 'logs') || die "Can't set permissions correctly for logs directory. Fix the problem and run the setup script again. Stopped "; chmod(0660, ) ; # files in logs - 660, there may be no files chmod(0770, 'DATA') || die "Can't set permissions correctly for DATA directory. Fix the problem and run the setup script again. Stopped "; chmod(0660, ) ; # files in DATA - 660, there may be no files chmod(0770, 'DATA/.auth') || die "Can't set permissions correctly for DATA/.auth directory. Fix the problem and run the setup script again. Stopped "; chmod(0660, ) ; # files in DATA/.auth - 660, there may be no files chmod(0750, 'html') || die "Can't set permissions correctly for html directory. Fix the problem and run the setup script again. Stopped "; # html subdir - 750 chmod(0640, ) ; 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 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 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 chmod(0770, ); # html/tmp/l2h/ subdir - 775 chmod(0770, ) ; # html/tmp/l2h/ subdir - 775 chmod(0770, ) ; # html/tmp/l2h/ subdir - 775 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 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 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 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 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 chmod(0750, ) ; 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 chmod(0770, ) ; # files and directories in templates - 770, there may be no files chmod(0770, ) ; # files and directories in templates - 770, there may be no files chmod(0770, ) ; # files and directories in templates - 770, there may be no files 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 chmod(0750, ) ; # files in templates/macros - 640, there may be no files print "\n Permissions set to default values.\n"; } } if (-e 'DATA/.auth/keys') { 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"; } print qq{ The WeBWorK Course setup script has finished. In order to complete the setup, please continue reading the instructions about: 1) using chmod g+xs to set the group setid properly. 2) running import_classlist-database.pl in order to set up the classlist, password and permissions databases. 3) running setProfPermissions.pl in order to give someone (probably yourself) professor privileges. 4) building problem sets (initially just go to the professor's page and click on 'Enter Build Problem set Page). }; sub check_URL { my ($name_URL,$var_URL) = @_; my $response = 'y'; while ($response eq 'y') { if (($var_URL =~ m|^/|) or ($var_URL =~ m|^http://|)) { $response = 'n'; } else { print qq{\nThe $name_URL you entered, $var_URL , does not begin with either \n a slash (/) or with http:// . This is almost certainly an error. \n Do you want to enter the $name_URL again? (y or n)}; $response =&getAns; if ($response ne 'n') { print "\n Enter the $name_URL:\n"; $var_URL=; chomp($var_URL); $response = 'y'; } else { $response = 'n'; } } } $var_URL; }