Your message dated Mon, 03 Apr 2006 07:17:08 -0700
with message-id <[EMAIL PROTECTED]>
and subject line Bug#342471: fixed in fai 2.10
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: fai
Severity: wishlist
Tags: patch

Hi,

Some improvements to fai-chboot in attatched patch:

* -l takes optional host/IP/HEX to only list those hosts
* -v option, an optional extra flag to -l to list all config files, not only
     those matching the hex, i.e also "template files" are listed. 
* -c a new option for copying an existing config file to new host(s).

/torkel

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8
Locale: LANG=en_GB.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)

Versions of packages fai depends on:
pn  debootstrap                              Not found.
ii  nfs-kernel-server [nfs-serve 1:1.0.6-3.1 Kernel NFS server support
ii  perl                         5.8.4-8     Larry Wall's Practical Extraction 
Index: bin/fai-chboot
===================================================================
--- bin/fai-chboot      (revision 3156)
+++ bin/fai-chboot      (working copy)
@@ -33,7 +33,20 @@
 use Socket;
 use Net::hostent;
 use Getopt::Std;
+use File::Copy;
 
+$Getopt::Std::STANDARD_HELP_VERSION=true;
+
+sub VERSION_MESSAGE {
+  print "$0 $version\n";
+}
+
+sub HELP_MESSAGE {
+  print << "EOM";
+ Please read the manual pages fai-chboot(8).
+EOM
+}
+
 $0=~ s#.+/##; # remove path from program name
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub ip2hex {
@@ -70,15 +83,45 @@
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub lsdir {
+  my %lshosts; 
+  foreach (@_) {
+      chomp;
+      # make sure we ha a fqdn name
+      if ($host =~ /^\d+\.\d+\.\d+\.\d+$/) {
+        # hostname is already an IP address
+        $tmphost = gethostbyaddr($_);
+      } else {
+        $tmphost = gethost($_);
+      }
+      $lshosts{$tmphost->name} = 1 if $tmphost;
+      $lshosts{$_} = 1;
+  }
 
   my (@n,$host,$ip,$iaddr,$hex,$kernelname,$append);
 
   opendir(DIR, $pxedir) || die "can't opendir $pxedir: $!";
-  foreach (readdir(DIR)) {
-#    prtipa if /^[0-9A-F]{2}$/;
-#    prtipb if /^[0-9A-F]{4}$/;
-#    prthostname if /^[0-9A-F]{6}/;
-    next unless /^[0-9A-F]+|default/;
+
+  # sort the files
+  my @allfiles = grep !/^\./, readdir DIR;
+  my (@default, @enabled, @disabled, @other);
+  foreach (@allfiles) {
+      if (/^default$/) {
+          push @default, $_;
+      } elsif (/^[0-9A-F]+$/) {
+          push @enabled, $_;
+      } elsif (/\.disable$/) {
+          push @disabled, $_;
+      } else {
+        push @other, $_;
+      }
+  }
+  @allfiles = @default;
+  push @allfiles, sort @enabled; 
+  push @allfiles, sort @disabled;
+  push @allfiles, sort @other if $verbose;
+
+  
+  foreach (@allfiles) {
     $hex = $_;
 
     # hex to ip address
@@ -86,7 +129,9 @@
     $ip = join ('.', map {$_ = hex $_} @n);
 
     if ($hex =~ /^default/) {
-      $host = 'unknown IP';
+      $host = '[DEFAULT]';
+    } elsif ($hex =~ /^[^0-9A-F]/) {
+        $host = "[Template]";
     } elsif ($#n < 3) {
       # Don't fail if not a complete IP
       $host = "Subnet: $ip";
@@ -95,23 +140,28 @@
       $iaddr = inet_aton($ip);
       if ($h = gethostbyaddr($iaddr, AF_INET)) {
        $host = $h->name;
+        $host =~ s/^([^.]+).*/\1/g;
       } else {
        $host = "unknown host: $ip";
       }
     }
 
+    my $tmphex = $hex;
+    $tmphex =~ s/.disable$//g;
+    next if %lshosts && ! ($lshosts{$host} || $lshosts{$tmphex} || 
$lshosts{$ip});
+
     # read pxe config file for a host
-    undef $kernelname;
     open (CFG,"$pxedir/$hex") || die "$! [EMAIL PROTECTED]";
     while (<CFG>) {
-      /^kernel (\S+)/ and $kernelname = $1;
-      /^(localboot.+)/ and $kernelname = $1;
-      /^append (.+)/ and $append = $1;
+      /^\s*kernel (\S+)/ and $kernelname = $1;
+      /^\s*(localboot.+)/ and $kernelname = $1;
+      /^\s*append (.+)/ and $append = $1;
     }
     close (CFG);
+    $kernelname = $displayname if $displayname;
 
     $opt_L or undef $append;
-    printf "%-8s %-12s $kernelname $append\n",$hex,$host;
+    printf "%-16s %-12s $kernelname $append\n",$hex, $host;
     undef $append;
     undef $kernelname;
   }
@@ -119,11 +169,8 @@
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub usage {
-
-  print "$0 $version\n";
-  print << "EOM";
- Please read the manual pages fai-chboot(8).
-EOM
+  &VERSION_MESSAGE;
+  &HELP_MESSAGE;
   exit 0;
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -171,11 +218,43 @@
   my ($ipadr,$hex) = host2hex($host);
   print "reenable pxe config for $host in hex $hex\n" if $verbose;
   return if $opt_n;
-  rename "$pxedir/$hex.disable","$pxedir/$hex" or $error .= "\nRename for $hex 
failed.$! $@";
+  if (-e $pxedir/$hex) {
+    print "$host ($hex) is already enabled\n";    
+  } elsif (-e $pxedir/$hex.disable ) {
+    rename "$pxedir/$hex.disable","$pxedir/$hex" or $error .= "\nRename for 
$hex failed. $! $@";
+  } else {
+      print "$host ($hex) is not disabled\n";
+  }
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+sub fcopy {
+  my ($srchost) = shift;
+  my ($desthost) = shift;
 
-getopts('Bd:ehnvlLiIp:f:Frk:So');
+  if (gethost($srchost)) {
+    my ($ipadr,$srchex) = host2hex($srchost);
+    if (-e "$pxedir/$srchex") {
+      $srcfile = "$pxedir/$srchex";
+    } elsif (-e "$pxedir/$srchex.disable") {
+      $srcfile = "$pxedir/$srchex.disable";
+    } elsif (-e "$pxedir/$srchost" ) {
+      $srcfile = "$pxedir/$srchost";
+    } else {
+      die "Source file for $srchost ($srchex) not available\n";
+    }
+  } elsif ( -e "$pxedir/$srchost") {
+      $srcfile = "$pxedir/$srchost";
+  } else {
+      die "Source file for $srchost not available\n";
+  }
+    
+  my ($ipadr,$desthex) = host2hex($desthost);
+  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.$! $@";
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+getopts('Bcd:ehnvlLiIp:f:Frk:So');
 $opt_h and usage;
 defined @ARGV or usage;
 
@@ -183,7 +262,7 @@
 $opt_v and $verbose = 1;
 $pxedir = $opt_d || '/boot/fai/pxelinux.cfg';
 $opt_L and $opt_l = 1;
-$opt_l and lsdir;
+$opt_l and lsdir(@ARGV);
 ($opt_B and $opt_F) && die "ERROR: use only one option out of -B and -F\n";
 ($opt_S and $opt_I) && die "ERROR: use only one option out of -I and -S\n";
 
@@ -196,6 +275,17 @@
   exit 0;
 }
 
+if ($opt_c) {
+  my ($srchost) = shift @ARGV;
+  die "Missing source (host) name. Can't copy.\n" unless $srchost;
+  die "Missing destination host name(s). Can't copy.\n" unless @ARGV;
+  foreach (@ARGV) {
+    fcopy("$srchost", "$_");
+  }
+  $error and die "$0: $error\n";
+  exit 0;
+}
+
 if ($opt_e) {
   die "Missing host name(s). Can't reenable network booting.\n" unless @ARGV;
   foreach (@ARGV) {
Index: man/fai-chboot.8
===================================================================
--- man/fai-chboot.8    (revision 3156)
+++ man/fai-chboot.8    (working copy)
@@ -7,7 +7,7 @@
 [OPTION]... KERNELNAME ROOTFS HOST...
 .br
 .B fai-chboot
--l
+-l|-L [-v|[HOST|IP|HEX]...]
 .br
 .B fai-chboot
 -e HOST...
@@ -16,6 +16,9 @@
 -r HOST...
 .br
 .B fai-chboot
+-c HOST|template HOST...
+.br
+.B fai-chboot
 -i [OPTION]... HOST...
 .br
 .B fai-chboot
@@ -36,6 +39,11 @@
 Set default values for FAI_FLAGS. This is the same as -f
 verbose,sshd,syslogd,reboot
 .TP
+.B \-c
+Copy a config file from a host or a template to one or more  hosts and enable 
+them for network booting. 
+Either hostnames or IP addresses works.
+.TP
 .BI "\-d " DIR
 Set the default directory for the network boot configuration to
 DIR. The default value is /boot/fai/pxelinux.cfg/.
@@ -67,10 +75,12 @@
 Set kernel append parameters.
 .TP
 .B \-l
-List the configuration for all hosts in short format.
+List the configuration for specified host(s) or all hosts if no host is given, 
+in short format. You can specify the host by name, by IP address or by the IP 
+address in uppercase hexadecimal. With \-v specified templates are also listed.
 .TP
 .B \-L
-List the configuration for all hosts. Also list the kernel append parameters.
+Same as \-l but also list the kernel append parameters.
 .TP
 .B \-n
 Do not create configuration but show what will be done. This also

--- End Message ---
--- Begin Message ---
Source: fai
Source-Version: 2.10

We believe that the bug you reported is fixed in the latest version of
fai, which is due to be installed in the Debian FTP archive:

fai-client_2.10_all.deb
  to pool/main/f/fai/fai-client_2.10_all.deb
fai-doc_2.10_all.deb
  to pool/main/f/fai/fai-doc_2.10_all.deb
fai-nfsroot_2.10_all.deb
  to pool/main/f/fai/fai-nfsroot_2.10_all.deb
fai-quickstart_2.10_all.deb
  to pool/main/f/fai/fai-quickstart_2.10_all.deb
fai-server_2.10_all.deb
  to pool/main/f/fai/fai-server_2.10_all.deb
fai_2.10.dsc
  to pool/main/f/fai/fai_2.10.dsc
fai_2.10.tar.gz
  to pool/main/f/fai/fai_2.10.tar.gz



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [EMAIL PROTECTED],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Thomas Lange <[EMAIL PROTECTED]> (supplier of updated fai package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [EMAIL PROTECTED])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Mon,  3 Apr 2006 15:11:30 +0200
Source: fai
Binary: fai-client fai-server fai-doc fai-quickstart fai-nfsroot
Architecture: source all
Version: 2.10
Distribution: unstable
Urgency: low
Maintainer: Thomas Lange <[EMAIL PROTECTED]>
Changed-By: Thomas Lange <[EMAIL PROTECTED]>
Description: 
 fai-client - Fully Automatic Installation client package
 fai-doc    - Documentation for FAI
 fai-nfsroot - Fully Automatic Installation nfsroot package
 fai-quickstart - Fully Automatic Installation quickstart package
 fai-server - Fully Automatic Installation server package
Closes: 277079 312201 312296 314613 341577 342471 344536 347974 348350 350015 
352939 356136 356265 356378 360183
Changes: 
 fai (2.10) unstable; urgency=low
 .
   * setup_harddisks: mapdisk(): add support for more than two disks, fix
     wrong comments (closes: #356265), allow logical partitions to be
     bootable (closes: #344536)
   * make-fai-nfsroot: do not copy files from /etc/apt to the nfsroot,
     detect kernel version for new kernel name (closes: 352939),
     remove patches-* file when using -K (closes: #348350), remove
     update-modules call, remove symlink creation to /tmp, add warning if
     $FAI_LOCAL_REPOSITORY is still used
   * fai-chboot: change output of -l and -L, major rework of the lsdir
     function, add more options for different listing formats, add template
     copy function (closes: #342471, #356136), options added: -g -c -t -o
   * 20-hwdetect.source: test if discover is installed
   * make-fai-bootfloppy: remove obsolete message (closes: #347974)
   * fcopy: remove newline from $source, add \Q, (closes: #350015), warning
     if unlink fails, add option -n (closes: #356378), preserving is not an
     error (closes: #360183)
   * make example scripts more cfengine2 compatible (closes: #312201)
   * hooks/instsoft.FAIBASE: do not pause when kernel modules are already
     available (closes: #314613)
   * install_packages: new feature, just unpack packages (closes: #277079),
     add urpmi, urpme and yum support
   * fai: exit script if no parameters are given and no run from nfsroot
   * subroutines: add verbose output when defining variables, add
     subroutines mkrw and mkrwsize, set $diskvar during softupdate to
     /var/log/fai/disk_var.sh, task_savelog: test if files exist before
     copying them
   * remove FAIBASE/20-save_diskvar (closes: #312296)
   * task_sysinfo: call lshw if available
   * lib/get-boot-info: remove duplicate network device names
   * make-fai-nfsroot.conf: use SERVERINTERFACE for detecting subnet
     (closes: #341577)
   * create_ramdisk: use mkrw for making directories writeable
   * fai-mirror: add warning if some files do not exist
Files: 
 8c9fef9ec1bb8ec6174bd829b39cee34 579 admin extra fai_2.10.dsc
 7d6707e385bceb50178760eef08bf345 180858 admin extra fai_2.10.tar.gz
 5b6eb9b5b58c68343db9089c73e507fd 86088 admin extra fai-client_2.10_all.deb
 cdb93e6c9fc9f9e40de79dfeec2d070c 504822 admin extra fai-doc_2.10_all.deb
 bb4830f212d02470abad0dd3f361c6aa 34704 admin extra fai-server_2.10_all.deb
 91e9bc7e5bae585933babce41f7b7801 1774 admin extra fai-quickstart_2.10_all.deb
 71c57d4a786ccf4280495bbb4958e15b 30944 admin extra fai-nfsroot_2.10_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEMR9c3BPlTqubZv0RAmdEAKCKS3QmeIlm9b77VXl2+kmckAFW1wCfcFwF
zvxRX18c5/B/HT3+alJPoao=
=Diqh
-----END PGP SIGNATURE-----


--- End Message ---

Reply via email to