Network: Diskless Booting III: Automating things

(last edit: 2001-05-01)


I wanted to be able to put a floppy in a pc with no graphical card and netinstall that machine complete automatically. The first step was to let the machine boot via the floppy. But my bootpd server didn't knew the MAC address and I had no monitor to find it out. Bootpd logs an errormessage to syslog with the unknown MAC address if the new machine tries to boot itself. I've set up syslog that it starts a perl script when such an error appears and this perl script adds the MAC address to the '/etc/bootptab' file so when the machine goes for its second broadcast it will be servered by the bootpd server.


To redirect the error messages to my perl script I had to add this lines: !bootpd *.* |exec /sbin/dynbootptab Don't forget to do a 'killall -HUP syslogd' to make the changes active.

The perl script

This is what the perlscript looks like: --- !/usr/bin/perl -w use strict; my $logFile = "/var/log/dynbootptab.log"; my $bootptab= "/etc/bootptab"; my $hostname= "diskless"; my $master = ""; my $rootfs = "/usr/diskless"; my $ip = ""; my ($sec, $min, $hour, $day, $month, $year) = localtime(); my $message = ; chomp($message); open (LOG, ">>$logFile"); if(defined($message)) { if($message =~ /^[a-z0-9\s\[\]:]+ unknown client Ethernet address ([a-z0-9\:]+)$/i) { print LOG <<"EOM"; ===NEW MAC=== $month-$day-$year $hour:$min:$sec :New mac $1 detected"; ============= EOM $message = $1; $message =~ s/://g; open(TAB, ">$bootptab") || print LOG "\n$month-$day-$year $hour:$min:$sec : Can't write to '$bootptab'"; print TAB <<"EOT"; .default:\\ :ht=ethernet:\\ :hd=$rootfs:\\ :bf=kernel:\\ :sm=\\ :rp="$master:$rootfs":\\ :hn:\\ :vm=rfc1048: $hostname:ha=$message:ip=$ip:tc=.default: EOT close(TAB); } else { print LOG "\n$month-$day-$year $hour:$min:$sec : $message"; } } else { print LOG "\n$month-$day-$year $hour:$min:$sec : Updatebootptab called without input."; } close (LOG); --- It does the following: it filters the MAC addres out if the MAC error has occured, rewrites the ENTIRE '/etc/bootptab' file and logs this action. If it hasn't found the MAC error it simply logs the error to '/var/log/dynbootptab.log'. It 'a good thing' to configure newsyslogd so that this log file doesn't get to big. This might seem like a simple script to you or maybey even not useable at all but it works perfect for my situation and maybey this info can help you in anyway. Previous is Setting up the client

Click here to go back to the index.