nix-community / nixos-install-scripts

collection of one-shot scripts to install NixOS on various server hosters and other hardware. [maintainer=@happysalada]
123 stars 68 forks source link

hetzner: Tighter regex match for INTERFACE_DEVICE_PATH #18

Open nh2 opened 1 year ago

nh2 commented 1 year ago

I found a case on a Hetzner SX134 server with an addiitonal 10 G network interface that in

https://github.com/nix-community/nixos-install-scripts/blob/552eb22477c84db9e17314e898050cd18981e1bd/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh#L184

we need

-INTERFACE_DEVICE_PATH=$(udevadm info -e | grep -Po "(?<=^P: )(.*${RESCUE_INTERFACE})")
+INTERFACE_DEVICE_PATH=$(udevadm info -e | grep -Po "(?<=^P: )(.*${RESCUE_INTERFACE})$")

Otherwise we can get two maches:

# udevadm info -e | grep -P "(?<=^P: )(.*eth1)"
P: /devices/pci0000:00/0000:00:01.1/0000:01:00.0/net/eth1
P: /devices/pci0000:00/0000:00:01.1/0000:01:00.0/net/eth1/ixgbe-mdio-0000:01:00.0

when in fact we want to match only the first line.