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

harris41 lon-capa-cvs@mail.lon-capa.org
Sun, 09 Jun 2002 23:31:09 -0000


harris41		Sun Jun  9 19:31:09 2002 EDT

  Modified files:              
    /doc/loncapafiles	updatequery.piml 
  Log:
  now makes a mailing to installrecord@mail.lon-capa.org
  
  
Index: doc/loncapafiles/updatequery.piml
diff -u doc/loncapafiles/updatequery.piml:1.14 doc/loncapafiles/updatequery.piml:1.15
--- doc/loncapafiles/updatequery.piml:1.14	Thu Jun  6 11:44:27 2002
+++ doc/loncapafiles/updatequery.piml	Sun Jun  9 19:31:09 2002
@@ -1,7 +1,7 @@
 <!-- updatequery.piml -->
 <!-- Scott Harrison -->
 
-<!-- $Id: updatequery.piml,v 1.14 2002/06/06 15:44:27 harris41 Exp $ -->
+<!-- $Id: updatequery.piml,v 1.15 2002/06/09 23:31:09 harris41 Exp $ -->
 
 <!--
 
@@ -299,7 +299,6 @@
 <perlscript mode='fg'>
 # read values from loncapa.conf
 my $confdir='/etc/httpd/conf/';
-#my $confdir='';
 my $filename='loncapa.conf';
 my %perlvar;
     if (-e "$confdir$filename") {
@@ -454,23 +453,50 @@
   print "ENTER 1, 2, 3, or 4:\n";
   my $choice=&lt;&gt;;
   chomp($choice);
-    $line2insert=&lt;&lt;END;
+  $line2insert=&lt;&lt;END;
 $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
 END
-    $date=`date -I`; chomp($date);
-    $lonHostID=$perlvar{'lonHostID'};
-    $lonHostID=~s/\W//g;
-    $lineexistflag=0;
-    $hostidexistflag=0;
+  $date=`date -I`; chomp($date);
+  $lonHostID=$perlvar{'lonHostID'};
+  $lonHostID=~s/\W//g;
+  $lineexistflag=0;
+  $hostidexistflag=0;
   if ($choice==1) {
-    $lonCluster='production';
+    $lonCluster='production'; $flag=1;
+  }
+  elsif ($choice==2) {
+    $lonCluster='standalone'; $flag=1;
+    open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
+      die('file generation error');
+      print(OUT $line2insert);
+    close(OUT);
+  }
+  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('');
+    }
+  }
+  elsif ($choice==26) {
+    $lonCluster='rawhide'; $flag=1;
+  }
+  if ($flag==1) {
     `rm -f ../hosts.tab`;
-    open(IN,'&lt;../production_hosts.tab');
+    open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
     while(&lt;IN&gt;) {
       if (/^$line2insert$/) {
         $lineexistflag=1;
       }
-      if (/^$perlvar{'lonHostID'}\:/) {
+      if (/^$lonHostID\:/) {
         $hostidexistflag=1;
       }
     }
@@ -478,65 +504,41 @@
     if ($hostidexistflag and !$lineexistflag) {
       print &lt;&lt;END;
 WARNING: $lonHostID already exists inside
-loncapa/loncom/production_hosts.tab.  The entry inside
-production_hosts.tab does not match your settings.
-The entry inside production_hosts.tab is being replaced
+loncapa/loncom/${lonCluster}_hosts.tab.  The entry inside
+${lonCluster}_hosts.tab does not match your settings.
+The entry inside ${lonCluster}_hosts.tab is being replaced
 with your new values.
 END
-      `grep -v "$lonHostID:" ../production_hosts.tab &gt; ../new_production_hosts.tab`;
-       open(OUT,'&gt;&gt;../new_production_hosts.tab') or
-         die("cannot open loncom/standalone_hosts.tab for output\n");
+      `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
+       open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
+         die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
          print(OUT $line2insert);
        close(OUT);
-      `ln -s new_production_hosts.tab ../hosts.tab`;
+      `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
       # email appropriate message
-      `echo "REPLACE:$lonHostID:date:$line2insert" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
+      `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
     }
     elsif ($hostidexistflag and $lineexistflag) {
-      `ln -s production_hosts.tab ../hosts.tab`;
-    }
-    elsif (!$$hostidexistflag and !$lineexistflag) {
-      `cat ../production_hosts.tab &gt; ../new_production_hosts.tab`;
-      `ln -s new_production_hosts.tab &gt; ../hosts.tab`;
+      print &lt;&lt;END;
+Entry exists in ${lonCluster}_hosts.tab.
+END
+      `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
+      # email appropriate message
+      `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
     }
-    $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
+    elsif (!$hostidexistflag and !$lineexistflag) {
+      print &lt;&lt;END;
+New entry for $lonCluster.
 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`;
+      `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
+       open(OUT,'&gt;../new_'.$lonCluster.'_hosts.tab') or
+         die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
+         print(OUT $line2insert);
+       close(OUT);
+      `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
+      # email appropriate message
+      `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
     }
-    `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 {
-
   }
 }