OpenWrt LuCI module for PXE boot menu
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

The task is to write a module for LuCI (Web UI used in OpenWrt written in LUA) that allows to view and change the default boot item for PXE menu on a per-MAC basic. It shouldn't be architecture-dependent (i.e. work both on ARM and X86).

It could either have a new config file in /etc/config, say /etc/config/pxemenu and a script that generates the PXE config files from that, or it could directly change the PXE config files, I don't care which approach is chosen, my guess is that the first one is easier.

In /srv/tftp/pxelinux.cfg/ there are following files:

options containing a list of options, looking like this (example):

LABEL ubuntu-18.04.3-desktop-amd64
  MENU LABEL Ubuntu 18.04.3 Desktop
  KERNEL ubuntu-18.04.3-desktop-amd64/vmlinuz.efi
  APPEND initrd=ubuntu-18.04.3-desktop-amd64/initrd.lz boot=casper netboot=nfs nfsroot=192.168.0.1:/srv/nfs4/ubuntu-18.04.3-desktop-amd64 splash --

LABEL winpe32
  MENU LABEL Windows PE 32bit
  KERNEL memdisk
  INITRD winpe10/winpe32.iso
  APPEND iso raw

LABEL winpe64
  MENU LABEL Windows PE 64bit
  KERNEL memdisk
  INITRD winpe10/winpe64.iso
  APPEND iso raw

LABEL hdd
  MENU LABEL Boot from hard drive
  LOCALBOOT 0

multiple 01-0a-0b-0c-0d-0e-0f (01- followed by a MAC which uses - for separators), containing, for example:

# NAME: computer1
INCLUDE pxelinux.cfg/base
DEFAULT hdd
INCLUDE pxelinux.cfg/options

The UI will display a list of hosts which are defined, and the corresponding boot menu label (based on the DEFAULT value), and allow the value to be changed, based on the sections in the options file. How other LuCI modules work is that they usually have a table listing the entries which are already defined, and allow to remove one or add a new one, which includes a drop down menu prepopulated with a list of active local hosts.

Something like this:

[computer1 (192.168.0.101) v] [Boot from hard drive v] [Edit]

As far as I know, there is no need to restart any service if the PXE config files change.

The result should be files that I can deploy onto an existing OpenWrt system, which will create a new menu item for this module. Bonus tip if it is in opkg format (package format used by OpenWrt).

Tags
web
lua

Crowdsource coding tasks.

0 Solutions