[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 1081 Revision 1082
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3################################################################################ 3################################################################################
4# WeBWorK 4# WeBWorK
5# 5#
6# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester 6# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester
7# All rights reserved 7# All rights reserved
8# 8#
9# $Id$ 9# $Id$
10################################################################################ 10################################################################################
11 11
12#################### initialization 12#################### initialization
13 13
57my $INTRO_TEXT = q{ 57my $INTRO_TEXT = q{
58+----------------------+ 58+----------------------+
59| System Webwork Setup | 59| System Webwork Setup |
60+----------------------+ 60+----------------------+
61 61
62This script is used to setup the main WeBWorK system. It will create 62This script is used to setup the main WeBWorK system. It will create
63initialization files, set groups and permissions for files and directories, 63initialization files, set groups and permissions for files and directories,
64and modify files. A "demo" or "working" version of the system can be setup. 64and modify files. A "demo" or "working" version of the system can be setup.
65 65
66You will need the following information: 66You will need the following information:
67 67
681) The location of your WeBWorK system directory. 681) The location of your WeBWorK system directory.
86 86
87}; 87};
88 88
89my $MODE_TEXT = q{ 89my $MODE_TEXT = q{
90 90
91You can set up a "working" or a "demo" WeBWorK system. A "demo" system 91You can set up a "working" or a "demo" WeBWorK system. A "demo" system
92should only be used as a sample system, never for a system that will be used 92should only be used as a sample system, never for a system that will be used
93with actual courses with real students. The main difference between a 93with actual courses with real students. The main difference between a
94"working" version and a "demo" version is that in a "working" version you 94"working" version and a "demo" version is that in a "working" version you
95will be promped to enter a group (e.g. wwadmin) where as in a "demo" 95will be promped to enter a group (e.g. wwadmin) where as in a "demo"
96version, the group will be set yo your own default group (e.g. fac). Anyone 96version, the group will be set yo your own default group (e.g. fac). Anyone
97in the group will have permission to modify all webwork files. You can set 97in the group will have permission to modify all webwork files. You can set
98up "working" and "demo" courses under either a "working" or a "demo" system, 98up "working" and "demo" courses under either a "working" or a "demo" system,
99but normally you would not set up a "working" course under a "demo" system. 99but normally you would not set up a "working" course under a "demo" system.
100 100
101}; 101};
102 102
103my $MAIN_DIR_TEXT = q{ 103my $MAIN_DIR_TEXT = q{
137 137
138}; 138};
139 139
140my $GROUP_TEXT = q{ 140my $GROUP_TEXT = q{
141 141
142WeBWorK needs to know what the admin group is. This group should have been 142WeBWorK needs to know what the admin group is. This group should have been
143set up by your system administrator and must contain at least your user ID. 143set up by your system administrator and must contain at least your user ID.
144All files and directories created will have this as their group. 144All files and directories created will have this as their group.
145 145
146}; 146};
147 147
148my $COURSE_PERMS_TEXT = q{ 148my $COURSE_PERMS_TEXT = q{
149 149
150You have the option to set permissions for the courses directory. If this is 150You have the option to set permissions for the courses directory. If this is
151an inital setup, you should probably do so. If this is not an initial setup, 151an inital setup, you should probably do so. If this is not an initial setup,
152the courses directory is already set up, or the courses directory is shared 152the courses directory is already set up, or the courses directory is shared
153between WeBWorK installations, your probably shouldn't. 153between WeBWorK installations, your probably shouldn't.
154 154
155}; 155};
156 156
157my $CHGRP_TEXT = q{ 157my $CHGRP_TEXT = q{
158 158
159You have to option to set the group for all system files and directories. If 159You have to option to set the group for all system files and directories. If
160this is an initial setup, you should probably do this. If this is not an 160this is an initial setup, you should probably do this. If this is not an
161initial setup, or you have customized the way system files should be 161initial setup, or you have customized the way system files should be
162grouped, you probably shoudn't. 162grouped, you probably shoudn't.
163 163
164}; 164};
165 165
166my $CHMOD_TEXT = q{ 166my $CHMOD_TEXT = q{
167 167
168You have to option to set the permissions for all system files and 168You have to option to set the permissions for all system files and
169directories. If this is an initial setup, you should probably do this. If 169directories. If this is an initial setup, you should probably do this. If
170this is not an initial setup, or you have customized the permissions for the 170this is not an initial setup, or you have customized the permissions for the
171system files, you probably shoudn't. 171system files, you probably shoudn't.
172 172
173}; 173};
174 174
175my $CONFIRM_TEXT = q{ 175my $CONFIRM_TEXT = q{
176 176
177Now that I have the necessary information, I can begin modifying the WeBWorK 177Now that I have the necessary information, I can begin modifying the WeBWorK
178system files. 178system files.
179 179
180}; 180};
181 181
182my $DONE_TEXT = q{ 182my $DONE_TEXT = q{
274#################### admin group 274#################### admin group
275 275
276unless(defined $groupName) { 276unless(defined $groupName) {
277 my ($userName, $userGID) = (getpwuid $<)[0,3]; 277 my ($userName, $userGID) = (getpwuid $<)[0,3];
278 my $userGroupName = (getgrgid $userGID)[0]; 278 my $userGroupName = (getgrgid $userGID)[0];
279 279
280 if ($system_setup_mode eq 'demo') { 280 if ($system_setup_mode eq 'demo') {
281 # in demo mode, the group is set to the user's primary group 281 # in demo mode, the group is set to the user's primary group
282 $groupName = $userGroupName; 282 $groupName = $userGroupName;
283 } else { 283 } else {
284 # in working mode, we get to chose 284 # in working mode, we get to chose
379} 379}
380 380
381sub fixFile 381sub fixFile
382{ 382{
383 my ($file) = @_; 383 my ($file) = @_;
384 384
385 # read the file 385 # read the file
386 open FILE, $file || die "Couldn't open $file for reading."; 386 open FILE, $file || die "Couldn't open $file for reading.";
387 my @lines = <FILE>; 387 my @lines = <FILE>;
388 close FILE || die "Couldn't close $file after reading."; 388 close FILE || die "Couldn't close $file after reading.";
389 389
390 # fix perl path 390 # fix perl path
391 $lines[0] =~ m/^#!(\S*)/; 391 $lines[0] =~ m/^#!(\S*)/;
392 if($1 ne $perlPath) { 392 if($1 ne $perlPath) {
393 $lines[0] =~ s/^#!\S*/#!$perlPath/; 393 $lines[0] =~ s/^#!\S*/#!$perlPath/;
394 open FILE, ">$file" || die "Couldn't open $file for writing."; 394 open FILE, ">$file" || die "Couldn't open $file for writing.";
407print CONFIG_FILE<<END_OF_CONFIG_FILE; 407print CONFIG_FILE<<END_OF_CONFIG_FILE;
408package Global; 408package Global;
409 409
410################################################################################ 410################################################################################
411# WeBWorK 411# WeBWorK
412# 412#
413# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester 413# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester
414# All rights reserved 414# All rights reserved
415################################################################################ 415################################################################################
416 416
417# \$cgiDebugMode, if enabled, will call the debug wrapper scripts instead of the 417# \$cgiDebugMode, if enabled, will call the debug wrapper scripts instead of the
439foreach my $dir ('cgi/', 'cgi/cgi-scripts/', 'scripts/', 'courseScripts/') { 439foreach my $dir ('cgi/', 'cgi/cgi-scripts/', 'scripts/', 'courseScripts/') {
440 open INIT_FILE, ">$mainDir${dir}webworkInit.pm"; 440 open INIT_FILE, ">$mainDir${dir}webworkInit.pm";
441 print INIT_FILE<<END_OF_INIT_FILE; 441 print INIT_FILE<<END_OF_INIT_FILE;
442################################################################################ 442################################################################################
443# WeBWorK 443# WeBWorK
444# 444#
445# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester 445# Copyright (c) 1995-2001 WeBWorK Team, University of Rochester
446# All rights reserved 446# All rights reserved
447################################################################################ 447################################################################################
448 448
449use lib '${mainDir}lib/'; 449use lib '${mainDir}lib/';
459 459
460if($chgrp_files_and_dirs) { 460if($chgrp_files_and_dirs) {
461 print "Setting group on system files and directories...\n"; 461 print "Setting group on system files and directories...\n";
462 system "chgrp -R $groupName $mainDir"; 462 system "chgrp -R $groupName $mainDir";
463 system "chgrp -R $groupName $mainDir/../system_html"; 463 system "chgrp -R $groupName $mainDir/../system_html";
464 system "chgrp -R $groupName $mainDir/../pg";
464 print "Done setting group.\n\n"; 465 print "Done setting group.\n\n";
465} 466}
466 467
467#################### chmod system stuff 468#################### chmod system stuff
468# uses: $chmod_files_and_dirs 469# uses: $chmod_files_and_dirs
471 print "Setting permissions on system files and directories for $system_setup_mode mode...\n"; 472 print "Setting permissions on system files and directories for $system_setup_mode mode...\n";
472 if ($system_setup_mode eq "demo") { 473 if ($system_setup_mode eq "demo") {
473 # get some general permissions for files and directories 474 # get some general permissions for files and directories
474 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0755"; 475 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0755";
475 system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0644"; 476 system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0644";
477 system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0644";
476 # add executable privs to scripts 478 # add executable privs to scripts
477 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0755"; 479 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0755";
478 } else { 480 } else {
479 # get some general permissions for files and directories 481 # get some general permissions for files and directories
480 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0775"; 482 system "find $mainDir $mainDir/../system_html -type d -print | xargs chmod 0775";
481 system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0664"; 483 system "find $mainDir $mainDir/../system_html -type f -print | xargs chmod 0664";
484 system "find $mainDir $mainDir/../pg -type f -print | xargs chmod 0664";
482 # add executable privs to scripts 485 # add executable privs to scripts
483 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0775"; 486 system "find ${mainDir}cgi ${mainDir}scripts -type f -print | xargs chmod 0775";
484 } 487 }
485 # make the log files group writable 488 # make the log files group writable
486 system "find $mainDir/logs -type f -print | xargs chmod 0664"; 489 system "find $mainDir/logs -type f -print | xargs chmod 0664";
487 # make the error_log file world writable 490 # make the error_log file world writable
488 system "find $mainDir/logs/error_log -print | xargs chmod 0666"; 491 system "find $mainDir/logs/error_log -print | xargs chmod 0666";
489 492
490 print "done setting permissions.\n\n"; 493 print "done setting permissions.\n\n";
491} 494}

Legend:
Removed from v.1081  
changed lines
  Added in v.1082

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9