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