]> code.ossystems Code Review - openembedded-core.git/commitdiff
dhcp: add systemd service files
authorChen Qi <Qi.Chen@windriver.com>
Wed, 3 Sep 2014 07:09:07 +0000 (15:09 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 3 Sep 2014 09:24:21 +0000 (10:24 +0100)
Add dhcpd.service and dhcrelay.service to support systemd systems.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-connectivity/dhcp/dhcp.inc
meta/recipes-connectivity/dhcp/files/dhcpd.service [new file with mode: 0644]
meta/recipes-connectivity/dhcp/files/dhcrelay.service [new file with mode: 0644]

index 512127cd4c89a85572b9901d201c15b0585a1bb7..a1752548be641800f1c5fd809a5c3dc638e745ca 100644 (file)
@@ -14,11 +14,19 @@ DEPENDS = "openssl bind"
 
 SRC_URI = "ftp://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
            file://site.h \
-          file://init-relay file://default-relay \
-          file://init-server file://default-server \
-          file://dhclient.conf file://dhcpd.conf"
+           file://init-relay file://default-relay \
+           file://init-server file://default-server \
+           file://dhclient.conf file://dhcpd.conf \
+           file://dhcpd.service file://dhcrelay.service"
 
-inherit autotools
+inherit autotools systemd
+
+SYSTEMD_PACKAGES = "dhcp-server dhcp-relay"
+SYSTEMD_SERVICE_dhcp-server = "dhcpd.service"
+SYSTEMD_AUTO_ENABLE_dhcp-server = "disable"
+
+SYSTEMD_SERVICE_dhcp-relay = "dhcrelay.service"
+SYSTEMD_AUTO_ENABLE_dhcp-relay = "disable"
 
 TARGET_CFLAGS += "-D_GNU_SOURCE"
 EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \
@@ -51,6 +59,13 @@ do_install_append () {
                mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
        fi
        install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
+
+       # Install systemd unit files
+       install -d ${D}${systemd_unitdir}/system
+       install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
+       install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
+       sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd.service ${D}${systemd_unitdir}/system/dhcrelay.service
+       sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd.service
 }
 
 PACKAGES += "dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
diff --git a/meta/recipes-connectivity/dhcp/files/dhcpd.service b/meta/recipes-connectivity/dhcp/files/dhcpd.service
new file mode 100644 (file)
index 0000000..8648f1a
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=DHCP Server Daemon
+After=network.target
+After=time-sync.target
+
+[Service]
+EnvironmentFile=@SYSCONFDIR@/default/dhcp-server
+ExecStart=-@SBINDIR@/dhcpd -q $INTERFACES
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/recipes-connectivity/dhcp/files/dhcrelay.service b/meta/recipes-connectivity/dhcp/files/dhcrelay.service
new file mode 100644 (file)
index 0000000..a2d8189
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=DHCP Relay Agent Daemon
+After=network.target
+
+[Service]
+ExecStart=@SBINDIR@/dhcrelay -d --no-pid
+
+[Install]
+WantedBy=multi-user.target