[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PXE, automatic installation and reboot



On Thu, 2013-07-25 at 17:30 +0200, Jimmy Thrasibule wrote:
> Hi,
> 
> I've setup and environment to automatically install some Debian boxes
> via the network using PXE, TFTP and Preseed. If this part is working
> fine, I'm facing a little issue when the installation is done.
> 
> I'm trying to make everything automatic with no human intervention. The
> problem is that when the installation is done, the box will reboot, boot
> again using PXE and start a new installation process.

You can prevent that from happening by using a specific configuration
file for every machine you install. The name of the file is based on the
HEX of the IP address that the machine will get from DHCP when you PXE
boot.

E.G. have a file called 0A641901 for a machine with IP 10.100.25.1

You also have a default file in your pxelinux.cfg file with the
following in it:

# generated by fai-chboot
default fai-generated

label fai-generated
localboot 0

You then have a simple PHP script to move the boot config to,
say, .disabled and when the machine reboots it will boot from local
disk.

Example PHP script:

<?php

if (isset($_SERVER['REMOTE_ADDR']))
    $ip = $_SERVER['REMOTE_ADDR'];
else
    $ip="192.168.1.203";

$long=ip2long($ip);
$hex=dechex($long);
$hex=strtoupper($hex);
print "$hex\n";
$origin = "/var/lib/tftpboot/pxelinux.cfg/$hex";
$destination = "/var/lib/tftpboot/pxelinux.cfg/$hex.disabled";
passthru("mv $origin $destination");

You can call this script from your preseed/late_command target

Cheers

Iain


> 
> How can I prevent that without having to monitor every installation
> process? The idea would be to kind of deny access to `pxelinux.0` when a
> host had already made a request.
> 
> --
> Jimmy
> 
> 
> 



Reply to: