Diff for /doc/loncapafiles/updatequery.piml between versions 1.5 and 1.9

version 1.5, 2002/05/13 01:09:26 version 1.9, 2002/05/16 15:29:15
Line 65  or contact sharrison\@mail.lon-capa.org. Line 65  or contact sharrison\@mail.lon-capa.org.
 ===============================================================================  ===============================================================================
 The following 4 values are needed to configure LON-CAPA:  The following 4 values are needed to configure LON-CAPA:
 * Machine Role  * Machine Role
 * Machine ID Name  * LON-CAPA Domain Name
 * LON-CAPA Domain Name, and  * LON-CAPA Machine ID Name, and
 * System Administration E-mail Address.  * System Administration E-mail Address.
 END  END
   
Line 120  my $ipdomain=''; Line 120  my $ipdomain='';
 if ($hostname=~/([^\.]*)\.([^\.]*)$/) {  if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
   $ipdomain=$1;    $ipdomain=$1;
 }  }
 my $lonHostID;  
 if ($ipdomain) {  
   $lonHostID=$ipdomain.$r.int(1+rand(9)); # should be probably detect against  
                                           # the hosts.tab  
 }  
   
   print(<<END);    print(<<END);
   
 **** Machine ID Name ****  **** Domain ****
 [this does NOT need to correspond to internet address names;  [this does NOT need to correspond to internet address domains,
  this name MUST be unique to the whole LON-CAPA network;   examples might be "msu" or "bionet" or "vermontcc"]
  we recommend that you use a name based off of your institution;  
  good examples: "msul1" or "bionetl1";  
  bad examples: "loncapabox" or "studentsinside"]  
 END  END
 # get machine name  
   # get domain name
 # accept if valid, if not valid, tell user and repeat  # accept if valid, if not valid, tell user and repeat
 $flag=0;  $flag=0;
   my $lonDefDomain;
 while (!$flag) {  while (!$flag) {
 if ($ipdomain) {  if ($ipdomain) {
 print(<<END);  print(<<END);
 ENTER LONCAPA MACHINE ID [$lonHostID]:  ENTER LONCAPA DOMAIN [$ipdomain]:
 END  END
 }  }
 else {  else {
   print(<<END);    print(<<END);
 ENTER LONCAPA MACHINE ID:  ENTER LONCAPA DOMAIN:
 END  END
 }  }
   my $choice=<>;    my $choice=<>;
   chomp($choice);    chomp($choice);
   if ($lonHostID and $choice=~/^\s*$/) {    if ($ipdomain and $choice=~/^\s*$/) {
     $choice=$lonHostID;      $choice=$ipdomain;
     open(OUT,'>>/tmp/loncapa_updatequery.out');      open(OUT,'>>/tmp/loncapa_updatequery.out');
     print(OUT 'lonHostID'."\t".$choice."\n");      print(OUT 'lonDefDomain'."\t".$choice."\n");
     close(OUT);      close(OUT);
       $lonDefDomain=$choice;
     $flag=1;      $flag=1;
   }    }
   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {    elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
     open(OUT,'>>/tmp/loncapa_updatequery.out');      open(OUT,'>>/tmp/loncapa_updatequery.out');
     print(OUT 'lonHostID'."\t".$choice."\n");      print(OUT 'lonDefDomain'."\t".$choice."\n");
     close(OUT);      close(OUT);
       $lonDefDomain=$choice;
       $r='l';
     $flag=1;      $flag=1;
   }    }
   else {    else {
Line 169  END Line 166  END
   }    }
 }  }
   
   my $lonHostID;
   if ($lonDefDomain) {
     $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
                                                 # against the hosts.tab
   }
   
   print(<<END);    print(<<END);
   
 **** Domain ****  **** Machine ID Name ****
 [this does NOT need to correspond to internet address domains,  [this does NOT need to correspond to internet address names;
  examples might be "msu" or "bionet" or "vermontcc"]   this name MUST be unique to the whole LON-CAPA network;
    we recommend that you use a name based off of your institution;
    good examples: "msul1" or "bionetl1";
    bad examples: "loncapabox" or "studentsinside"]
 END  END
   # get machine name
 # get domain name  
 # accept if valid, if not valid, tell user and repeat  # accept if valid, if not valid, tell user and repeat
 $flag=0;  $flag=0;
 my $lonDefDomain;  
 while (!$flag) {  while (!$flag) {
 if ($ipdomain) {  if ($ipdomain) {
 print(<<END);  print(<<END);
 ENTER LONCAPA DOMAIN [$ipdomain]:  ENTER LONCAPA MACHINE ID [$lonHostID]:
 END  END
 }  }
 else {  else {
   print(<<END);    print(<<END);
 ENTER LONCAPA DOMAIN:  ENTER LONCAPA MACHINE ID:
 END  END
 }  }
   my $choice=<>;    my $choice=<>;
   chomp($choice);    chomp($choice);
   if ($ipdomain and $choice=~/^\s*$/) {    if ($lonHostID and $choice=~/^\s*$/) {
     $choice=$ipdomain;      $choice=$lonHostID;
     open(OUT,'>>/tmp/loncapa_updatequery.out');      open(OUT,'>>/tmp/loncapa_updatequery.out');
     print(OUT 'lonDefDomain'."\t".$choice."\n");      print(OUT 'lonHostID'."\t".$choice."\n");
     close(OUT);      close(OUT);
     $lonDefDomain=$choice;      $lonHostID=$choice;
     $flag=1;      $flag=1;
   }    }
   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {    elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
     open(OUT,'>>/tmp/loncapa_updatequery.out');      open(OUT,'>>/tmp/loncapa_updatequery.out');
     print(OUT 'lonDefDomain'."\t".$choice."\n");      print(OUT 'lonHostID'."\t".$choice."\n");
     close(OUT);      close(OUT);
     $lonDefDomain=$choice;      $lonHostID=$choice;
     $r='l';  
     $flag=1;      $flag=1;
   }    }
   else {    else {
Line 217  END Line 220  END
 # get e-mail address  # get 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;
 my $lonAdmEmail;  my $lonAdmEMail;
 while (!$flag) {  while (!$flag) {
   print(<<END);    print(<<END);
   
Line 231  END Line 234  END
   chomp($choice);    chomp($choice);
   if ($choice=~/\@/) {    if ($choice=~/\@/) {
     open(OUT,'>>/tmp/loncapa_updatequery.out');      open(OUT,'>>/tmp/loncapa_updatequery.out');
     print(OUT 'lonAdmEmail'."\t".$choice."\n");      print(OUT 'lonAdmEMail'."\t".$choice."\n");
     close(OUT);      close(OUT);
     $lonAdmEmail=$choice;      $lonAdmEMail=$choice;
     $flag=1;      $flag=1;
   }    }
   else {    else {
Line 242  END Line 245  END
 }  }
   
 # update loncapa.conf  # update loncapa.conf
 #my $confdir='/etc/httpd/conf/';  my $confdir='/etc/httpd/conf/';
 my $confdir='';  #my $confdir='';
 my $filename='loncapa.conf';  my $filename='loncapa.conf';
 my %perlvar;  my %perlvar;
     if (-e "$confdir$filename") {      if (-e "$confdir$filename") {
Line 259  my %perlvar; Line 262  my %perlvar;
     }      }
     $perlvar{'lonHostID'}=$lonHostID;      $perlvar{'lonHostID'}=$lonHostID;
     $perlvar{'lonDefDomain'}=$lonDefDomain;      $perlvar{'lonDefDomain'}=$lonDefDomain;
     $perlvar{'lonAdmEmail'}=$lonAdmEmail;      $perlvar{'lonAdmEMail'}=$lonAdmEMail;
     $perlvar{'lonRole'}=$lonRole;      $perlvar{'lonRole'}=$lonRole;
     unless ($perlvar{'lonSqlAccess'}) {      unless ($perlvar{'lonSqlAccess'}) {
        $perlvar{'lonSqlAccess'}='localhostkey';         $perlvar{'lonSqlAccess'}='localhostkey';
Line 295  END Line 298  END
 <target dist='default'>/</target>  <target dist='default'>/</target>
 <perlscript mode='fg'>  <perlscript mode='fg'>
 # read values from loncapa.conf  # read values from loncapa.conf
 #my $confdir='/etc/httpd/conf/';  my $confdir='/etc/httpd/conf/';
 my $confdir='';  #my $confdir='';
 my $filename='loncapa.conf';  my $filename='loncapa.conf';
 my %perlvar;  my %perlvar;
     if (-e "$confdir$filename") {      if (-e "$confdir$filename") {
Line 311  my %perlvar; Line 314  my %perlvar;
  }   }
  close(CONFIG);   close(CONFIG);
     }      }
   my %perlvarstatic;
       if (-e "${confdir}loncapa_apache.conf") {
    open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
             die("Can't read ${confdir}loncapa_apache.conf");
    while (my $configline=&lt;CONFIG&gt;) {
       if ($configline =~ /^[^\#]*PerlSetVar/) {
    my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
    chomp($varvalue);
    $perlvarstatic{$varname}=$varvalue;
       }
    }
    close(CONFIG);
       }
   # implement editing logic below, interactively
   # update loncapa.conf until 7 is entered
   
   $flag=0;
   while (!$flag) {
   print(&lt;&lt;END);    print(&lt;&lt;END);
   
 ===============================================================================  ===============================================================================
 This is now the current configuration of your machine.  This is now the current configuration of your machine.
 1) Machine Name: $perlvar{'lonHostID'}  1) Domain Name: $perlvar{'lonDefDomain'}
 2) Domain Name: $perlvar{'lonDefDomain'}  2) Machine Name: $perlvar{'lonHostID'}
 3) System Administrator's E-mail Address: $perlvar{'lonAdmEmail'}  3) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
 4) Role: $perlvar{'lonRole'}  4) Role: $perlvar{'lonRole'}
 5) Cache Expiration Time: $perlvar{'lonExpire'}  5) Cache Expiration Time: $perlvar{'lonExpire'}
 6) Server Load: $perlvar{'lonLoadLim'}  6) Server Load: $perlvar{'lonLoadLim'}
 7) Everything is correct up above  7) Everything is correct up above
   END
     print(&lt;&lt;END);
 ENTER A CHOICE OF 1-6 TO CHANGE, otherwise ENTER 7:  ENTER A CHOICE OF 1-6 TO CHANGE, otherwise ENTER 7:
 END  END
   
 # implement editing logic below, interactively  
 # update loncapa.conf until 7 is entered  
 my $choice=&lt;&gt;;  my $choice=&lt;&gt;;
 chomp($choice);  chomp($choice);
     if ($choice==1) {
     print(&lt;&lt;END);
   2) Domain Name: $perlvar{'lonDefDomain'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonDefDomain'}=$choice2;
     }
     elsif ($choice==2) {
     print(&lt;&lt;END);
   1) Machine Name: $perlvar{'lonHostID'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonHostID'}=$choice2;
     }
     elsif ($choice==3) {
     print(&lt;&lt;END);
   3) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonAdmEMail'}=$choice2;
     }
     elsif ($choice==4) {
     print(&lt;&lt;END);
   4) Role: $perlvar{'lonRole'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonRole'}=$choice2;
     }
     elsif ($choice==5) {
     print(&lt;&lt;END);
   5) Cache Expiration Time: $perlvar{'lonExpire'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonExpire'}=$choice2;
     }
     elsif ($choice==6) {
     print(&lt;&lt;END);
   6) Server Load: $perlvar{'lonLoadLim'}
   ENTER NEW VALUE:
   END
       my $choice2=&lt;&gt;;
       chomp($choice2);
       $perlvar{'lonLoadLim'}=$choice2;
     }
     elsif ($choice==7) {
       $flag=1;
     }
     else {
   
     }
   }
       open(OUT,"&gt;$confdir$filename") or
         die("Cannot output to $confdir$filename\n");
       foreach my $key (keys %perlvar) {
         my $value=$perlvar{$key};
         print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
   PerlSetVar     $key      $value
   END
       }
       close(OUT);
 </perlscript>  </perlscript>
 </file>  </file>
 <file>  <file>
Line 349  on the LON-CAPA network) Line 438  on the LON-CAPA network)
 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and  2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
                  not be connected to other LON-CAPA machines for now                   not be connected to other LON-CAPA machines for now
 3) DEVELOPMENT - you want to play with or explore LON-CAPA  3) DEVELOPMENT - you want to play with or explore LON-CAPA
 4) Do not install hosts.tab right now  4) PRESERVE the existing hosts.tab (/home/httpd/lonTabs/hosts.tab)
   
 ENTER 1, 2, 3, or 4:  
 END  END
 # Option number 26 will install rawhide_hosts.tab, but  # Option number 26 will install rawhide_hosts.tab, but
 # the typical user does not want to be part of an intensive  # the typical user does not want to be part of an intensive
Line 359  END Line 447  END
   
 # get input  # get input
 # if valid then process, otherwise loop  # if valid then process, otherwise loop
 my $choice=&lt;&gt;;  my $hostname=`hostname`;chomp($hostname);
 chomp($choice);  my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
   $flag=0;
   while (!$flag) {
     print "ENTER 1, 2, 3, or 4:\n";
     my $choice=&lt;&gt;;
     chomp($choice);
     if ($choice==1) {
       $lonCluster='production';
       `rm -f ../hosts.tab`;
       `ln -s production_hosts.tab ../hosts.tab`;
       $flag=1;
     }
     elsif ($choice==2) {
       $lonCluster='standalone';
       open(OUT,'&gt;../standalone_hosts.tab') or
         die("cannot open loncom/standalone_hosts.tab for output\n");
       print(OUT &lt;&lt;END);
   $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
   END
       close(OUT);
       `rm -f ../hosts.tab`;
       `ln -s standalone_hosts.tab ../hosts.tab`;
       $flag=1;
     }
     elsif ($choice==3) {
       $lonCluster='development';
       `rm -f loncom/hosts.tab`;
       `ln -s development_hosts.tab ../hosts.tab`;
       $flag=1;
     }
     elsif ($choice==4) {
       $lonCluster='existing';
       `rm -f ../hosts.tab`;
       `touch existing_hosts.tab`;
       if (-e '/home/httpd/lonTabs/hosts.tab') {
         `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
       }
       `ln -s existing_hosts.tab ../hosts.tab`;
       $flag=1;
     }
     elsif ($choice==26) {
       $lonCluster='rawhide';
       `rm -f ../hosts.tab`;
       `ln -s rawhide_hosts.tab ../hosts.tab`;
       $flag=1;
     }
     else {
   
     }
   }
   
 }  }
 </perlscript>  </perlscript>

Removed from v.1.5  
changed lines
  Added in v.1.9


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