summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/systemd-networkd-ext/hooks/configure-dhcp-for-newroot.sh
blob: a0e876a4a1bf35f82be5477a3db3d498e423f935 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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