Diff for /doc/loncapafiles/updatequery.piml between versions 1.41 and 1.46

version 1.41, 2005/08/15 17:53:33 version 1.46, 2006/01/28 10:35:02
Line 129  END Line 129  END
 $|=1;  $|=1;
 my $domainDescription;  my $domainDescription;
 my $domainTabExtras;  my $domainTabExtras;
   my $primaryLibServer;
   my @libservers = ();
 unless (-e "<TARGET />") {  unless (-e "<TARGET />") {
   print(&lt;&lt;END);    print(&lt;&lt;END);
            WELCOME TO LON-CAPA!             WELCOME TO LON-CAPA!
Line 205  if ($hostname=~/([^\.]*)\.([^\.]*)$/) { Line 207  if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
   
 **** Domain ****  **** Domain ****
 [this does NOT need to correspond to internet address domains,  [This does NOT need to correspond to internet address domains.
  good examples might be "msu" or "bionet" or "vermontcc",   Please make this name short AND descriptive of your organization.
  bad examples are "physics" (too general)   Domain names are close to impossible to change later!!!
    Good examples might be "msu" or "bionet" or "vermontcc".
    Bad examples are "physics" (too general)
    or "michiganstateuniversity" (too long)     or "michiganstateuniversity" (too long)
    or "msuedu" (internet domain, just make it "msu")     or "msuedu" (internet domain, just make it "msu")
    or "msuphysics" (only if there is a good reason to limit)     or "msuphysics" (only if there is a good reason to limit to department
                       - we don't know of one)
    or "mydomain" (what is that?)     or "mydomain" (what is that?)
  Please make this name short AND descriptive of your organization.   Avoid multiple domains at the same institution, even if it means that you 
  Note that the domain is very hard to change later.   have to actually work together with your colleagues. You can still run
  Double-check with the LON-CAPA group at MSU if this domain is    multiple library servers within the same domain.
  going to be part of the main production cluster, since it needs   If this domain is eventually going to be part of the main production
  to be unique.]   cluster, you MUST contact the LON-CAPA group at MSU (loncapa@loncapa.org)
    to have a domain name assigned, and then use it exactly as given. This is
    also true for test installs that might eventually turn into production setups.
    Stop now if you didn't do so.]
 END  END
   
 # get domain name  # get domain name
Line 308  if ($lonDefDomain) { Line 316  if ($lonDefDomain) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
   
 **** Machine ID Name ****  **** Machine ID Name ****
 [this does NOT need to correspond to internet address names;  [This does NOT need to correspond to internet address names;
  this name MUST be unique to the whole LON-CAPA network;   this name MUST be unique to the whole LON-CAPA network;
  we recommend that you use a name based off of your institution;   we recommend that you use a name based off of your institution.
  good examples: "msul1" or "bioneta2";   Good examples: "msul1" or "bioneta2".
  bad examples: "loncapabox" or "studentsinside".   Bad examples: "loncapabox" or "studentsinside".
  Note that machine names are very hard to change later.]   Note that machine names are very hard to change later.]
 END  END
 # get machine name  # get machine name
Line 355  END Line 363  END
   }    }
 }  }
   
   # get primary library server in domain
   if ($lonRole eq 'library') {
       if (!grep/^\Q$lonHostID\E$/,@libservers) {
           push(@libservers,$lonHostID);
       } 
       if (@libservers == 1) {
           $primaryLibServer = $libservers[0];
       }
   }
   while (!$flag) {
     print(&lt;&lt;END);
   **** Domain's Primary Library Server ID ****
   This should be the LON-CAPA machine ID of a library server in your 
   domain.  If you only have a single library server in your domain, then
   the Primary Library server ID will be the machine ID of that server. 
   This server will be where domain data which are not associated with any
   specific home library server will be stored (e.g., e-mail broadcast by
   administrators to users in the domain).
   END
       if (defined($primaryLibServer)) {
           print(&lt;&lt;END);
   ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:
   END
       } elsif (@libservers > 0) {
           print(&lt;&lt;END);
   ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]]
   END
       } else {
           print (&lt;&lt;END);
   No library servers could be identified for this domain.  If you have already installed LON-CAPA on a different server (designated as a library server) in this domain, please enter the LONCAPA MACHINE ID of that server.  If not, you will need to install a LON-CAPA library server.  Enter the MACHINE ID of the server you plan to designate as a library server.
   END
       }
   
       my $choice=&lt;&gt;;
       chomp($choice);
       if ($primaryLibServer and $choice=~/^\s*$/) {
           $choice=$primaryLibServer;
           open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
           print(OUT 'primaryLibServer'."\t".$choice."\n");
           close(OUT);
           $flag=1;
       } elsif (length($choice)>15) {
           print "Name too long\n";
       } elsif (length($choice)<4) {
           print "Name too short\n";
       } elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
           open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
           print(OUT 'primaryLibServer'."\t".$choice."\n");
           close(OUT);
           $primaryLibServer=$choice;
           $flag=1;
       } else {
           print "Invalid input (only alphanumeric characters supported).\n";
       }
   }
   
   
 # get admin e-mail address  # get admin e-mail address
 # accept if valid, if not valid, tell user and repeat  # accept if valid, if not valid, tell user and repeat
 $flag=0;  $flag=0;
Line 547  my %perlvarstatic; Line 612  my %perlvarstatic;
      (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);       (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
      chomp($domainDescription);       chomp($domainDescription);
      chomp($domainTabExtras);       chomp($domainTabExtras);
        # the remianing field (primary lib server) is handled later
        $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
              last;               last;
           }            }
        }         }
Line 559  my %perlvarstatic; Line 626  my %perlvarstatic;
      (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);       (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
      chomp($domainDescription);       chomp($domainDescription);
      chomp($domainTabExtras);       chomp($domainTabExtras);
        # the remianing field (primary lib server) is handled later
        $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0-5]);
              last;               last;
           }            }
        }         }
        close(IN);         close(IN);
     }      }
       if (!$primaryLibServer and $lonCluster ne 'existing') {
           open(IN,'&lt;../'.$lonCluster.'_domain.tab');
           while(&lt;IN&gt;) {
               if (/^$perlvar{'lonDefDomain'}\:/) {
                   (undef,undef,undef,undef,undef,undef,undef,undef,
                                                 $primaryLibServer)=split(/:/,$_);
                   chomp($primaryLibServer);
               }
           }
           close(IN);
           if (!$primaryLibServer) {
               open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
               while(&lt;IN&gt;) {
                   if (/^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                       push(@libservers,$1);
                   }
               }
               close(IN);
               if (@libservers == 1) {
                   $primaryLibServer = $libservers[0];
               }
           }
       }
       if (!$primaryLibServer) {
           open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
           while(&lt;IN&gt;) {
               if (/^$perlvar{'lonDefDomain'}\:/) {
                   (undef,undef,undef,undef,undef,undef,undef,undef,
                                                 $primaryLibServer)=split(/:/,$_);
                   chomp($primaryLibServer);
               }
               close(IN);
           }
           if (!$primaryLibServer) {
               open(IN,'&lt;/home/httpd/lonTabs/hosts.tab');
               while(&lt;IN&gt;) {
                   if (/^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                       push(@libservers,$1);
                   }
               }
               close(IN);
               if (@libservers == 1) {
                   $primaryLibServer = $libservers[0];
               }
           }
       }
         
 # implement editing logic below, interactively  # implement editing logic below, interactively
 # update loncapa.conf until 8 is entered  # update loncapa.conf until 12 is entered
   
 $flag=0;  $flag=0;
   
Line 578  This is now the current configuration of Line 693  This is now the current configuration of
  1) Domain Name: $perlvar{'lonDefDomain'}   1) Domain Name: $perlvar{'lonDefDomain'}
  2) Domain Description: $domainDescription   2) Domain Description: $domainDescription
  3) Machine Name: $perlvar{'lonHostID'}   3) Machine Name: $perlvar{'lonHostID'}
  4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}   4) ID of primary library server for domain: $primaryLibServer
  5) Support E-mail Address: $perlvar{'lonSupportEMail'}   5) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  6) Role: $perlvar{'lonRole'}   6) Support E-mail Address: $perlvar{'lonSupportEMail'}
  7) Cache Expiration Time: $perlvar{'lonExpire'}   7) Role: $perlvar{'lonRole'}
  8) Server Load: $perlvar{'lonLoadLim'}   8) Cache Expiration Time: $perlvar{'lonExpire'}
  9) User Load: $perlvar{'lonUserLoadLim'}   9) Server Load: $perlvar{'lonLoadLim'}
 10) Allow only secure connections: $securestatus   10) User Load: $perlvar{'lonUserLoadLim'}
 11) Everything is correct up above  11) Allow only secure connections: $securestatus 
   12) Everything is correct up above
 END  END
   
 my $error='';  my $error='';
Line 604  foreach my $v ($perlvar{'lonDefDomain'}, Line 720  foreach my $v ($perlvar{'lonDefDomain'},
    }     }
    if ($v=~/\W/) { $error.="\nName $v contains special characters"; }     if ($v=~/\W/) { $error.="\nName $v contains special characters"; }
 }  }
 if ($domainDescription!~/^[\(\)\-\w\s]+$/) {  if ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
    $error.="\nDomain Description contains special characters";     $error.="\nDomain Description contains special characters";
 }   } 
 foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {  foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
Line 613  foreach my $v ($perlvar{'lonExpire'},$pe Line 729  foreach my $v ($perlvar{'lonExpire'},$pe
 unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {  unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
    $error.="\nInvalid Role";     $error.="\nInvalid Role";
 }  }
   
   if (!defined($primaryLibServer)) {
      if (@libservers > 0) {
          $error .= "No primary library server ID designated. Choose from: ".join(',',sort(@libservers));
      } else {
          $error .= "No library servers in this domain (including current server)";
      }
   } else {
      if (length($primaryLibServer)>16) { $error.="\nPrimary Library Server ID:  $primaryLibServer too long"; }
      if (length($primaryLibServer)<2) { $error.="\nPrimary Library Server ID:  $primaryLibServer too short"; }
      if ($primaryLibServer =~/capa/i) {
           if ($primaryLibServer!~/^oucapa\d+$/ &&
               ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
                    $error.="\nPrimary library server ID $primaryLibServer contains 'capa'";
           }
      }
      foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
           'editupload') {
         $error.="\nPrimary library server ID $primaryLibServer reserved." if $primaryLibServer eq $bad;
      }
      if ($primaryLibServer=~/\W/) { $error.="\nPrimary library server ID $primaryLibServer contains special characters"; }
   }
   
   
 if ($error) { print "\n*** ERRORS: $error\n"; }  if ($error) { print "\n*** ERRORS: $error\n"; }
   print(&lt;&lt;END);    print(&lt;&lt;END);
 ENTER A CHOICE OF 1-10 TO CHANGE, otherwise ENTER 11:  ENTER A CHOICE OF 1-11 TO CHANGE, otherwise ENTER 12:
 END  END
 my $choice=&lt;&gt;;  my $choice=&lt;&gt;;
 chomp($choice);  chomp($choice);
Line 655  END Line 795  END
   }    }
   elsif ($choice==4) {    elsif ($choice==4) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}  4) ID of primary library server for domain: $primaryLibServer
   ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
                    your domain; it cannot contain any of '_' '-' '.' or ':'. 
                    This server will be where domain data which are not 
                    associated with any specific home library server
                    will be stored (e.g., e-mail broadcast by Domain Coordinators
                    to users in the domain).
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $primaryLibServer=$choice2;
     }
     elsif ($choice==5) {
     print(&lt;&lt;END);
   5) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
 ENTER NEW VALUE:  ENTER NEW VALUE:
 END  END
     my $choice2=&lt;&gt;;      my $choice2=&lt;&gt;;
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonAdmEMail'}=$choice2;      $perlvar{'lonAdmEMail'}=$choice2;
   }    }
   elsif ($choice==5) {    elsif ($choice==6) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 5) Support E-mail Address: $perlvar{'lonSupportEMail'}  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
 ENTER NEW VALUE:  ENTER NEW VALUE:
 END  END
     my $choice2=&lt;&gt;;      my $choice2=&lt;&gt;;
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonSupportEMail'}=$choice2;      $perlvar{'lonSupportEMail'}=$choice2;
   }    }
   elsif ($choice==6) {    elsif ($choice==7) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 6) Role: $perlvar{'lonRole'}  7) Role: $perlvar{'lonRole'}
 ENTER NEW VALUE (this should be either 'access' or 'library'   ENTER NEW VALUE (this should be either 'access' or 'library' 
                  if in doubt select 'library'):                   if in doubt select 'library'):
 END  END
Line 681  END Line 835  END
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonRole'}=$choice2;      $perlvar{'lonRole'}=$choice2;
   }    }
   elsif ($choice==7) {    elsif ($choice==8) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 7) Cache Expiration Time: $perlvar{'lonExpire'}  8) Cache Expiration Time: $perlvar{'lonExpire'}
 ENTER NEW VALUE (in seconds, 86400 is a reasonable value):  ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
 END  END
     my $choice2=&lt;&gt;;      my $choice2=&lt;&gt;;
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonExpire'}=$choice2;      $perlvar{'lonExpire'}=$choice2;
   }    }
   elsif ($choice==8) {    elsif ($choice==9) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 8) Server Load: $perlvar{'lonLoadLim'}  9) Server Load: $perlvar{'lonLoadLim'}
 ENTER NEW VALUE:  ENTER NEW VALUE:
 END  END
     my $choice2=&lt;&gt;;      my $choice2=&lt;&gt;;
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonLoadLim'}=$choice2;      $perlvar{'lonLoadLim'}=$choice2;
   }    }
   elsif ($choice==9) {    elsif ($choice==10) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 9) User Load: $perlvar{'lonUserLoadLim'}  10) User Load: $perlvar{'lonUserLoadLim'}
 Numer of users that can login before machine is 'overloaded'  Numer of users that can login before machine is 'overloaded'
 ENTER NEW VALUE (integer value, 0 means there is no limit):  ENTER NEW VALUE (integer value, 0 means there is no limit):
 END  END
Line 709  END Line 863  END
     chomp($choice2);      chomp($choice2);
     $perlvar{'lonUserLoadLim'}=$choice2;      $perlvar{'lonUserLoadLim'}=$choice2;
   }    }
   elsif ($choice==10) {    elsif ($choice==11) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
 10) Allow only secure connections: $securestatus   11) Allow only secure connections: $securestatus 
 The Lon-CAPA communication daemons lonc and lond can be configured to  The Lon-CAPA communication daemons lonc and lond can be configured to
 allow only secure connections by default.  allow only secure connections by default.
   
Line 738  END Line 892  END
     }      }
     ($securestatus,$securenum)=&securesetting(%perlvar);      ($securestatus,$securenum)=&securesetting(%perlvar);
   }    }
   elsif (($choice==11) && (!$error)) {    elsif (($choice==12) && (!$error)) {
     $flag=1;      $flag=1;
   }    }
   else {    else {
Line 769  unless (-l "<TARGET />") { Line 923  unless (-l "<TARGET />") {
   $line2insert=&lt;&lt;END;    $line2insert=&lt;&lt;END;
 $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname  $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
 END  END
   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";    $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
   if ($lonCluster eq 'standalone') {    if ($lonCluster eq 'standalone') {
     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or      open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
       die('file generation error');        die('file generation error');

Removed from v.1.41  
changed lines
  Added in v.1.46


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>