Commit 938056f9 authored by Eric Le Bihan's avatar Eric Le Bihan Committed by Thomas Petazzoni
Browse files

dhcp: add systemd service file



Add a systemd service file to start dhcpd.

The network interfaces to listen on can be set via the variable
INTERFACES in /etc/default/dhcpd.conf. Example:

  INTERFACES="eth0 eth1"

Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
(needed at dhcpd start-up).

Signed-off-by: default avatarEric Le Bihan <eric.le.bihan.dev@free.fr>
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent 146f69ec
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -73,6 +73,21 @@ define DHCP_INSTALL_INIT_SYSV
		$(TARGET_DIR)/etc/init.d/S80dhcp-relay
endef

define DHCP_INSTALL_INIT_SYSTEMD
	$(INSTALL) -D -m 644 package/dhcp/dhcpd.service \
		$(TARGET_DIR)/lib/systemd/system/dhcpd.service

	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants

	ln -sf ../../../../lib/systemd/system/dhcpd.service \
		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service

	echo "d /var/lib/dhcp 0755 - - - -" > \
		$(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf
	echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \
		$(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf
endef

define DHCP_INSTALL_TARGET_CMDS
	$(DHCP_INSTALL_RELAY)
	$(DHCP_INSTALL_SERVER)
+13 −0
Original line number Diff line number Diff line
[Unit]
Description=DHCP server
After=network.target

[Service]
Type=forking
PIDFile=/run/dhcpd.pid
ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES
KillSignal=SIGINT
EnvironmentFile=/etc/default/dhcpd.conf

[Install]
WantedBy=multi-user.target