]> rtime.felk.cvut.cz Git - novaboot.git/blobdiff - novaboot
dhcpd: Add sample config for different PXEClient architectures
[novaboot.git] / novaboot
index 3403bfd063db43cdc580eb2d6f8331a66bb3c065..1fdfd52e9eea29c831c02d207591a0fa66a5c26d 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -1138,10 +1138,19 @@ if (defined $dhcp_tftp)
     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;
@@ -1161,19 +1170,21 @@ host server {
 
 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);