From 7c96c4682fae33e9ddf015df5513984a9422bddc Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 22 May 2024 21:53:32 +0800 Subject: [PATCH] =?UTF-8?q?alpine:=20=E9=80=82=E9=85=8D=203.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 10 +++++----- trans.sh | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 1e1f1a0..588a184 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2316,10 +2316,10 @@ EOF } mod_initrd_alpine() { - # hack 1 virt 内核添加 ipv6 模块 + # hack 1 v3.19 和之前的 virt 内核需添加 ipv6 模块 if virt_dir=$(ls -d $tmp_dir/lib/modules/*-virt 2>/dev/null); then ipv6_dir=$virt_dir/kernel/net/ipv6 - if ! [ -f $ipv6_dir/ipv6.ko ]; then + if ! [ -f $ipv6_dir/ipv6.ko ] || ! grep -q ipv6 $tmp_dir/lib/modules/*/modules.builtin; then mkdir -p $ipv6_dir modloop_file=$tmp/modloop_file modloop_dir=$tmp/modloop_dir @@ -2337,7 +2337,7 @@ mod_initrd_alpine() { fi insert_into_file init after 'configure_ip\(\)' </dev/null + # -f 好像没用 + mdev -sf 2>/dev/null fi done } @@ -1467,12 +1467,20 @@ mount_pseudo_fs() { fi } +get_yq_name() { + if grep -q '3\.1[6789]' /etc/alpine-release; then + echo yq + else + echo yq-go + fi +} + create_cloud_init_network_config() { ci_file=$1 get_netconf_to ethx get_netconf_to mac_addr - apk add yq + apk add "$(get_yq_name)" # shellcheck disable=SC2154 yq -i ".network.version=1 | @@ -1550,7 +1558,7 @@ create_cloud_init_network_config() { # 如果 network.config[1] 没有 address,则删除,避免低版本 cloud-init 报错 yq -i 'del(.network.config[1] | select(has("address") | not))' $ci_file - apk del yq + apk del "$(get_yq_name)" } truncate_machine_id() {