diff --git a/deployment.sh b/deployment.sh index bb9df98..88fb590 100755 --- a/deployment.sh +++ b/deployment.sh @@ -839,6 +839,20 @@ if "$PRO_EDITION" ; then fi fi +if "$PRO_EDITION" && [[ $(imvirt) != "Physical" ]] ; then + echo "Generating udev persistent net rules." + INT_MAC=$(udevadm info -a -p /sys/class/net/${INTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') + EXT_MAC=$(udevadm info -a -p /sys/class/net/${EXTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') + + cat > $TARGET/etc/udev/rules.d/70-persistent-net.rules << EOF +## Generated by Sipwise deployment script +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$INT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$INTERNAL_DEV" +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$EXT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$EXTERNAL_DEV" +EOF +fi + +# needs to be executed *after* udev rules have been set up, +# otherwise we get duplicated MAC address<->device name mappings if "$RETRIEVE_NETWORK_CONFIG" ; then echo "Retrieving network configuration from management server" wget --timeout=30 -O /etc/network/interfaces "${MANAGEMENT_IP}:3000/nwconfig/$(cat ${TARGET}/etc/hostname)" @@ -854,17 +868,6 @@ if "$RETRIEVE_NETWORK_CONFIG" ; then done fi -if "$PRO_EDITION" && [[ $(imvirt) != "Physical" ]] ; then - echo "Generating udev persistent net rules." - INT_MAC=$(udevadm info -a -p /sys/class/net/${INTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') - EXT_MAC=$(udevadm info -a -p /sys/class/net/${EXTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') - - cat > $TARGET/etc/udev/rules.d/70-persistent-net.rules << EOF -## Generated by Sipwise deployment script -SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$INT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$INTERNAL_DEV" -SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$EXT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$EXTERNAL_DEV" -EOF -fi if "$NGCP_INSTALLER" ; then