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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 23 Revision 24
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2# change the above line to point to the perl program
3 2
4################################################################################ 3# WeBWorK
5# system_webwork_setup.pl
6# 4#
7# This file changes the permissions to the correct ones in each of the 5# Copyright (c) 1995-2001 The Board of Trustees of the University of Rochester
8# subdirectories and the main course directory. It also modifies Global.pm and 6# All rights reserved
9# the various perl scripts.
10# 7#
11# $Id$ 8# $Id$
12################################################################################
13 9
14#################### initialization 10#################### initialization
15 11
16require 5.000; 12require 5.000;
17use strict;
18
19use Cwd; 13use Cwd;
20use File::Copy; 14use File::Copy;
21 15
22# define built-in defaults 16# define built-in defaults
23my $DEFAULT_PERL_PATH = '/usr/bin/perl'; 17my $DEFAULT_PERL_PATH = '/usr/bin/perl';
28my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL'; 22my $CGI_DEBUG_TAG = 'WeBWorKCGIDebugURL';
29my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL'; 23my $CGI_NODEBUG_TAG = 'WeBWorKCGINoDebugURL';
30my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine'; 24my $LIB_INIT_LINE_TAG = 'WeBWorKInitLine';
31 25
32# scope and undefine setup variables 26# scope and undefine setup variables
33our $no_prompts = undef; 27$no_prompts = undef;
34our $system_setup_mode = undef; 28$system_setup_mode = undef;
35our $mainDir = undef; 29$mainDir = undef;
36our $perlPath = undef; 30$perlPath = undef;
37our $cgiURL = undef; 31$cgiURL = undef;
38our $htmlURL = undef; 32$htmlURL = undef;
39our $groupName = undef; 33$groupName = undef;
40our $update_stuff_in_courses = undef; 34$update_stuff_in_courses = undef;
41our $chgrp_files_and_dirs = undef; 35$chgrp_files_and_dirs = undef;
42our $chmod_files_and_dirs = undef; 36$chmod_files_and_dirs = undef;
43our $local_preprocessor = undef; 37$local_preprocessor = undef;
44our $local_postprocessor = undef; 38$local_postprocessor = undef;
45 39
46# read defaults in from defaults file 40# read defaults in from defaults file
47my $DEFAULTS_FILE; 41my $DEFAULTS_FILE;
48if($ARGV[0]) { $DEFAULTS_FILE = $ARGV[0]; } 42if($ARGV[0]) { $DEFAULTS_FILE = $ARGV[0]; }
49else { $DEFAULTS_FILE = ((getpwuid $<)[7]) . '/system_webwork_setup.defaults'; } 43else { $DEFAULTS_FILE = ((getpwuid $<)[7]) . '/system_webwork_setup.defaults'; }
292 my $validGroup = 0; 286 my $validGroup = 0;
293 while(1) { 287 while(1) {
294 $groupName = questionString("What is the admin group name?", $userGroupName); 288 $groupName = questionString("What is the admin group name?", $userGroupName);
295 my @members = split / /, (getgrnam $groupName)[3]; 289 my @members = split / /, (getgrnam $groupName)[3];
296 if($groupName eq $userGroupName) { 290 if($groupName eq $userGroupName) {
297 print "$groupName is $userName's primary group. Good.\n"; 291 print "$groupName is ${userName}'s primary group. Good.\n";
298 } elsif(grep /$userName/, @members) { 292 } elsif(grep /$userName/, @members) {
299 print "$userName is a member of $groupName. Good.\n"; 293 print "$userName is a member of $groupName. Good.\n";
300 last; 294 last;
301 } elsif($< == 0) { # we're root! 295 } elsif($< == 0) { # we're root!
302 print "$userName isn't a member of $groupName, but you're root, so who cares?\n"; 296 print "$userName isn't a member of $groupName, but you're root, so who cares?\n";
544} 538}
545 539
546#################### run local postprocessor 540#################### run local postprocessor
547 541
548if(defined $local_postprocessor) { 542if(defined $local_postprocessor) {
549 print "Executing local preprocessor...\n"; 543 print "Executing local postprocessor...\n";
550 &$local_postprocessor; 544 &$local_postprocessor;
551 print "Done with local preprocessor.\n"; 545 print "Done with local postprocessor.\n";
552} 546}
553 547
554#################### finish up 548#################### finish up
555 549
556page($DONE_TEXT); 550page($DONE_TEXT);
561{ 555{
562 my @string_lines = split /^/, shift; #/ 556 my @string_lines = split /^/, shift; #/
563 # not really optimal, but we're going to assume a constant screen height. 557 # not really optimal, but we're going to assume a constant screen height.
564 my $SCREEN_HEIGHT = 20; 558 my $SCREEN_HEIGHT = 20;
565 while(@string_lines) { 559 while(@string_lines) {
566 print join "", @string_lines[0..$SCREEN_HEIGHT-1]; 560 print join "", @string_lines[0..($SCREEN_HEIGHT>scalar @string_lines ? (scalar @string_lines)-1 : $SCREEN_HEIGHT-1)];
567 if(scalar @string_lines >= $SCREEN_HEIGHT) { 561 if(scalar @string_lines >= $SCREEN_HEIGHT) {
568 print "\n[Press ENTER to continues...]"; 562 print "\n[Press ENTER to continues...]";
569 <STDIN>; 563 <STDIN>;
570 print "\n"; 564 print "\n";
571 } 565 }
603 chomp $answer; 597 chomp $answer;
604 $answer =~ s/^\s*//; 598 $answer =~ s/^\s*//;
605 $answer or $answer = $default; 599 $answer or $answer = $default;
606 return $answer; 600 return $answer;
607} 601}
602
603__END__
604
605=head1 NAME
606
607system_webwork_setup.pl - set up the WeBWorK system
608
609=head1 SYNOPSIS
610
611system_webwork_setup.pl [defaults-file]
612
613=head1 DESCRIPTION
614
615B<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>.
616
617=head1 DEFAULTS
618
619The 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:
620
621=over 4
622
623=item $no_prompts
624
625Refrain from prompting at the beginning of the script and before making changes. Also supresses the introductory text.
626
627=item $system_setup_mode
628
629Can 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.
630
631=item $mainDir
632
633Specify WeBWorK's main directory, which should contain the directories cgi/ scripts/ courseScripts/ and lib/.
634
635=item $perlPath
636
637Specify the path to the perl interpreter which should be used. This is used to set the shebang line in cgi-scripts and scripts.
638
639=item $cgiURL
640
641Specify the externally visible URL to the CGI directory (typically cgi/cgi-scripts/). This will be used when scripts call other scripts.
642
643=item $htmlURL
644
645Specify the externally visible URL to the HTML directory (typically system_html/). This will be used when scripts refer to static graphics and text.
646
647=item $groupName
648
649When 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!)
650
651=item $update_stuff_in_courses
652
653If true, B<system_webwork_setup.pl> will set permissions in the courses directory and prepare the B<course_webwork_setup.pl> script for execution.
654
655=item $chgrp_files_and_dirs, $chmod_files_and_dirs
656
657If true, the group and/or permissions on system files will be set according to I<$system_setup_mode>.
658
659=item $local_preprocessor, $local_postprocessor
660
661If 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.
662
663=back
664
665=head FILES
666
667$HOME/system_webwork_setup.defaults
668
669=head1 AUTHOR
670
671Samuel Hathaway <sh002i@math.rochester.edu>

Legend:
Removed from v.23  
changed lines
  Added in v.24

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9