[oe-commits] [openembedded-core] 03/31: dhcp: add dhclient.service
git at git.openembedded.org
git at git.openembedded.org
Sun Jul 23 07:02:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit 1e24d4d19e66d3562e587f3d890dee12ebc07947
Author: Chen Qi <Qi.Chen at windriver.com>
AuthorDate: Thu Jul 20 15:33:58 2017 +0800
dhcp: add dhclient.service
Add dhclient.service. This service file mainly comes from meta-systemd,
with modifications to take nfs boot into consideration.
While using eth0 as the nfsboot interface, we'd like dhclient service
to skip it like what ifup and connman do in sysvinit.
Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
meta/recipes-connectivity/dhcp/dhcp.inc | 21 ++++++++++--
.../dhcp/files/dhclient-systemd-wrapper | 39 ++++++++++++++++++++++
.../dhcp/files/dhclient.service | 13 ++++++++
3 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
index 292f192..db4a963 100644
--- a/meta/recipes-connectivity/dhcp/dhcp.inc
+++ b/meta/recipes-connectivity/dhcp/dhcp.inc
@@ -17,6 +17,8 @@ SRC_URI = "http://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
file://init-relay file://default-relay \
file://init-server file://default-server \
file://dhclient.conf file://dhcpd.conf \
+ file://dhclient-systemd-wrapper \
+ file://dhclient.service \
file://dhcpd.service file://dhcrelay.service \
file://dhcpd6.service \
file://search-for-libxml2.patch "
@@ -29,13 +31,16 @@ inherit autotools systemd useradd update-rc.d
USERADD_PACKAGES = "${PN}-server"
USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}"
-SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay"
+SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client"
SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service"
SYSTEMD_AUTO_ENABLE_${PN}-server = "disable"
SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service"
SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable"
+SYSTEMD_SERVICE_${PN}-client = "dhclient.service"
+SYSTEMD_AUTO_ENABLE_${PN}-client = "disable"
+
INITSCRIPT_PACKAGES = "dhcp-server"
INITSCRIPT_NAME_dhcp-server = "dhcp-server"
INITSCRIPT_PARAMS_dhcp-server = "defaults"
@@ -79,7 +84,13 @@ do_install_append () {
sed -i -e 's, at SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
sed -i -e 's, at base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
sed -i -e 's, at localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
- sed -i -e 's, at SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
+ sed -i -e 's, at SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
+
+ install -d ${D}${base_sbindir}
+ install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper
+ install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system
+ sed -i -e 's, at SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service
+ sed -i -e 's, at BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service
}
PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
@@ -97,7 +108,11 @@ FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhc
FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
-FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
+FILES_${PN}-client = "${base_sbindir}/dhclient \
+ ${base_sbindir}/dhclient-script \
+ ${sysconfdir}/dhcp/dhclient.conf \
+ ${base_sbindir}/dhclient-systemd-wrapper \
+ "
FILES_${PN}-omshell = "${bindir}/omshell"
diff --git a/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper b/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper
new file mode 100644
index 0000000..7d0e224
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# In case the interface is used for nfs, skip it.
+nfsroot=0
+interfaces=""
+exec 9<&0 < /proc/mounts
+while read dev mtpt fstype rest; do
+ if test $mtpt = "/" ; then
+ case $fstype in
+ nfs | nfs4)
+ nfsroot=1
+ nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'`
+ break
+ ;;
+ *)
+ ;;
+ esac
+ fi
+done
+exec 0<&9 9<&-
+
+if [ $nfsroot -eq 0 ]; then
+ interfaces="$INTERFACES"
+else
+ if [ -x /bin/ip -o -x /sbin/ip ] ; then
+ nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'`
+ fi
+ for i in $INTERFACES; do
+ if test "x$i" = "x$nfs_iface"; then
+ echo "dhclient skipping nfsroot interface $i"
+ else
+ interfaces="$interfaces $i"
+ fi
+ done
+fi
+
+if test "x$interfaces" != "x"; then
+ /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf /var/lib/dhcp/dhclient.leases $interfaces
+fi
diff --git a/meta/recipes-connectivity/dhcp/files/dhclient.service b/meta/recipes-connectivity/dhcp/files/dhclient.service
new file mode 100644
index 0000000..9ddb4d1
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/files/dhclient.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Dynamic Host Configuration Protocol (DHCP)
+Wants=network.target
+Before=network.target
+After=systemd-udevd.service
+
+[Service]
+EnvironmentFile=- at SYSCONFDIR@/default/dhcp-client
+ExecStart=@BASE_SBINDIR@/dhclient-systemd-wrapper
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list