From 709741a504a15ff8e02e4250d6b731925fdf0ce7 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 11 Jul 2024 21:03:46 +0800 Subject: [PATCH] =?UTF-8?q?debian:=20=E4=BF=AE=E5=A4=8D=20dmit=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=90=8E=E6=B2=A1=E6=9C=89=E7=BD=91=E7=BB=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因是普通内核和云内核网卡名不一致 关联 #77 --- trans.sh | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/trans.sh b/trans.sh index 67dc024..f2901c6 100644 --- a/trans.sh +++ b/trans.sh @@ -684,12 +684,16 @@ get_eths() { ) } +is_distro_like_debian() { + [ "$distro" = debian ] || [ "$distro" = kali ] +} + create_ifupdown_config() { conf_file=$1 rm -f $conf_file - if [ "$distro" = debian ] || [ "$distro" = kali ]; then + if is_distro_like_debian; then cat <>$conf_file source /etc/network/interfaces.d/* @@ -704,15 +708,32 @@ EOF # ethx for ethx in $(get_eths); do - if [ -f /etc/network/devhotplug ] && grep -wo "$ethx" /etc/network/devhotplug; then - mode=allow-hotplug - else - mode=auto - fi - cat <>$conf_file + mode=auto + enpx= + if is_distro_like_debian; then + if [ -f /etc/network/devhotplug ] && grep -wo "$ethx" /etc/network/devhotplug; then + mode=allow-hotplug + fi -$mode $ethx -EOF + if is_have_cmd udevadm; then + enpx=$(udevadm test-builtin net_id /sys/class/net/$ethx 2>&1 | grep ID_NET_NAME_PATH= | cut -d= -f2) + fi + fi + + # dmit debian 普通内核和云内核网卡名不一致,因此需要 rename + # 安装系统时 ens18 + # 普通内核 ens18 + # 云内核 enp6s18 + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=928923 + + # 头部 + { + echo + if [ -n "$enpx" ] && [ "$enpx" != "$ethx" ]; then + echo rename $enpx=$ethx >>$conf_file + fi + echo $mode $ethx + } >>$conf_file # ipv4 if is_dhcpv4; then