open(my $fh, '>', 'dhcpd.conf');
my $mac = `cat /sys/class/net/$netif/address`;
chomp $mac;
- print $fh "subnet 10.23.23.0 netmask 255.255.255.0 {
- range 10.23.23.10 10.23.23.100;
- filename \"bin/boot/grub/pxegrub.pxe\";
- next-server 10.23.23.1;
+ print $fh "
+subnet 10.23.23.0 netmask 255.255.255.0 {
+ range 10.23.23.10 10.23.23.100;
+ next-server 10.23.23.1;
+}
+class \"pxe-clients\" {
+ match option vendor-class-identifier;
+}
+subclass \"pxe-clients\" \"PXEClient:Arch:00000:UNDI:002001\" {
+ option bootfile-name \"boot/grub/i386-pc/core.0\";
+}
+subclass \"pxe-clients\" \"PXEClient:Arch:00007:UNDI:003016\" {
+ option bootfile-name \"boot/grub/x86_64-efi/core.efi\";
}
host server {
hardware ethernet $mac;
if (defined $dhcp_tftp || defined $tftp) {
$tftp_port ||= 69;
+ my $tftp_root = "$builddir";
+ $tftp_root = "$server" if(defined $server);
# Prepare a GRUB netboot directory
- system_verbose("grub-mknetdir --net-directory=$builddir") if (defined $grub2_config);
+ system_verbose("grub-mknetdir --net-directory=$tftp_root") if (defined $grub2_config);
# Generate TFTP mapfile
- open(my $fh, '>', "$builddir/mapfile");
+ open(my $fh, '>', "$tftp_root/mapfile");
print $fh "# Some PXE clients (mainly UEFI) have bug. They add zero byte to the end of the
# path name. This rule removes it
r \\.efi.* \\.efi";
close($fh);
# Unfortunately, tftpd requires root privileges even with
# non-privileged (>1023) port due to initgroups().
- system_verbose("sudo in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid -m mapfile --address :$tftp_port $builddir");
+ system_verbose("sudo in.tftpd --listen --secure -v -v -v --pidfile $builddir/tftpd.pid -m mapfile --address :$tftp_port $tftp_root");
# Kill server when we die
$SIG{__DIE__} = sub { system_verbose('sudo pkill --pidfile=dhcpd.pid') if (defined $dhcp_tftp);