#!/bin/sh
# DHCP for the host on the USB network: hands it 172.16.42.2, the address the
# initramfs gave it, and nothing else (no router, no DNS, no DNS server of its
# own: port 0).  Without it the host loses its address whenever the USB link
# comes up again after the initramfs -- a replugged cable, or the ACM
# function stage 1 adds (01-acm-console.sh) -- and ping, ssh and netconsole
# fail although the phone runs (docs/BOOT.md).  Its own options, not
# /etc/dnsmasq.conf: Void's dnsmasq service stays as Void ships it.
exec 2>&1
[ -d /sys/class/net/usb0 ] || { sv down "${PWD##*/}"; exit 0; }
exec dnsmasq --keep-in-foreground --conf-file=/dev/null --port=0 \
	--interface=usb0 --bind-dynamic --dhcp-authoritative \
	--dhcp-range=172.16.42.2,172.16.42.2,255.255.255.0,12h \
	--dhcp-option=3 --dhcp-option=6 \
	--dhcp-leasefile=/run/usb0-dhcp.leases --log-facility=-
