summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh')
-rw-r--r--builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh b/builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh
new file mode 100644
index 00000000..a0e876a4
--- /dev/null
+++ b/builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# This hook creates a networkd configuration for the NEWROOT
+# * DHCP configuration for the boot interface
+# * Set static hostname via /etc/hostname
+
+# This uses the configuration file generated by the parse-kcl-for-networkd.sh hook
+# Note: on systemd v219, UseDomains is bugged and does not seem to do anything
+# thus that option is complemented with the KCL's domain
+# to hopefully garantee one of these will take effect.
+mkdir -p "$NEWROOT/etc/systemd/network/"
+new_network_conf="$NEWROOT/etc/systemd/network/10-pxe-interface.network"
+echo '[Match]' > $new_network_conf
+grep "MACAddress=" /etc/systemd/network/*boot*.network >> $new_network_conf
+echo '' >> $new_network_conf
+echo '[Network]' >> $new_network_conf
+echo 'DHCP=ipv4' >> $new_network_conf
+grep "Domains=" /etc/systemd/network/*boot*.network >> $new_network_conf
+echo '' >> $new_network_conf
+echo '[DHCP]' >> $new_network_conf
+echo 'UseDNS=true' >> $new_network_conf
+echo 'UseDomains=true' >> $new_network_conf
+echo 'UseHostname=true' >> $new_network_conf
+echo 'CriticalConnection=true' >> $new_network_conf
+
+# Similarly, UseHostname seems to have no effect, so work around for now...
+cat /proc/sys/kernel/hostname > $NEWROOT/etc/hostname