Fix dnsmasq crash by creating tftp-root dir and using subnet config
build-and-push / test (push) Successful in 38s
build-and-push / build-and-push (push) Successful in 1m22s

dnsmasq exited with status 3 because the tftp-root directory didn't
exist at startup. Also replaced hardcoded 192.168.1.0 in dhcp-range
with the configured subnet value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 21:47:07 -04:00
parent 0bf1a62897
commit 05bb242f50
+11 -1
View File
@@ -41,6 +41,9 @@ func (s *Supervisor) Start(ctx context.Context, hosts []model.Host) error {
if err := os.MkdirAll(s.cfg.RuntimeDir, 0o755); err != nil {
return fmt.Errorf("pxe: create runtime dir: %w", err)
}
if err := os.MkdirAll(s.cfg.TFTPRoot, 0o755); err != nil {
return fmt.Errorf("pxe: create tftp root: %w", err)
}
if err := s.writeConfig(hosts); err != nil {
return err
}
@@ -82,8 +85,14 @@ func (s *Supervisor) writeConfig(hosts []model.Host) error {
return fmt.Errorf("pxe: write dhcp-hostsfile: %w", err)
}
subnet := s.cfg.Subnet
if i := strings.Index(subnet, "/"); i != -1 {
subnet = subnet[:i]
}
conf := dnsmasqConf{
Interface: s.cfg.Interface,
Subnet: subnet,
TFTPRoot: s.cfg.TFTPRoot,
HostsFile: hostsPath,
PublicURL: s.cfg.PublicURL,
@@ -126,6 +135,7 @@ func (s *Supervisor) startProcess(ctx context.Context) error {
type dnsmasqConf struct {
Interface string
Subnet string
TFTPRoot string
HostsFile string
PublicURL string
@@ -137,7 +147,7 @@ port=0
interface={{.Interface}}
bind-interfaces
dhcp-range=tag:known,192.168.1.0,proxy
dhcp-range=tag:known,{{.Subnet}},proxy
dhcp-hostsfile={{.HostsFile}}
dhcp-ignore=tag:!known