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

harris41 lon-capa-cvs@mail.lon-capa.org
Thu, 06 Jun 2002 15:36:41 -0000


harris41		Thu Jun  6 11:36:41 2002 EDT

  Modified files:              
    /doc/loncapafiles	updatequery.piml 
  Log:
  implementing hosts.tab modification for production cluster; sending
  out an e-mail based on hosts.tab modification; only one possibility
  implemented for production cluster so far
  
  
Index: doc/loncapafiles/updatequery.piml
diff -u doc/loncapafiles/updatequery.piml:1.12 doc/loncapafiles/updatequery.piml:1.13
--- doc/loncapafiles/updatequery.piml:1.12	Wed May 22 16:52:27 2002
+++ doc/loncapafiles/updatequery.piml	Thu Jun  6 11:36:41 2002
@@ -1,7 +1,7 @@
 <!-- updatequery.piml -->
 <!-- Scott Harrison -->
 
-<!-- $Id: updatequery.piml,v 1.12 2002/05/22 20:52:27 harris41 Exp $ -->
+<!-- $Id: updatequery.piml,v 1.13 2002/06/06 15:36:41 harris41 Exp $ -->
 
 <!--
 
@@ -454,10 +454,56 @@
   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
+END
+    $date=`date -I`; chomp($date);
+    $lonHostID=$perlvar{'lonHostID'};
+    $lonHostID=~s/\W//g;
+    $lineexistflag=0;
+    $hostidexistflag=0;
   if ($choice==1) {
     $lonCluster='production';
     `rm -f ../hosts.tab`;
-    `ln -s production_hosts.tab ../hosts.tab`;
+    open(IN,'&lt;../production_hosts.tab');
+    while(&lt;IN&gt;) {
+      if (/^$line2insert$/) {
+        $lineexistflag=1;
+      }
+      if (/^$perlvar{'lonHostID'}\:/) {
+        $hostidexistflag=1;
+      }
+    }
+    close(IN);
+    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
+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");
+         print(OUT &lt;&lt;END);
+$line2insert
+END
+       close(OUT);
+      `ln -s new_production_hosts.tab ../hosts.tab`;
+      # email appropriate message
+#      `echo "$date" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
+      `echo "REPLACE:$lonHostID:date:$line2insert" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
+      # "REPLACE:hostid:date"
+      # "REPLACE:hostid:date:line"
+    }
+    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`;
+    }
     $flag=1;
   }
   elsif ($choice==2) {