patch for fai-chboot -c

Andreas Sindermann sinder at thp.Uni-Koeln.DE
Wed Jul 5 11:21:52 CEST 2006


Hi,

this is a unified patch for fai-chboot provided by Ubuntu. With this
patch 'fai-chboot -c' behaves as follows:

a) a possibly existent .disable pxe file will be removed automaticall
    and a corresponding message is printed.

b) an introducing headline to the copied file is prepended stating
    from which source and for which host it has been
    generated. Currently one can't see (except by the hex-filename) for
    which host it has been generated.

Andreas
-------------- next part --------------
--- fai-chboot.ori	2006-07-05 09:34:25.000000000 +0200
+++ fai-chboot	2006-07-05 11:10:50.000000000 +0200
@@ -273,6 +273,18 @@
   rename "$pxedir/$hex.disable","$pxedir/$hex" or $error .= "\nRename for $hex failed. $! $@";
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+sub docopy {
+  my ($srcfile, $pxedir, $desthex, $desthost, $ipadr) = @_;
+  open SOURCE, "$srcfile";
+  open DEST, ">$pxedir/$desthex";
+  print DEST "# template generated by fai-chboot for host $desthost with IP $ipadr from source $srcfile\n";
+  while (<SOURCE>) {
+    print DEST $_;
+  }
+  close SOURCE;
+  close DEST;
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub tcopy {
 
   my ($srchost,$desthost) = @_;
@@ -307,17 +319,19 @@
       return;
     }
     print "copy pxe config from $srchost to template $desthost\n" if $verbose;
-    copy("$srcfile","$pxedir/$desthost") or $error .= 
-        "\nCopy of $srchost ($srchex) to template $desthost failed.$! $@";
+    docopy("$srcfile","$pxedir", "$desthost", "$desthost", "$ipadr");
   } else {
     ($ipadr,$desthex) = host2hex($desthost);
-    if (-e "$pxedir/$desthex.disable") {
-       warn "Config for $desthost is currently disabled. Copying aborted.\n";
-       return;
+#    if (-e "$pxedir/$desthex.disable") {
+#       warn "Config for $desthost is currently disabled. Copying aborted.\n";
+#       return;
+#    }
+    if (-f "$pxedir/$desthex.disable") {
+      unlink "$pxedir/$desthex.disable";
+      print "removed old $pxedir/$desthex.disable\n";
     }
     print "copy pxe config from $srchost to $desthost ($desthex)\n" if $verbose;
-    copy("$srcfile","$pxedir/$desthex") or $error .= 
-        "\nCopy of $srchost ($srchex) to $desthost ($desthex) failed.$! $@";
+    docopy("$srcfile","$pxedir", "$desthex", "$desthost", "$ipadr");
   }
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


More information about the linux-fai-devel mailing list