123456789101112131415161718192021222324252627282930313233343536373839404142 |
-
-
-
-
-
-
-
-
- $useipaddr = 0;
-
- $domainname = "ken.com.au";
- $tftpdir = "/tftpdir/";
- open(B, "/etc/bootptab") or die "/etc/bootptab: $!\n";
- while(<B>) {
- if (/^[^a-z]/) {
- $prevline = $_;
- next;
- }
- chomp($_);
- ($hostname, @tags) = split(/:/, $_, 5);
- ($fqdn = $hostname) .= ".$domainname" unless($hostname =~ /\./);
- ($macaddr) = grep(/^ha=/, @tags);
- $macaddr =~ s/ha=//;
- $macaddr =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/g;
- ($ipaddr) = grep(/^ip=/, @tags);
- $ipaddr =~ s/ip=//;
- ($bootfile) = grep(/^bf=/, @tags);
- $bootfile =~ s/bf=//;
- $bootfile = $tftpdir . $bootfile;
-
- print $prevline if ($prevline =~ /^#/);
- $address = $useipaddr ? $ipaddr : $fqdn;
- print <<EOF
- host $hostname {
- hardware ethernet $macaddr;
- fixed-address $address;
- filename "$bootfile";
- }
- EOF
- ;
- $prevline = $_;
- }
|