diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh index ae2bc74..21a528e 100755 --- a/templates/scripts/includes/deployment.sh +++ b/templates/scripts/includes/deployment.sh @@ -1304,6 +1304,53 @@ puppet_install_from_puppet() { return 0 } +set_custom_grub_boot_options() { + echo "Adjusting default GRUB boot options (enabling net.ifnames=0)" + sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/GRUB_CMDLINE_LINUX_DEFAULT="\1 net.ifnames=0"/' "${TARGET}/etc/default/grub" + + echo "Invoking update-grub" + grml-chroot "${TARGET}" update-grub + + if [ -d "${TARGET}/etc/.git" ]; then + echo "Commit /etc/default/grub changes using etckeeper" + grml-chroot "${TARGET}" etckeeper commit "/etc/default/grub changes" + fi +} + + +generate_udev_network_rules() { + # get list of available network devices + # (excl. some known-to-be-irrelevant ones, also see MT#8297) + NETWORK_DEVICES="$(tail -n +3 /proc/net/dev | sed -r 's/^ *([0-9a-zA-Z]+):.*$/\1/g' | \ + grep -ve '^vmnet' -ve '^vboxnet' -ve '^docker' -ve '^usb' -ve '^vlan' -ve '^bond' | sort -u)" + + echo "Generating udev persistent net rules." + TARGET_UDEV_PERSISTENT_NET_RULES="${TARGET}/etc/udev/rules.d/70-persistent-net.rules" + echo "## Generated by Sipwise deployment script" > "${TARGET_UDEV_PERSISTENT_NET_RULES}" + for dev in ${NETWORK_DEVICES}; do + [[ "${dev}" =~ ^lo ]] && continue + + pciid=$(ethtool -i "${dev}" | awk '/^bus-info: / {print $2}') + if [[ "${pciid}" =~ ^([0-9a-fA-F:.-])+$ ]]; then + dev_name_new="n${dev}" + echo "Adding device '${dev}' with PCIID '${pciid}', dev_name_new=${dev_name_new}" + cat >> "${TARGET_UDEV_PERSISTENT_NET_RULES}" <<EOL +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="${pciid}", NAME="${dev_name_new}" +EOL + else + echo "WARNING: could not find valid PCIID '${pciid}' for device '${dev}'" + fi + unset pciid + done + + echo "Content of resulting /etc/udev/rules.d/70-persistent-net.rules:" + cat "${TARGET_UDEV_PERSISTENT_NET_RULES}" + + # Rename existing network devices at this time, to use the new names "neth*" + # when creating config_deploy.inc later + NETWORK_DEVICES="${NETWORK_DEVICES//eth/neth}" +} + # Main script INSTALL_LOG='/tmp/deployment-installer-debug.log' @@ -2169,37 +2216,15 @@ ff02::1 ip6-allnodes ff02::2 ip6-allrouters EOF -# get list of available network devices -# (excl. some known-to-be-irrelevant ones, also see MT#8297) -NETWORK_DEVICES="$(tail -n +3 /proc/net/dev | sed -r 's/^ *([0-9a-zA-Z]+):.*$/\1/g' | \ - grep -ve '^vmnet' -ve '^vboxnet' -ve '^docker' -ve '^usb' -ve '^vlan' -ve '^bond' | sort -u)" - -echo "Generating udev persistent net rules." -TARGET_UDEV_PERSISTENT_NET_RULES="${TARGET}/etc/udev/rules.d/70-persistent-net.rules" -echo "## Generated by Sipwise deployment script" > "${TARGET_UDEV_PERSISTENT_NET_RULES}" -for dev in ${NETWORK_DEVICES}; do - [[ "${dev}" =~ ^lo ]] && continue - - pciid=$(ethtool -i "${dev}" | awk '/^bus-info: / {print $2}') - if [[ "${pciid}" =~ ^([0-9a-fA-F:.-])+$ ]]; then - dev_name_new="n${dev}" - echo "Adding device '${dev}' with PCIID '${pciid}', dev_name_new=${dev_name_new}" - cat >> "${TARGET_UDEV_PERSISTENT_NET_RULES}" <<EOL -SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="${pciid}", NAME="${dev_name_new}" -EOL - else - echo "WARNING: could not find valid PCIID '${pciid}' for device '${dev}'" - fi - unset pciid -done - -# Rename existing network devices at this time, to use the new names "neth*" -# when creating config_deploy.inc later -NETWORK_DEVICES="${NETWORK_DEVICES//eth/neth}" +if ! "$NGCP_INSTALLER" ; then + set_custom_grub_boot_options +fi if "$NGCP_INSTALLER" ; then set_deploy_status "ngcp-installer" + generate_udev_network_rules + echo "Searching for proper ngcp-installer package ..." get_installer_path @@ -2285,15 +2310,15 @@ EOT if [ -r /tmp/grml-debootstrap.log ] ; then cp /tmp/grml-debootstrap.log "${TARGET}"/var/log/ fi -fi -# network interfaces need to be renamed eth*->neth* with mr9.5 / Debian -# bullseye, and not left with grml-bootstrap defaults -echo "Renaming eth*->neth* in /etc/network/interfaces ..." -sed -i '/eth[0-9]/ s|eth|neth|g' "${TARGET}/etc/network/interfaces" -echo "Content of resulting /etc/network/interfaces:" -tail -v -n +0 "${TARGET}/etc/network/interfaces" -echo "========" + # network interfaces need to be renamed eth*->neth* with mr9.5 / Debian + # bullseye, and not left with grml-bootstrap defaults + echo "Renaming eth*->neth* in /etc/network/interfaces ..." + sed -i '/eth[0-9]/ s|eth|neth|g' "${TARGET}/etc/network/interfaces" + echo "Content of resulting /etc/network/interfaces:" + tail -v -n +0 "${TARGET}/etc/network/interfaces" + echo "========" +fi if [[ -n "${MANAGEMENT_IP}" ]] && "${RETRIEVE_MGMT_CONFIG}" ; then echo "Retrieving public key from management node"