From ea4af1f18d1502a0a35242f5bc962667ce3ad65a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 1 Jan 2025 17:38:29 +0800 Subject: [PATCH] =?UTF-8?q?opensuse:=20=E4=BF=AE=E5=A4=8D=E9=9D=99?= =?UTF-8?q?=E6=80=81+=E5=8A=A8=E6=80=81=E5=8F=8C=E7=BD=91=E5=8D=A1?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E8=AE=BE=E7=BD=AE=20onlink=20?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloud-init-fix-onlink.sh | 22 +++++++++++++++++----- trans.sh | 24 +++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cloud-init-fix-onlink.sh b/cloud-init-fix-onlink.sh index 0d6a5c8..55ea03f 100644 --- a/cloud-init-fix-onlink.sh +++ b/cloud-init-fix-onlink.sh @@ -88,8 +88,11 @@ EOF sed -i '/gateway[4|6]:/d' $conf # 重新应用配置 - netplan apply - systemctl restart systemd-networkd + if command -v netplan && { + systemctl is-enabled systemd-networkd || systemctl is-enabled NetworkManager + }; then + netplan apply + fi } fix_networkd_conf() { @@ -145,7 +148,9 @@ GatewayOnLink=yes # 重新应用配置 # networkctl reload 不起作用 - systemctl restart systemd-networkd + if systemctl is-enabled systemd-networkd; then + systemctl restart systemd-networkd + fi } fix_wicked_conf() { @@ -184,16 +189,23 @@ fix_wicked_conf() { done # 重新应用配置 - systemctl restart wicked + if systemctl is-enabled wicked; then + systemctl restart wicked + fi } -# debian 11/12: netplan + networkd/resolved +# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 + +# debian 10/11 云镜像原本用 ifupdown + resolvconf,脚本改成用 netplan + networkd/resolved +# debian 12 云镜像: netplan + networkd/resolved # 23.1.1 修复 fix_netplan_conf # arch: networkd/resolved # gentoo: networkd/resolved # 24.2 修复 +# 只需对云镜像处理 +# 因为普通安装用的是 alpine 的 cloud-init,版本够新,不用处理 fix_networkd_conf # opensuse 15.5: ifcfg + netconfig (dns) + wicked diff --git a/trans.sh b/trans.sh index 0952b24..329137e 100644 --- a/trans.sh +++ b/trans.sh @@ -1787,13 +1787,8 @@ EOF rm -rf net.cfg apk del cloud-init - # 修复 onlink 网关 - if is_staticv4 || is_staticv6; then - fix_sh=cloud-init-fix-onlink.sh - download $confhome/$fix_sh $os_dir/$fix_sh - chroot $os_dir bash /$fix_sh - rm -f $os_dir/$fix_sh - fi + # arch gentoo 网络配置是用 alpine cloud-init 生成的 + # cloud-init 版本够新,因此无需修复 onlink 网关 # ntp 用 systemd 自带的 # TODO: vm agent + 随机数生成器 @@ -2566,13 +2561,16 @@ modify_linux() { # 修复 onlink 网关 add_onlink_script_if_need() { - if is_staticv4 || is_staticv6; then - fix_sh=cloud-init-fix-onlink.sh - download $confhome/$fix_sh $os_dir/$fix_sh - insert_into_file $ci_file after '^runcmd:' <