Package: fai-server Version: 3.1 Severity: minor
fai-chboot lists wrong information in several other cases as well.
Here is the list of bugs I have found and fixed:
- the option -p expected an argument
- when fai-chboot gets no ROOTFS it complained about missing host
- the default-file was treated special and not displayed with -ld or
-le
- some hex-files in the tftp-dir were (only in some cases)
classified as type = Other
- subnets were not calculated/displayed correctly
- fai-chboot -L wrote the name for templates and default-files
twice instead of the type followed by name
- fai-chboot -Ld ignored default.disable but printed disabled
host that also were enabled (which should override it)
- when a new pxe config was created, existing disable-files were
left untouched (this is not really a bug, but IMO not what one
would expect)
- if a hostname was given to -c and only a template was found it
still used the host-file as source, resulting in an empty
destination
- the manpage for fai-chboot did not mention that "default" may be
specified instead of a hostname or IP
- the default directory for -D in the manpage was wrong
- there was not hint in the manpage that -l option combinations
are exclusive and may not be combined (-lte, ...)
- the manpage did not mention anything about the -o option
multiplexing (-o vs. -l -o)
To make things a bit more clear, here are first some examples with the
original fai-chboot followed by the same examples with my patched
version.
# ------- current version --------
# ls /srv/tftp/fai/pxelinux.cfg/
C C0A8 C0A80A01 C0A80A7 default.disable
C0 C0A80 C0A80A01.disable C0A80A71 foo.tmpl
C0A C0A80A.disable C0A80A64 C0A81 foobar
# fai-chboot -lgv
[Other] default.disable sysinfo vmlinuz-install
[Other] C install vmlinuz-install
[Other] C0 install vmlinuz-install
[Other] C0A install vmlinuz-install
Subnet: 192.168 C0A80 install vmlinuz-install
Subnet: 192.168 C0A80 install vmlinuz-install
Subnet: 192.168 C0A80 install vmlinuz-install
Subnet: 192.168. C0A80A.disable install vmlinuz-install
bart C0A80A71 install vmlinuz-install
boss C0A80A01.disable install vmlinuz-install
marvin C0A80A64 sysinfo vmlinuz-install
Subnet: 192.168. C0A80A.disable install vmlinuz-install
boss C0A80A01.disable install vmlinuz-install
[Template] foo.tmpl sysinfo vmlinuz-install
[Other] foobar sysinfo vmlinuz-install
# fai-chboot -Ldv
Subnet: 192.168.10 C0A80A.disable vmlinuz-install ip=dhcp FAI_ACTION=install
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,tcp,rsize=32768,wsize=32768
FAI_FLAGS=verbose,sshd,reboot
boss C0A80A01.disable vmlinuz-install ip=dhcp FAI_ACTION=install root=/dev/nfs
nfsroot=/srv/fai/nfsroot,v3,tcp,rsize=32768,wsize=32768
# fai-chboot -Ltv
foo.tmpl foo.tmpl vmlinuz-install ip=dhcp devfs=nomount FAI_ACTION=sysinfo
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,proto=tcp
FAI_FLAGS=verbose,sshd,createvt
# fai-chboot -Lo
foobar foobar vmlinuz-install ip=dhcp devfs=nomount FAI_ACTION=sysinfo
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,proto=tcp
FAI_FLAGS=verbose,sshd,createvt
# fai-chboot -p foo
No host specified.
# ------- patched version --------
# fai-sources/bin/fai-chboot -lgv
Skipping C0A80A01.disable as disabled host because also enabled.
Subnet: 192.160/12 C0A install vmlinuz-install
Subnet: 192.168.0/20 C0A80 install vmlinuz-install
Subnet: 192.168.10.112/28 C0A80A7 install vmlinuz-install
Subnet: 192.168.16/20 C0A81 install vmlinuz-install
Subnet: 192.168/16 C0A8 sysinfo vmlinuz-install
Subnet: 192/4 C install vmlinuz-install
Subnet: 192/8 C0 install vmlinuz-install
bart C0A80A71 install vmlinuz-install
boss C0A80A01 install vmlinuz-install
marvin C0A80A64 sysinfo vmlinuz-install
Subnet: 192.168.10/24 C0A80A.disable install vmlinuz-install
[DEFAULT] default.disable sysinfo vmlinuz-install
[Template] foo.tmpl sysinfo vmlinuz-install
[Other] foobar sysinfo vmlinuz-install
# fai-sources/bin/fai-chboot -Ldv
Skipping C0A80A01.disable as disabled host because also enabled.
Subnet: 192.168.10/24 C0A80A.disable vmlinuz-install ip=dhcp FAI_ACTION=install
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,tcp,rsize=32768,wsize=32768
FAI_FLAGS=verbose,sshd,reboot
[DEFAULT] default.disable vmlinuz-install ip=dhcp FAI_ACTION=sysinfo
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,tcp,rsize=32768,wsize=32768
FAI_FLAGS=verbose,sshd,createvt
# fai-sources/bin/fai-chboot -Ltv
Skipping C0A80A01.disable as disabled host because also enabled.
[Template] foo.tmpl vmlinuz-install ip=dhcp devfs=nomount FAI_ACTION=sysinfo
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,proto=tcp
FAI_FLAGS=verbose,sshd,createvt
# fai-sources/bin/fai-chboot -Lo
[Other] foobar vmlinuz-install ip=dhcp devfs=nomount FAI_ACTION=sysinfo
root=/dev/nfs nfsroot=/srv/fai/nfsroot,v3,proto=tcp
FAI_FLAGS=verbose,sshd,createvt
# fai-sources/bin/fai-chboot -p foo
No rootfs specified.
Regards,
thpo
--
| Thomas Pöhnitzsch, Dipl.-Inf. | foobar GmbH |
| System Management/Software Development | Bernsdorfer Str. 210-212 |
| Tel.: +49 371 5221 - 160 Fax: - 158 | 09126 Chemnitz/Germany |
| E-Mail: [EMAIL PROTECTED] | http://www.foobar-cpa.de |
Index: bin/fai-chboot
===================================================================
--- bin/fai-chboot (revision 4112)
+++ bin/fai-chboot (working copy)
@@ -79,63 +79,76 @@
opendir(DIR, $pxedir) || die "can't opendir $pxedir: $!";
foreach (readdir(DIR)) {
next if /^\./;
- if (/^default/) { push @default, $_ ; next};
- if (/^[0-9A-F]+$/) { push @enabled, $_ ; next};
- if (/\.disable$/) { push @disabled, $_ ; next};
- if (/\.tmpl$/) { push @templates, $_ ; next};
+ if (/^(default|[0-9A-F]+)$/) { push @enabled, $_ ; next};
+ if (/\.tmpl$/) { push @templates, $_ ; next};
+ if (/\.disable$/) {
+ if (-f (split /\./)[0]) {
+ warn "Skipping $_ as disabled host because also enabled.\n" if
$verbose;
+ } else {
+ push @disabled, $_;
+ }
+ next;
+ };
push @other, $_;
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub lsdir {
-# -lr list only disabled hosts
+# -ld list only disabled hosts
# -le list only enabled hosts
# -lt list only templates
# -lo list only "other", i.e that does not match templates or hosts
# -lg list by goups (enabled, disabled, templates, others)
-# -l[retog] <pattern> list matching pattern
+# -l[detog] <pattern> list matching pattern
- my (@n,$host,$ip,$iaddr,$hex,$type);
+ my ($n,$host,$iaddr,$hex,$type);
@patterns = @_; # a global variable
readpxedir();
# create list which entries we want to list
- @allfiles = (@default,@enabled,@disabled,@templates,@other);
+ @allfiles = (@enabled,@disabled,@templates,@other);
$opt_d and @allfiles = @disabled;
$opt_e and @allfiles = @enabled;
$opt_t and @allfiles = @templates;
$opt_o and @allfiles = @other;
- $opt_g and @allfiles = (@default,@enabled,@disabled,@templates,@other);
+ $opt_g and @allfiles = (@enabled,@disabled,@templates,@other);
# map all entries (in HEX) to hostname or IP
foreach $hex (@allfiles) {
- undef $type;
- # hex to ip address
- @n = $hex =~ m/[0-9A-F][0-9A-F]/g;
- $ip = join ('.', map {$_ = hex $_} @n);
+ undef $host,$type;
- if ($hex =~ /^default$/) {
+ if ($hex =~ /^default(.disable)?$/) {
$host = $hex;
$type = '[DEFAULT]';
} elsif ($hex =~ /\.tmpl$/) {
$host = "$hex";
$type = '[Template]';
- } elsif ($#n > 0 && $#n < 3) {
- # Don't fail if not a complete IP
- $host = "Subnet: $ip";
- } else {
- # ip to hostname
- $iaddr = inet_aton($ip);
- if ($h = gethostbyaddr($iaddr, AF_INET)) {
- $host = $h->name;
- $host =~ s/^([^.]+).*/$1/; # strip domain from FQDN so we have short
hostnames
- } else {
+ } elsif ($hex =~ /[0-9A-F]+/) {
+ my $hexstrip = (split /\./,$hex)[0]; # remove .disable if necessary
+ $n = $hexstrip;
+ # hex to ip/subnet address
+ while ( length $n ) {
+ $host = sprintf( "%s%d" ,$host?"$host.":$host,
+ (hex substr $n,0,1,"" ) * 16 + (hex substr
$n,0,1,""));
+ }
+ if ( $host and ( length($hexstrip) < 8) ) {
+ $host = "Subnet: $host/". length($hexstrip)*4
+ } else {
+ # ip to hostname
+ $iaddr = inet_aton($host);
+ if ($h = gethostbyaddr($iaddr, AF_INET)) {
+ $host = $h->name;
+ $host =~ s/^([^.]+).*/$1/; # strip domain from FQDN so we have
short hostnames
+ }
+ }
+ }
+
+ if ( !$host ) {
$host = $hex;
$type = '[Other]';
- }
}
$hexname{$host} = $hex;
$hname{$hex}= $host;
@@ -143,7 +156,6 @@
}
if ($opt_g) { # print in group, sorted inside each group
- prtsorted(@default);
prtsorted(@enabled);
prtsorted(@disabled);
prtsorted(@templates);
@@ -190,9 +202,9 @@
$append =~ /FAI_ACTION=(\S+)/;
$append = $1;
# printf "%-16.16s $append $kernelname %-8s\n",$host,$hex;
- printf "%-16.16s %-20.20s $append $kernelname\n",$type?$type:$host,$hex;
+ printf "%-26.26s %-20.20s $append $kernelname\n",$type?$type:$host,$hex;
} else {
- printf "%s %s $kernelname $append\n",$host,$hex;
+ printf "%s %s $kernelname $append\n",$type?$type:$host,$hex;
}
undef $append;
@@ -225,11 +237,15 @@
my ($ipadr,$hex) = host2hex($host);
warn "$host has $ipadr in hex $hex\n" if $verbose;
+ if (-f "$pxedir/$hex.disable") {
+ unlink "$pxedir/$hex.disable";
+ print "removed old $pxedir/$hex.disable\n";
+ }
warn "Writing file $pxedir/$hex for $host\n" if $verbose;
return if $opt_n;
if ($opt_p && -e "$pxedir/$hex") {
- warn "WARNING: $pxedir/$hex already exists. Skipping file creation. ";
+ warn "WARNING: $pxedir/$hex already exists.\nSkipping file creation. ";
return;
}
open (FILE,"> $pxedir/$hex") or warn "$0 $@ $!";
@@ -305,7 +321,7 @@
} elsif (-e "$pxedir/$srchost" ) {
$srcfile = "$pxedir/$srchost";
} elsif (-e "$pxedir/$srchost.tmpl" ) {
- $srcfile = "$pxedir/$srchost";
+ $srcfile = "$pxedir/$srchost.tmpl";
} else {
warn "Source file for $srchost ($srchex) not available\n";
return;
@@ -313,7 +329,7 @@
} elsif ( -e "$pxedir/$srchost") {
$srcfile = "$pxedir/$srchost";
} elsif ( -e "$pxedir/$srchost.tmpl") {
- $srcfile = "$pxedir/$srchost";
+ $srcfile = "$pxedir/$srchost.tmpl";
} else {
warn "Source file for $srchost not available\n";
return;
@@ -336,7 +352,7 @@
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-getopts('gBc:D:edhnvlLiIp:f:Fk:Sto');
+getopts('gBc:D:edhnvlLiIpf:Fk:Sto');
$opt_h and usage;
defined @ARGV or usage;
@@ -406,7 +422,7 @@
} else {
$kernelname = shift;
$kernelname = "kernel $kernelname";
- $rootfs = shift;
+ $rootfs = shift or die "No rootfs specified.\n";
}
$opt_F and $opt_f="verbose,sshd,createvt";
Index: man/fai-chboot.8
===================================================================
--- man/fai-chboot.8 (revision 4112)
+++ man/fai-chboot.8 (working copy)
@@ -7,7 +7,7 @@
[OPTION]... KERNELNAME ROOTFS HOST...
.br
.B fai-chboot
--l [-e|-d|-t|-o|-g] [PATTERN]
+-l[e|d|t|o|g] [PATTERN]
.br
.B fai-chboot
-e HOST...
@@ -16,7 +16,7 @@
-d HOST...
.br
.B fai-chboot
--c HOST|TEMPLATE HOST...
+-c HOST|TEMPLATE HOST|TEMPLATE...
.br
.B fai-chboot
-i [OPTION]... HOST...
@@ -31,7 +31,7 @@
additional kernel parameters and define some FAI specific flags. For
each host one configuration file is created. The file name of the
configuration file is its IP address in upper case hexadecimal. HOST
-can be a host name or an IP address.
+can be a host name, an IP address or the keyword "default".
.SH OPTIONS
.TP
@@ -45,7 +45,7 @@
.TP
.BI "\-D " DIR
Set the default directory for the network boot configuration to
-DIR. The default value is /srv/tftp/pxelinux.cfg/.
+DIR. The default value is /srv/tftp/fai/pxelinux.cfg/.
.TP
.B \-d
Disable network booting for HOST. This renames the config file and adds
@@ -79,12 +79,13 @@
.B \-l
List the configuration for all hosts in short format. If PATTERN is
given, list only hosts matching PATTERN. Lists hostname, FAI_ACTION,
-kernel name and IP address in hex. With \fB\-l\fR, list only enabled hosts.
-With \fB-d\fR list only disabled hosts.
-With \fB-t\fR list only templates.
-With \fB-o\fR list only hosts that does not match any of the other categories.
-With \fB-g\fR list the configuration for all hosts, sorted and ordered by
-groups (enabled, disabled, templates, others).
+kernel name and IP address in hex. Use \fB\-le\fR, to list only enabled hosts,
+\fB-ld\fR to list only disabled hosts, \fB-lt\fR to list only templates,
+\fB-lo\fR to list only hosts that do not match any of the other before
+mentioned categories, and \fB-lg\fR to list the configuration for all hosts,
+sorted and ordered by groups (enabled, disabled, templates, others).
+Note that a combination of multiple \fB-l\fR options is not supported and that
+in listing mode no other action will be performed.
.TP
.B \-L
List the configuration for all hosts. Also list the kernel append parameters.
signature.asc
Description: Digital signature

