summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortorben2018-09-03 18:51:29 +0200
committertorben2018-09-03 18:51:29 +0200
commit413f260e170af2b2df9a3fbc8a165f1790521095 (patch)
tree7f8284df68b04d4dc5fa3fc8fc732b085ab1bc42
parentRefactoring for proper file names. (diff)
downloadsystemd-init-413f260e170af2b2df9a3fbc8a165f1790521095.tar.gz
systemd-init-413f260e170af2b2df9a3fbc8a165f1790521095.tar.xz
systemd-init-413f260e170af2b2df9a3fbc8a165f1790521095.zip
Allow complete dynamically configured systemd-networkd.
-rw-r--r--modules.d/dnbd-root-filesystem/configuration/dnbd/alt-servers6
-rwxr-xr-xmodules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh77
2 files changed, 44 insertions, 39 deletions
diff --git a/modules.d/dnbd-root-filesystem/configuration/dnbd/alt-servers b/modules.d/dnbd-root-filesystem/configuration/dnbd/alt-servers
index 345f1040..fbf3ce6a 100644
--- a/modules.d/dnbd-root-filesystem/configuration/dnbd/alt-servers
+++ b/modules.d/dnbd-root-filesystem/configuration/dnbd/alt-servers
@@ -1,11 +1,9 @@
; Enforce client to use this proxy only by avoiding to propagate alt-server
; configuration to client.
-; UNI Lan
--10.8.8.51
+; UNI LAN (external adapter)
+-10.21.9.111
; Home Lan
-192.168.0.113
-; UNI WLan (None persistent!)
--10.126.10.137
; Virtual Machine
-10.0.2.2
; Home WLan
diff --git a/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh b/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
index d4c4c109..62e5608a 100755
--- a/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
+++ b/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
@@ -19,25 +19,29 @@ parse_kernel_command_line() {
## KCL "BOOTIF": MAC address of the interface that DHCP'ed during PXE
declare -g BOOTIF="$(getarg BOOTIF=)"
declare -g WIRELESS_BOOTIF="$(getarg WIRELESS_BOOTIF=)"
- # Remove the hardware type prefix of BOOTIF if it has 20 chars to get
- # the plain MAC address. The hardware type prefix has length 3, e.g. "01-".
- [ -n "${BOOTIF}" ] && [ ${#BOOTIF} -eq 20 ] && BOOTIF="${BOOTIF#???}"
- BOOTIF="$(tr '-' ':' <<< $BOOTIF)"
- readonly BOOTIF
- [ -n "${WIRELESS_BOOTIF}" ] && [ ${#WIRELESS_BOOTIF} -eq 20 ] && WIRELESS_BOOTIF="${WIRELESS_BOOTIF#???}"
- WIRELESS_BOOTIF="$(tr '-' ':' <<< $WIRELESS_BOOTIF)"
- readonly WIRELESS_BOOTIF
-
+ if [[ "$BOOTIF" != '' ]]; then
+ # Remove the hardware type prefix of BOOTIF if it has 20 chars to get
+ # the plain MAC address. The hardware type prefix has length 3, e.g. "01-".
+ (( ${#BOOTIF} == 20 )) && BOOTIF="${BOOTIF#???}"
+ BOOTIF="$(tr '-' ':' <<< $BOOTIF)"
+ readonly BOOTIF
+ fi
+ if [[ "$WIRELESS_BOOTIF" != '' ]]; then
+ (( ${#WIRELESS_BOOTIF} == 20 )) && WIRELESS_BOOTIF="${WIRELESS_BOOTIF#???}"
+ WIRELESS_BOOTIF="$(tr '-' ':' <<< $WIRELESS_BOOTIF)"
+ readonly WIRELESS_BOOTIF
+ fi
## KCL "ip": is expected in following format (syslinux IPAPPEND3):
declare -rg IPCONF="$(getarg ip=)"
- # <CLIENT_IP>:<PXE_SERVER_IP>:<GATEWAY_IP>:<NETMASK>
- declare -g CLIENT_IP=
- declare -g SERVER_IP=
- declare -g GATEWAY_IP=
- declare -g NETMASK=
- read -r CLIENT_IP SERVER_IP GATEWAY_IP NETMASK <<< $( awk -F: '{print $1" "$2" "$3" "$4}' <<< "${IPCONF}" )
- readonly CLIENT_IP SERVER_IP GATEWAY_IP NETMASK
-
+ if [[ "$IPCONF" != '' ]]; then
+ # <CLIENT_IP>:<PXE_SERVER_IP>:<GATEWAY_IP>:<NETMASK>
+ declare -g CLIENT_IP=
+ declare -g SERVER_IP=
+ declare -g GATEWAY_IP=
+ declare -g NETMASK=
+ read -r CLIENT_IP SERVER_IP GATEWAY_IP NETMASK <<< $( awk -F: '{print $1" "$2" "$3" "$4}' <<< "${IPCONF}" )
+ readonly CLIENT_IP SERVER_IP GATEWAY_IP NETMASK
+ fi
# Taken from parse-ip-opts.sh: Convert the netmask to CIDR notation
declare -g CIDR
@@ -111,12 +115,15 @@ print_static_ip_conf() {
generate_networkd_config() {
mkdir --parents /etc/systemd/network
rm --force --recursive /etc/systemd/network/*
- if [[ "$BOOTIF" != '' ]] && [[ "$BOOTIF" != false ]]; then
+ if [[ "$BOOTIF" != false ]]; then
local BOOTIF_NETWORK_CONF="/etc/systemd/network/$BOOTIF_NAME.network"
(
echo [Match]
- echo "MACAddress=${BOOTIF}"
- echo 'Path=pci*'
+ if [[ "$BOOTIF" != '' ]]; then
+ echo "MACAddress=$BOOTIF"
+ fi
+ #echo 'Path=pci*'
+ echo 'Path=enp*'
echo
# Currently the boot interface is configured to either:
# * static ip as given by the initial DHCP during PXE
@@ -137,16 +144,22 @@ generate_networkd_config() {
echo LinkLocalAddressing=no
) > "$BOOTIF_NETWORK_CONF"
# NOTE: Declarative version if boot interface renaming.
- cat << EOF > "/etc/systemd/network/$BOOTIF_NAME.link"
-[Match]
-MACAddress=$BOOTIF
+ (
+ echo [Match]
+ if [[ "$BOOTIF" != '' ]]; then
+ echo "MACAddress=$BOOTIF"
+ else
+ echo 'Path=enp*'
+ fi
+ cat << EOF
[Link]
Description=Critical wired network device.
Name=$BOOTIF_NAME
EOF
+ ) > "/etc/systemd/network/$BOOTIF_NAME.link"
fi
- if [ "$WIRELESS_BOOTIF" = '' ] || [ "$WIRELESS_BOOTIF" = false ]; then
+ if [ "$WIRELESS_BOOTIF" = false ]; then
if \
rm \
--force \
@@ -163,8 +176,10 @@ EOF
local WIRELESS_BOOTIF_NETWORK_CONF="/etc/systemd/network/$WIRELESS_BOOTIF_NAME.network"
(
echo [Match]
- echo "MACAddress=$WIRELESS_BOOTIF"
- echo "Path=pci*"
+ if [[ "$WIRELESS_BOOTIF" != '' ]]; then
+ echo "MACAddress=$WIRELESS_BOOTIF"
+ fi
+ echo 'Path=wlp*'
echo
# Currently the boot interface is configured to either:
# * static ip as given by the initial DHCP during PXE
@@ -173,15 +188,7 @@ EOF
# In particular, configuring both vlan tags and the physical
# interface is not supported (might be needed in some setups)
echo [Network]
- if [[ "$BRIDGED" != '' ]]; then
- echo "Bridge=$BRIDGE_NAME"
- elif [ -n "$CLIENT_IP" -a -n "$GATEWAY_IP" ]; then
- print_static_ip_conf "$CLIENT_IP/${CIDR:-24}" "$GATEWAY_IP"
- elif [[ "$VLAN" != '' ]]; then
- echo "VLAN=$BOOTIF_NAME.$VLAN"
- else
- echo DHCP=ipv4
- fi
+ echo DHCP=ipv4
cat << EOF
LinkLocalAddressing=no
IPv6AcceptRA=no