summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2017-07-20 15:33:58 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-24 09:13:30 +0100
commit695b3fa02ee75db9e56d3ca0d813fc3665b15df0 (patch)
tree306774b52bfd8d5fc32339975780c04869774338 /meta/recipes-connectivity
parent7b078d95fb58b0bbaf0a036933214294b7ca4e68 (diff)
downloadpoky-695b3fa02ee75db9e56d3ca0d813fc3665b15df0.tar.gz
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. (From OE-Core rev: faa8d0f5e8db4a99367d42ba8c8de5b2e339d8d2) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-connectivity')
-rw-r--r--meta/recipes-connectivity/dhcp/dhcp.inc21
-rw-r--r--meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper39
-rw-r--r--meta/recipes-connectivity/dhcp/files/dhclient.service13
3 files changed, 70 insertions, 3 deletions
diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
index 292f192b7c..db4a963321 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 \
17 file://init-relay file://default-relay \ 17 file://init-relay file://default-relay \
18 file://init-server file://default-server \ 18 file://init-server file://default-server \
19 file://dhclient.conf file://dhcpd.conf \ 19 file://dhclient.conf file://dhcpd.conf \
20 file://dhclient-systemd-wrapper \
21 file://dhclient.service \
20 file://dhcpd.service file://dhcrelay.service \ 22 file://dhcpd.service file://dhcrelay.service \
21 file://dhcpd6.service \ 23 file://dhcpd6.service \
22 file://search-for-libxml2.patch " 24 file://search-for-libxml2.patch "
@@ -29,13 +31,16 @@ inherit autotools systemd useradd update-rc.d
29USERADD_PACKAGES = "${PN}-server" 31USERADD_PACKAGES = "${PN}-server"
30USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}" 32USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}"
31 33
32SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay" 34SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client"
33SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service" 35SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service"
34SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" 36SYSTEMD_AUTO_ENABLE_${PN}-server = "disable"
35 37
36SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service" 38SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service"
37SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable" 39SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable"
38 40
41SYSTEMD_SERVICE_${PN}-client = "dhclient.service"
42SYSTEMD_AUTO_ENABLE_${PN}-client = "disable"
43
39INITSCRIPT_PACKAGES = "dhcp-server" 44INITSCRIPT_PACKAGES = "dhcp-server"
40INITSCRIPT_NAME_dhcp-server = "dhcp-server" 45INITSCRIPT_NAME_dhcp-server = "dhcp-server"
41INITSCRIPT_PARAMS_dhcp-server = "defaults" 46INITSCRIPT_PARAMS_dhcp-server = "defaults"
@@ -79,7 +84,13 @@ do_install_append () {
79 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service 84 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
80 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service 85 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
81 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service 86 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
82 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service 87 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
88
89 install -d ${D}${base_sbindir}
90 install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper
91 install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system
92 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service
93 sed -i -e 's,@BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service
83} 94}
84 95
85PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell" 96PACKAGES += "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
97 108
98FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay" 109FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
99 110
100FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf" 111FILES_${PN}-client = "${base_sbindir}/dhclient \
112 ${base_sbindir}/dhclient-script \
113 ${sysconfdir}/dhcp/dhclient.conf \
114 ${base_sbindir}/dhclient-systemd-wrapper \
115 "
101 116
102FILES_${PN}-omshell = "${bindir}/omshell" 117FILES_${PN}-omshell = "${bindir}/omshell"
103 118
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 0000000000..7d0e224a1d
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper
@@ -0,0 +1,39 @@
1#!/bin/sh
2
3# In case the interface is used for nfs, skip it.
4nfsroot=0
5interfaces=""
6exec 9<&0 < /proc/mounts
7while read dev mtpt fstype rest; do
8 if test $mtpt = "/" ; then
9 case $fstype in
10 nfs | nfs4)
11 nfsroot=1
12 nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'`
13 break
14 ;;
15 *)
16 ;;
17 esac
18 fi
19done
20exec 0<&9 9<&-
21
22if [ $nfsroot -eq 0 ]; then
23 interfaces="$INTERFACES"
24else
25 if [ -x /bin/ip -o -x /sbin/ip ] ; then
26 nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'`
27 fi
28 for i in $INTERFACES; do
29 if test "x$i" = "x$nfs_iface"; then
30 echo "dhclient skipping nfsroot interface $i"
31 else
32 interfaces="$interfaces $i"
33 fi
34 done
35fi
36
37if test "x$interfaces" != "x"; then
38 /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf /var/lib/dhcp/dhclient.leases $interfaces
39fi
diff --git a/meta/recipes-connectivity/dhcp/files/dhclient.service b/meta/recipes-connectivity/dhcp/files/dhclient.service
new file mode 100644
index 0000000000..9ddb4d1dfe
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/files/dhclient.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=Dynamic Host Configuration Protocol (DHCP)
3Wants=network.target
4Before=network.target
5After=systemd-udevd.service
6
7[Service]
8EnvironmentFile=-@SYSCONFDIR@/default/dhcp-client
9ExecStart=@BASE_SBINDIR@/dhclient-systemd-wrapper
10RemainAfterExit=yes
11
12[Install]
13WantedBy=multi-user.target