blob: 1b3003604615993a3f9388e054784551b615d315 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/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.
. "/run/openslx/pxe-network.conf"
NETWORKD_DIR="/etc/systemd/network"
mkdir -p "${NEWROOT}/${NETWORKD_DIR}" # dirname a-la bash
# First, copy over every configuration made so far
cp "${NETWORKD_DIR}/${SLX_BRIDGE}"* "${NEWROOT}/${NETWORKD_DIR}"
# Workaround: UseHostname seems broken, so manually set the hostname for now...
[ -n "${SLX_HOSTNAME}" ] && echo "${SLX_HOSTNAME}" > $NEWROOT/etc/hostname
# Now determine which network configuration we are running
# VLANs are already configured to DHCP, so nothing to do
if [ -n "${SLX_STAGE4_DHCP}" -o -z "${SLX_VLAN_ID}" ]; then
# In both bridged and non-bridged mode, we need to adjust
# the configuration to DHCP for stage4
MATCH_LINE=
MAIN_NET_CONF=
if [ -n "${SLX_BRIDGE}" ]; then
MATCH_LINE="Name=${SLX_BRIDGE}"
MAIN_NETIF_CONF="${NETWORKD_DIR}/${SLX_BRIDGE}.network"
elif [ -n "${SLX_PXE_MAC}" ]; then
MATCH_LINE="MACAddress=${SLX_PXE_MAC}"
MAIN_NETIF_CONF="${NETWORKD_DIR}/${SLX_PXE_NETIF}.network"
else
emergency_shell "Could not determine network configuration mode!"
fi
# backup current network config for later reference before overwritting it
if [ -e "${MAIN_NETIF_CONF}" ]; then
mv "${NEWROOT}/${MAIN_NETIF_CONF}" "${NEWROOT}/${MAIN_NETIF_CONF}.stage3"
else
emergency_shell "Failed to find main networkd configuration: ${MAIN_NETIF_CONF}"
fi
# Now generate a DHCP configuration for the main interface
cat <<-EOF > "${NEWROOT}/${MAIN_NETIF_CONF}"
[Match]
${MATCH_LINE}
[Network]
DHCP=ipv4
LinkLocalAddressing=no
IPv6AcceptRA=no
[DHCP]
UseDNS=true
UseDomains=true
UseHostname=true
CriticalConnection=true
EOF
fi
|