From 48427149f274eed97a60b5180da81a3e27048257 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 3 Sep 2018 19:18:53 +0200 Subject: Improve network device recognation. --- ...twork-configuration-to-systemd-service-files.sh | 68 +++++++++++++--------- modules.d/systemd-networkd-ext/module-setup.sh | 2 +- 2 files changed, 40 insertions(+), 30 deletions(-) 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 62e5608a..410a890e 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 @@ -118,20 +118,18 @@ generate_networkd_config() { if [[ "$BOOTIF" != false ]]; then local BOOTIF_NETWORK_CONF="/etc/systemd/network/$BOOTIF_NAME.network" ( - echo [Match] - 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 # * bridged # * vlan-tagged (ethernet interface not configured) # In particular, configuring both vlan tags and the physical # interface is not supported (might be needed in some setups) - echo [Network] + cat << EOF +[Match] +Name=$BOOTIF_NAME + +[Network] +EOF if [[ "$BRIDGED" != '' ]]; then echo "Bridge=${BRIDGE_NAME}" elif [ -n "$CLIENT_IP" -a -n "$GATEWAY_IP" ]; then @@ -175,21 +173,18 @@ EOF else local WIRELESS_BOOTIF_NETWORK_CONF="/etc/systemd/network/$WIRELESS_BOOTIF_NAME.network" ( - echo [Match] - 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 # * bridged # * vlan-tagged (ethernet interface not configured) # In particular, configuring both vlan tags and the physical # interface is not supported (might be needed in some setups) - echo [Network] - echo DHCP=ipv4 cat << EOF +[Match] +Name=$WIRELESS_BOOTIF_NAME + +[Network] +DHCP=ipv4 LinkLocalAddressing=no IPv6AcceptRA=no @@ -200,14 +195,20 @@ UseHostname=true CriticalConnection=true EOF ) > "$WIRELESS_BOOTIF_NETWORK_CONF" - cat << EOF > "/etc/systemd/network/$WIRELESS_BOOTIF_NAME.link" -[Match] -MACAddress=$WIRELESS_BOOTIF + ( + echo [Match] + if [[ "$WIRELESS_BOOTIF" != '' ]]; then + echo "MACAddress=$WIRELESS_BOOTIF" + else + echo 'Path=wlp*' + fi + cat << EOF [Link] Description=Critical wireless network device. Name=$WIRELESS_BOOTIF_NAME EOF + ) > "/etc/systemd/network/$WIRELESS_BOOTIF_NAME.link" fi if [[ "$VLAN" != '' ]]; then local VLAN_DEV_CONF="/etc/systemd/network/$BOOTIF_NAME.$VLAN.netdev" @@ -302,17 +303,26 @@ parse_kernel_command_line # Save IP config for later use save_ip_config -# Create the udev rule to rename the boot interface to the declared BOOTIF_NAME -# Create udev rule to rename the PXE boot interface to BOOTIF_NAME -if [[ "$BOOTIF" != '' ]] && [[ "$BOOTIF" != false ]]; then - # priority 70 < 80-net-name-slot.rules. - echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$BOOTIF'", NAME="'$BOOTIF_NAME'"' \ - > /etc/udev/rules.d/70-pxe-boot-interface.rules +# NOTE: priority 70 < 80-net-name-slot.rules. +if [[ "$BOOTIF" != false ]]; then + # Create the udev rule to rename the boot interface to the declared BOOTIF_NAME + if [ "$BOOTIF" = '' ]; then + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", NAME=="enp*", NAME="'$BOOTIF_NAME'"' \ + > /etc/udev/rules.d/70-pxe-boot-interface.rules + else + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$BOOTIF'", NAME="'$BOOTIF_NAME'"' \ + > /etc/udev/rules.d/70-pxe-boot-interface.rules + fi fi -if [[ "$WIRELESS_BOOTIF" != '' ]] && [[ "$WIRELESS_BOOTIF" != false ]]; then - # priority 70 < 80-net-name-slot.rules. - echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$WIRELESS_BOOTIF'", NAME="'$WIRELESS_BOOTIF_NAME'"' \ - > /etc/udev/rules.d/70-pxe-wireless-boot-interface.rules +if [[ "$WIRELESS_BOOTIF" != false ]]; then + # Create udev rule to rename the specifief wireless boot interface to WIRELESS_BOOTIF_NAME + if [ "$WIRELESS_BOOTIF" = '' ]; then + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", NAME=="wlp*", NAME="'$WIRELESS_BOOTIF_NAME'"' \ + > /etc/udev/rules.d/70-pxe-wireless-boot-interface.rules + else + echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$WIRELESS_BOOTIF'", NAME="'$WIRELESS_BOOTIF_NAME'"' \ + > /etc/udev/rules.d/70-pxe-wireless-boot-interface.rules + fi fi # Generate config files for networkd diff --git a/modules.d/systemd-networkd-ext/module-setup.sh b/modules.d/systemd-networkd-ext/module-setup.sh index 38bb2014..0f982924 100755 --- a/modules.d/systemd-networkd-ext/module-setup.sh +++ b/modules.d/systemd-networkd-ext/module-setup.sh @@ -26,10 +26,10 @@ check() { # called by dracut depends() { + # TODO not needed for tests: dialog \ echo \ bashlink \ custom-logging \ - dialog \ kernel-network-modules \ systemd } -- cgit v1.2.3-55-g7522