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/files | |
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/files')
-rw-r--r-- | meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper | 39 | ||||
-rw-r--r-- | meta/recipes-connectivity/dhcp/files/dhclient.service | 13 |
2 files changed, 52 insertions, 0 deletions
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 | ||