diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2017-07-20 15:33:58 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-24 09:13:30 +0100 |
commit | 695b3fa02ee75db9e56d3ca0d813fc3665b15df0 (patch) | |
tree | 306774b52bfd8d5fc32339975780c04869774338 /meta/recipes-connectivity/dhcp | |
parent | 7b078d95fb58b0bbaf0a036933214294b7ca4e68 (diff) | |
download | poky-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/dhcp')
-rw-r--r-- | meta/recipes-connectivity/dhcp/dhcp.inc | 21 | ||||
-rw-r--r-- | meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper | 39 | ||||
-rw-r--r-- | meta/recipes-connectivity/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 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 | |||
29 | USERADD_PACKAGES = "${PN}-server" | 31 | USERADD_PACKAGES = "${PN}-server" |
30 | USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}" | 32 | USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}" |
31 | 33 | ||
32 | SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay" | 34 | SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client" |
33 | SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service" | 35 | SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service" |
34 | SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" | 36 | SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" |
35 | 37 | ||
36 | SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service" | 38 | SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service" |
37 | SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable" | 39 | SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable" |
38 | 40 | ||
41 | SYSTEMD_SERVICE_${PN}-client = "dhclient.service" | ||
42 | SYSTEMD_AUTO_ENABLE_${PN}-client = "disable" | ||
43 | |||
39 | INITSCRIPT_PACKAGES = "dhcp-server" | 44 | INITSCRIPT_PACKAGES = "dhcp-server" |
40 | INITSCRIPT_NAME_dhcp-server = "dhcp-server" | 45 | INITSCRIPT_NAME_dhcp-server = "dhcp-server" |
41 | INITSCRIPT_PARAMS_dhcp-server = "defaults" | 46 | INITSCRIPT_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 | ||
85 | PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell" | 96 | 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 | |||
97 | 108 | ||
98 | FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay" | 109 | FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay" |
99 | 110 | ||
100 | FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf" | 111 | FILES_${PN}-client = "${base_sbindir}/dhclient \ |
112 | ${base_sbindir}/dhclient-script \ | ||
113 | ${sysconfdir}/dhcp/dhclient.conf \ | ||
114 | ${base_sbindir}/dhclient-systemd-wrapper \ | ||
115 | " | ||
101 | 116 | ||
102 | FILES_${PN}-omshell = "${bindir}/omshell" | 117 | FILES_${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. | ||
4 | nfsroot=0 | ||
5 | interfaces="" | ||
6 | exec 9<&0 < /proc/mounts | ||
7 | while 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 | ||
19 | done | ||
20 | exec 0<&9 9<&- | ||
21 | |||
22 | if [ $nfsroot -eq 0 ]; then | ||
23 | interfaces="$INTERFACES" | ||
24 | else | ||
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 | ||
35 | fi | ||
36 | |||
37 | if test "x$interfaces" != "x"; then | ||
38 | /sbin/dhclient -d -cf /etc/dhcp/dhclient.conf -q -lf /var/lib/dhcp/dhclient.leases $interfaces | ||
39 | fi | ||
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] | ||
2 | Description=Dynamic Host Configuration Protocol (DHCP) | ||
3 | Wants=network.target | ||
4 | Before=network.target | ||
5 | After=systemd-udevd.service | ||
6 | |||
7 | [Service] | ||
8 | EnvironmentFile=-@SYSCONFDIR@/default/dhcp-client | ||
9 | ExecStart=@BASE_SBINDIR@/dhclient-systemd-wrapper | ||
10 | RemainAfterExit=yes | ||
11 | |||
12 | [Install] | ||
13 | WantedBy=multi-user.target | ||