From 80e643ae8d519dda5ee571da5adadb18e05bb6db Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 2 Aug 2023 00:02:00 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E5=AE=89=E8=A3=85=20?= =?UTF-8?q?centos=20=E4=BA=91=E9=95=9C=E5=83=8F=E6=97=B6=EF=BC=8C=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E7=B3=BB=E7=BB=9F=E5=88=86=E5=8C=BA=E6=94=BE?= =?UTF-8?q?=E7=BD=AE=20ci=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/trans.sh b/trans.sh index a9994df..644304d 100644 --- a/trans.sh +++ b/trans.sh @@ -420,6 +420,8 @@ mount_pseudo_fs() { } download_cloud_init_config() { + os_dir=$1 + if ! mount | grep -w 'on /os type'; then apk add lsblk mkdir -p /os @@ -429,6 +431,7 @@ download_cloud_init_config() { # fedora 云镜像没有默认子卷,且系统在root子卷中 if mount /dev/$part /os; then if etc_dir=$({ ls -d /os/etc || ls -d /os/*/etc; } 2>/dev/null); then + os_dir=$(dirname $etc_dir) break fi umount /os @@ -436,18 +439,18 @@ download_cloud_init_config() { done fi - if [ -z "$etc_dir" ]; then + if [ -z "$os_dir" ]; then error_and_exit "can't find os partition" fi - ci_file=$etc_dir/cloud/cloud.cfg.d/99_nocloud.cfg + ci_file=$os_dir/etc/cloud/cloud.cfg.d/99_nocloud.cfg # shellcheck disable=SC2154 download $confhome/nocloud.yaml $ci_file # swapfile # arch自带swap,过滤掉 - if ! grep -w swap $etc_dir/fstab; then + if ! grep -w swap $os_dir/etc/fstab; then # btrfs if mount | grep 'on /os type btrfs'; then line_num=$(grep -E -n '^runcmd:' $ci_file | cut -d: -f1) @@ -657,7 +660,7 @@ EOF fi # cloud-init - download_cloud_init_config + download_cloud_init_config /os # 还原 resolv.conf mv /os/etc/resolv.conf.orig /os/etc/resolv.conf