[LON-CAPA-cvs] cvs: doc /loncapafiles updatequery.piml

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 09 Dec 2005 00:53:54 -0000


This is a MIME encoded message

--raeburn1134089634
Content-Type: text/plain

raeburn		Thu Dec  8 19:53:54 2005 EDT

  Modified files:              
    /doc/loncapafiles	updatequery.piml 
  Log:
  Allow primary library server to be specified for domain. 
  
  
--raeburn1134089634
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20051208195354.txt"

Index: doc/loncapafiles/updatequery.piml
diff -u doc/loncapafiles/updatequery.piml:1.42 doc/loncapafiles/updatequery.piml:1.43
--- doc/loncapafiles/updatequery.piml:1.42	Wed Oct 26 15:38:15 2005
+++ doc/loncapafiles/updatequery.piml	Thu Dec  8 19:53:54 2005
@@ -1,6 +1,6 @@
 <!-- updatequery.piml -->
 
-<!-- $Id: updatequery.piml,v 1.42 2005/10/26 19:38:15 albertel Exp $ -->
+<!-- $Id: updatequery.piml,v 1.43 2005/12/09 00:53:54 raeburn Exp $ -->
 
 <!--
 
@@ -129,6 +129,8 @@
 $|=1;
 my $domainDescription;
 my $domainTabExtras;
+my $primaryLibServer;
+my @libservers = ();
 unless (-e "<TARGET />") {
   print(&lt;&lt;END);
            WELCOME TO LON-CAPA!
@@ -355,6 +357,63 @@
   }
 }
 
+# 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
 # accept if valid, if not valid, tell user and repeat
 $flag=0;
@@ -564,6 +623,53 @@
        }
        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];
+            }
+        }
+    }
+    $primaryLibServer = '';
    
 # implement editing logic below, interactively
 # update loncapa.conf until 8 is entered
@@ -578,14 +684,15 @@
  1) Domain Name: $perlvar{'lonDefDomain'}
  2) Domain Description: $domainDescription
  3) Machine Name: $perlvar{'lonHostID'}
- 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
- 5) Support E-mail Address: $perlvar{'lonSupportEMail'}
- 6) Role: $perlvar{'lonRole'}
- 7) Cache Expiration Time: $perlvar{'lonExpire'}
- 8) Server Load: $perlvar{'lonLoadLim'}
- 9) User Load: $perlvar{'lonUserLoadLim'}
-10) Allow only secure connections: $securestatus 
-11) Everything is correct up above
+ 4) ID of primary library server for domain: $primaryLibServer
+ 5) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
+ 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
+ 7) Role: $perlvar{'lonRole'}
+ 8) Cache Expiration Time: $perlvar{'lonExpire'}
+ 9) Server Load: $perlvar{'lonLoadLim'}
+10) User Load: $perlvar{'lonUserLoadLim'}
+11) Allow only secure connections: $securestatus 
+12) Everything is correct up above
 END
 
 my $error='';
@@ -613,9 +720,33 @@
 unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
    $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"; }
   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
 my $choice=&lt;&gt;;
 chomp($choice);
@@ -655,25 +786,39 @@
   }
   elsif ($choice==4) {
   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:
 END
     my $choice2=&lt;&gt;;
     chomp($choice2);
     $perlvar{'lonAdmEMail'}=$choice2;
   }
-  elsif ($choice==5) {
+  elsif ($choice==6) {
   print(&lt;&lt;END);
-5) Support E-mail Address: $perlvar{'lonSupportEMail'}
+6) Support E-mail Address: $perlvar{'lonSupportEMail'}
 ENTER NEW VALUE:
 END
     my $choice2=&lt;&gt;;
     chomp($choice2);
     $perlvar{'lonSupportEMail'}=$choice2;
   }
-  elsif ($choice==6) {
+  elsif ($choice==7) {
   print(&lt;&lt;END);
-6) Role: $perlvar{'lonRole'}
+7) Role: $perlvar{'lonRole'}
 ENTER NEW VALUE (this should be either 'access' or 'library' 
                  if in doubt select 'library'):
 END
@@ -681,27 +826,27 @@
     chomp($choice2);
     $perlvar{'lonRole'}=$choice2;
   }
-  elsif ($choice==7) {
+  elsif ($choice==8) {
   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):
 END
     my $choice2=&lt;&gt;;
     chomp($choice2);
     $perlvar{'lonExpire'}=$choice2;
   }
-  elsif ($choice==8) {
+  elsif ($choice==9) {
   print(&lt;&lt;END);
-8) Server Load: $perlvar{'lonLoadLim'}
+9) Server Load: $perlvar{'lonLoadLim'}
 ENTER NEW VALUE:
 END
     my $choice2=&lt;&gt;;
     chomp($choice2);
     $perlvar{'lonLoadLim'}=$choice2;
   }
-  elsif ($choice==9) {
+  elsif ($choice==10) {
   print(&lt;&lt;END);
-9) User Load: $perlvar{'lonUserLoadLim'}
+10) User Load: $perlvar{'lonUserLoadLim'}
 Numer of users that can login before machine is 'overloaded'
 ENTER NEW VALUE (integer value, 0 means there is no limit):
 END
@@ -709,9 +854,9 @@
     chomp($choice2);
     $perlvar{'lonUserLoadLim'}=$choice2;
   }
-  elsif ($choice==10) {
+  elsif ($choice==11) {
   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
 allow only secure connections by default.
 
@@ -738,7 +883,7 @@
     }
     ($securestatus,$securenum)=&securesetting(%perlvar);
   }
-  elsif (($choice==11) && (!$error)) {
+  elsif (($choice==12) && (!$error)) {
     $flag=1;
   }
   else {
@@ -769,7 +914,7 @@
   $line2insert=&lt;&lt;END;
 $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
 END
-  $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
+  $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
   if ($lonCluster eq 'standalone') {
     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
       die('file generation error');

--raeburn1134089634--