[sanboot] Prevent leaking a stack reference for "keep-san" AoE
[gpxe.git] / contrib / bootptodhcp / bootptodhcp.pl
blobc8d6465ae9ba54ec5952283a7b7703360398f159
1 #!/usr/bin/perl -w
3 # Quick hack to convert /etc/bootptab to format required by ISC DHCPD
4 # This only outputs the fixed hosts portion of the config file
5 # You still have to provide the global options and the subnet scoping
7 # Turn $useipaddr on if you prefer to use IP addresses in the config file
8 # I run DNS so I prefer domain names
9 $useipaddr = 0;
10 # This will be appended to get the FQDN unless the hostname is already FQDN
11 $domainname = "ken.com.au";
12 $tftpdir = "/tftpdir/";
13 open(B, "/etc/bootptab") or die "/etc/bootptab: $!\n";
14 while(<B>) {
15 if (/^[^a-z]/) {
16 $prevline = $_;
17 next;
19 chomp($_);
20 ($hostname, @tags) = split(/:/, $_, 5);
21 ($fqdn = $hostname) .= ".$domainname" unless($hostname =~ /\./);
22 ($macaddr) = grep(/^ha=/, @tags);
23 $macaddr =~ s/ha=//;
24 $macaddr =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/g;
25 ($ipaddr) = grep(/^ip=/, @tags);
26 $ipaddr =~ s/ip=//;
27 ($bootfile) = grep(/^bf=/, @tags);
28 $bootfile =~ s/bf=//;
29 $bootfile = $tftpdir . $bootfile;
30 # I have a comment line above most entries and I like to carry this over
31 print $prevline if ($prevline =~ /^#/);
32 $address = $useipaddr ? $ipaddr : $fqdn;
33 print <<EOF
34 host $hostname {
35 hardware ethernet $macaddr;
36 fixed-address $address;
37 filename "$bootfile";
39 EOF
41 $prevline = $_;