[Fai-commit] r3763 - trunk/bin

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Sun Aug 6 21:01:32 UTC 2006


Author: lange
Date: 2006-08-06 21:01:32 +0000 (Sun, 06 Aug 2006)
New Revision: 3763

Modified:
   trunk/bin/fai-chboot
Log:
existent .disable pxe file will be removed automatically,
add headline when copying from template


Modified: trunk/bin/fai-chboot
===================================================================
--- trunk/bin/fai-chboot	2006-08-06 20:18:04 UTC (rev 3762)
+++ trunk/bin/fai-chboot	2006-08-06 21:01:32 UTC (rev 3763)
@@ -28,7 +28,7 @@
 #*********************************************************************
 
 # variable needed: $nfsroot
-$version="version 2.2.2 22-july-2006";
+$version="version 2.2.3 3-august-2006";
 
 use Socket;
 use Net::hostent;
@@ -251,6 +251,10 @@
   # rename network config file
   my ($host) = shift;
   my ($ipadr,$hex) = host2hex($host);
+  if (! -e "$pxedir/$hex") {
+    print "$host ($hex) is not enabled\n";
+    return;
+  }
   print "disable pxe config for $host in hex $hex\n" if $verbose;
   return if $opt_n;
   rename "$pxedir/$hex","$pxedir/$hex.disable" or $error .= "\nRename for $hex failed. $! $@";
@@ -273,6 +277,19 @@
   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 +324,15 @@
       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 (-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 Fai-commit mailing list