#!/opt/bin/perl $self = $0; $self =~ s!^.*/!!; $mnt_target = "/mnt"; $mnt_source = "sunfi1.fi:/bootp"; $bootptab = "bootptab"; $hostdir = "/s/tftpboot/host"; $rc = system("/etc/mount $mnt_source $mnt_target") >> 8; if ($rc) { die "$self: can't mount '$mnt_source' to '$mnt_target': $rc\n"; } unless (open(BOOTPTAB, "<$mnt_target/$bootptab")) { die "$self: can't read '$mnt_source/$bootptab': $!\n"; } while () { next if /^\s*#/; @item = split(/:/); next if (@item < 2); $host = $item[0]; $file = "$host.fi.sdm.de"; foreach $entry (@item) { if ($entry =~ /^ip=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) { $addr = $1; } } next if ($addr eq ''); if (-f "$hostdir/$file") { warn "$self: file '$hostdir/$file' already exists!\n"; next; } unless (open(HOST, ">$hostdir/$file")) { warn "$self: can't write '$hostdir/$file': $!\n"; next; } print HOST "hostname=$host\n"; print HOST "ip-nr=$addr\n"; print HOST "domain=fi.sdm.de\n"; close(HOST); } close(BOOTPTAB); $rc = system("/etc/umount $mnt_target") >> 8; if ($rc) { die "$self: can't unmount '$mnt_source' at '$mnt_target': $rc\n"; } __END__