#!/usr/bin/env bash # Enable or disable DHCP network-boot options (option 66/67) on the provisioning LXC. # Does not stop the DHCP server or TFTP; only stops advertising netboot so devices boot from local storage. # Usage: toggle-network-boot-dhcp.sh enable | disable # Run as root (or with sudo). Install to /opt/cm4-provisioning/toggle-network-boot-dhcp.sh set -e PXE_CONF="/etc/dnsmasq.d/network-boot-pxe.conf" SNIPPET_CONTENT="# PXE options - do not edit; managed by toggle-network-boot-dhcp.sh dhcp-option=66,10.20.50.1 dhcp-option=67,start4cd.elf " case "${1:-}" in enable) echo "$SNIPPET_CONTENT" > "$PXE_CONF" systemctl reload dnsmasq 2>/dev/null || service dnsmasq reload 2>/dev/null || true echo "Network boot (DHCP options) enabled." ;; disable) rm -f "$PXE_CONF" systemctl reload dnsmasq 2>/dev/null || service dnsmasq reload 2>/dev/null || true echo "Network boot (DHCP options) disabled. Devices will get DHCP but boot from local storage." ;; status) if [ -f "$PXE_CONF" ]; then echo "enabled" else echo "disabled" fi ;; *) echo "Usage: $0 enable | disable | status" >&2 exit 1 ;; esac