This does two things:
First, if inst.dhcpclass= was given on the command line, make sure the
/etc/dhclient.conf file is copied over to the anaconda environment. NM
will read this file and merge its contents with the device-specific ones
before running dhclient. This preserves the command line setting should
we re-run dhclient later (like, on a kickstart install).
Second, if network --dhcpclass= is given in a kickstart file, write out
a device-specific dhclient config blob in /etc/dhcp. This file will
then get copied over to the anaconda environment. NM will merge it,
just like in the first case.
Resolves: rhbz#1293051
---
dracut/Makefile.am | 1 +
dracut/anaconda-copy-dhclient.sh | 4 ++++
dracut/module-setup.sh | 1 +
dracut/parse-kickstart | 10 +++++++++-
4 files changed, 15 insertions(+), 1 deletion(-)
create mode 100755 dracut/anaconda-copy-dhclient.sh
diff --git a/dracut/Makefile.am b/dracut/Makefile.am
index b389a34..04fe8f7 100644
--- a/dracut/Makefile.am
+++ b/dracut/Makefile.am
@@ -33,6 +33,7 @@ dist_dracut_SCRIPTS = module-setup.sh \
anaconda-diskroot \
anaconda-copy-ks.sh \
anaconda-copy-cmdline.sh \
+ anaconda-copy-dhclient.sh \
anaconda-copy-s390ccwconf.sh \
anaconda-ifcfg.sh \
fetch-kickstart-net.sh \
diff --git a/dracut/anaconda-copy-dhclient.sh b/dracut/anaconda-copy-dhclient.sh
new file mode 100755
index 0000000..b38da5b
--- /dev/null
+++ b/dracut/anaconda-copy-dhclient.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Copy over dhclient config files to the anaconda environment
+[ -d /etc/dhcp ] && copytree /etc/dhcp /run/initramfs/state/etc/dhcp/
+[ -f /etc/dhclient.conf ] && cp /etc/dhclient.conf /run/initramfs/state/etc/
diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh
index 5afdfcb..c3b879d 100755
--- a/dracut/module-setup.sh
+++ b/dracut/module-setup.sh
@@ -38,6 +38,7 @@ install() {
inst_hook pre-pivot 50 "$moddir/anaconda-copy-ks.sh"
inst_hook pre-pivot 50 "$moddir/anaconda-copy-cmdline.sh"
inst_hook pre-pivot 50 "$moddir/anaconda-copy-s390ccwconf.sh"
+ inst_hook pre-pivot 90 "$moddir/anaconda-copy-dhclient.sh"
inst_hook pre-pivot 99 "$moddir/save-initramfs.sh"
inst_hook pre-shutdown 50 "$moddir/anaconda-pre-shutdown.sh"
# kickstart parsing, WOOOO
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index bc9cbdd..e26bd92 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -460,7 +460,7 @@ def ksnet_to_ifcfg(net, filename=None):
if net.nodefroute:
ifcfg['DEFROUTE'] = "no"
- # FUTURE: dhcpclass, ethtool, essid/wepkey/wpakay, etc.
+ # FUTURE: ethtool, essid/wepkey/wpakey, etc.
if net.bootProto == 'dhcp':
srcpath = "/tmp/dhclient.%s.lease" % dev
@@ -471,6 +471,14 @@ def ksnet_to_ifcfg(net, filename=None):
os.makedirs(dstdir)
shutil.copyfile(srcpath, dstpath)
+ if net.dhcpclass:
+ dstdir = "/etc/dhcp"
+ if not os.path.isdir(dstdir):
+ os.makedirs(dstdir)
+
+ with open("%s/dhclient-%s.conf" % (dstdir, dev), "w") as f:
+ f.write("send vendor-class-identifier \"%s\";" % net.dhcpclass)
+
if net.bondslaves:
ifcfg.pop('HWADDR', None)
ifcfg['TYPE'] = "Bond"
--
2.4.3