Diff for /doc/loncapafiles/updatequery.piml between versions 1.21 and 1.27

version 1.21, 2002/12/09 18:54:40 version 1.27, 2003/05/19 18:35:50
Line 1 Line 1
 <!-- updatequery.piml -->  <!-- updatequery.piml -->
 <!-- Scott Harrison -->  
   
 <!-- $Id$ -->  <!-- $Id$ -->
   
Line 52  sleep(3); Line 51  sleep(3);
 </perlscript>  </perlscript>
 </file>  </file>
 <file>  <file>
   <target dist='default'>loncom/hosts.tab</target>
   <perlscript mode='fg'>
   unless (-l "<TARGET />") {
     print(&lt;&lt;END);
   
   ===============================================================================
   What hosts.tab and domain.tab would you like to have installed?
   (hosts.tab is a listing of all other internet machines
   that a server system considers to be valid server systems
   on the LON-CAPA network
   domain.tab is a description of the internal LON-CAPA domains)
   
   1) PRODUCTION - you want to deliver courses today or sometime very soon
                   on this machine
   2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
                    not be connected to other LON-CAPA machines for now
   3) DEVELOPMENT - you want to play with or explore LON-CAPA
   4) PRESERVE the existing hosts.tab and domain.tab
                   (/home/httpd/lonTabs/hosts.tab and
                    /home/httpd/lonTabs/domain.tab)
   
   END
   # Option number 26 will install rawhide_hosts.tab, but
   # the typical user does not want to be part of an intensive
   # machine test cluster.
   
   # get input
   # if valid then process, otherwise loop
   $flag=0;
   while (!$flag) {
     print "ENTER 1, 2, 3, or 4:\n";
     my $choice=&lt;&gt;;
     chomp($choice);
     if ($choice==1) {
       $lonCluster='production'; $flag=1;
     }
     elsif ($choice==2) {
       $lonCluster='standalone'; $flag=1;
     }
     elsif ($choice==3) {
       $lonCluster='development'; $flag=1;
     }
     elsif ($choice==4) {
       $lonCluster='existing'; $flag=1;
       if (-e '/home/httpd/lonTabs/hosts.tab') {
         `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
       }
       else {
         print &lt;&lt;END;
   There is no existing /home/httpd/lonTabs/hosts.tab
   END
         die('');
       }
       if (-e '/home/httpd/lonTabs/domain.tab') {
         `cp /home/httpd/lonTabs/domain.tab ../existing_domain.tab`;
       }
       else {
         print &lt;&lt;END;
   There is no existing /home/httpd/lonTabs/domain.tab
   END
         die('');
       }
     }
     elsif ($choice==26) {
       $lonCluster='rawhide'; $flag=1;
     }
   }
   }
   </perlscript>
   </file>
   <file>
 <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>  <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
 <perlscript mode='fg'>  <perlscript mode='fg'>
 $|=1;  $|=1;
Line 305  my %perlvar; Line 375  my %perlvar;
     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {      unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
        $perlvar{'lonLoadLim'}='2.00';         $perlvar{'lonLoadLim'}='2.00';
     }      }
       unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
          $perlvar{'lonUserLoadLim'}='0';
       }
     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {      unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
        $perlvar{'lonExpire'}='86400';         $perlvar{'lonExpire'}='86400';
     }      }
Line 351  my %perlvar; Line 424  my %perlvar;
     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {      unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
        $perlvar{'lonLoadLim'}='2.00';         $perlvar{'lonLoadLim'}='2.00';
     }      }
       unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
          $perlvar{'lonUserLoadLim'}='0';
       }
     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {      unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
        $perlvar{'lonExpire'}='86400';         $perlvar{'lonExpire'}='86400';
     }      }
Line 376  my %perlvarstatic; Line 452  my %perlvarstatic;
  }   }
  close(CONFIG);   close(CONFIG);
     }      }
       if (!$domainDescription && $lonCluster ne 'existing') {
          open(IN,'&lt;../'.$lonCluster.'_domain.tab');
          while(&lt;IN&gt;) {
             if (/^$perlvar{'lonDefDomain'}\:/) {
        (undef,$domainDescription)=split(/:/,$_);
        chomp($domainDescription);
                last;
             }
          }
          close(IN);
       }
       if (!$domainDescription) {
          open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
          while(&lt;IN&gt;) {
             if (/^$perlvar{'lonDefDomain'}\:/) {
        (undef,$domainDescription)=split(/:/,$_);
        chomp($domainDescription);
                last;
             }
          }
          close(IN);
       }
      
 # implement editing logic below, interactively  # implement editing logic below, interactively
 # update loncapa.conf until 7 is entered  # update loncapa.conf until 8 is entered
   
 $flag=0;  $flag=0;
   
Line 393  This is now the current configuration of Line 492  This is now the current configuration of
 5) Role: $perlvar{'lonRole'}  5) Role: $perlvar{'lonRole'}
 6) Cache Expiration Time: $perlvar{'lonExpire'}  6) Cache Expiration Time: $perlvar{'lonExpire'}
 7) Server Load: $perlvar{'lonLoadLim'}  7) Server Load: $perlvar{'lonLoadLim'}
 8) Everything is correct up above  8) User Load: $perlvar{'lonUserLoadLim'}
   9) Everything is correct up above
 END  END
 my $hbug=-1;  my $hbug=-1;
 my $dbug=-1;  my $dbug=-1;
Line 420  if ($dbug) { Line 520  if ($dbug) {
 }  }
   
   print(&lt;&lt;END);    print(&lt;&lt;END);
 ENTER A CHOICE OF 1-7 TO CHANGE, otherwise ENTER 8:  ENTER A CHOICE OF 1-8 TO CHANGE, otherwise ENTER 9:
 END  END
 my $choice=&lt;&gt;;  my $choice=&lt;&gt;;
 chomp($choice);  chomp($choice);
Line 496  END Line 596  END
     $perlvar{'lonLoadLim'}=$choice2;      $perlvar{'lonLoadLim'}=$choice2;
   }    }
   elsif ($choice==8) {    elsif ($choice==8) {
     print(&lt;&lt;END);
   8) 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
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonUserLoadLim'}=$choice2;
     }
     elsif ($choice==9) {
     $flag=1;      $flag=1;
   }    }
   else {    else {
Line 517  END Line 627  END
 <target dist='default'>loncom/hosts.tab</target>  <target dist='default'>loncom/hosts.tab</target>
 <perlscript mode='fg'>  <perlscript mode='fg'>
 unless (-l "<TARGET />") {  unless (-l "<TARGET />") {
   print(&lt;&lt;END);    my $hostname=`hostname`;chomp($hostname);
     my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
 ===============================================================================    $hostaddress=~s/\s//;
 What hosts.tab would you like to have installed?  
 (hosts.tab is a listing of all other internet machines  
 that a server system considers to be valid server systems  
 on the LON-CAPA network)  
   
 1) PRODUCTION - you want to deliver courses today or sometime very soon  
                 on this machine  
 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and  
                  not be connected to other LON-CAPA machines for now  
 3) DEVELOPMENT - you want to play with or explore LON-CAPA  
 4) PRESERVE the existing hosts.tab (/home/httpd/lonTabs/hosts.tab)  
   
 END  
 # Option number 26 will install rawhide_hosts.tab, but  
 # the typical user does not want to be part of an intensive  
 # machine test cluster.  
   
 # get input  
 # if valid then process, otherwise loop  
 my $hostname=`hostname`;chomp($hostname);  
 my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);  
 $hostaddress=~s/\s//;  
 $flag=0;  
 while (!$flag) {  
   print "ENTER 1, 2, 3, or 4:\n";  
   my $choice=&lt;&gt;;  
   chomp($choice);  
   $line2insert=&lt;&lt;END;  
 $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress:$domainDescription  
 END  
   $date=`date -I`; chomp($date);    $date=`date -I`; chomp($date);
   $lonHostID=$perlvar{'lonHostID'};    $lonHostID=$perlvar{'lonHostID'};
   $lonHostID=~s/\W//g;    $lonHostID=~s/\W//g;
   $lineexistflag=0;    $lineexistflag=0;
   $hostidexistflag=0;    $hostidexistflag=0;
   if ($choice==1) {    $line2insert=&lt;&lt;END;
     $lonCluster='production'; $flag=1;  $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
   }  END
   elsif ($choice==2) {    $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription\n";
     $lonCluster='standalone'; $flag=1;    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');
       print(OUT $line2insert);        print(OUT $line2insert);
     close(OUT);      close(OUT);
   }      open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
   elsif ($choice==3) {        die('file generation error');
     $lonCluster='development'; $flag=1;        print(OUT $domaininsert);
   }      close(OUT);
   elsif ($choice==4) {  
     $lonCluster='existing'; $flag=1;  
     if (-e '/home/httpd/lonTabs/hosts.tab') {  
       `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;  
     }  
     else {  
       print &lt;&lt;END;  
 There is no existing /home/httpd/lonTabs/hosts.tab  
 END  
       die('');  
     }  
   }  
   elsif ($choice==26) {  
     $lonCluster='rawhide'; $flag=1;  
   }    }
   if ($flag==1) {    if ($flag==1) {
     `rm -f ../hosts.tab`;      `rm -f ../hosts.tab`;
Line 635  END Line 701  END
       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;        `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
     }      }
   }    }
 }    $lineexistflag=0;
     if ($flag==1) {
       `rm -f ../domain.tab`;
       open(IN,'&lt;../'.$lonCluster.'_domain.tab');
       while(&lt;IN&gt;) {
         if (/^$domaininsert$/) {
           $lineexistflag=1;
         }
         if (/^$perlvar{'lonDefDomain'}\:/) {
           $domainexistflag=1;
         }
       }
       close(IN);
       if ($domainexistflag and !$lineexistflag) {
         print &lt;&lt;END;
   WARNING: $perlvar{'lonDefDomain'} already exists inside
   loncapa/loncom/${lonCluster}_domain.tab.  The entry inside
   ${lonCluster}_domain.tab does not match your settings.
   The entry inside ${lonCluster}_domain.tab is being replaced
   with your new values.
   END
         `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
          open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
            die("cannot open loncom/${lonCluster}_domain.tab for output\n");
            print(OUT $domaininsert);
          close(OUT);
         `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
         # email appropriate message
         system('ping -c 1 www.lon-capa.org > /dev/null || ping -c 1 www.msu.edu > /dev/null || ping -c 1 www.mit.edu > /dev/null');
         `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
       }
       elsif ($domainexistflag and $lineexistflag) {
         print &lt;&lt;END;
   Entry exists in ${lonCluster}_domain.tab.
   END
         `ln -s ${lonCluster}_domain.tab ../domain.tab`;
         # email appropriate message
         `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
       }
       elsif (!$domainexistflag and !$lineexistflag) {
         print &lt;&lt;END;
   New entry for $lonCluster.
   END
         `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
          open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
            die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
            print(OUT $domaininsert);
          close(OUT);
         `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
         # email appropriate message
         `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
       }
     }
 }  }
 </perlscript>  </perlscript>
 </file>  </file>

Removed from v.1.21  
changed lines
  Added in v.1.27


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