mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
core: 修复安装 centos 云镜像时,找不到系统分区放置 ci 配置文件
This commit is contained in:
parent
0468b45cc9
commit
80e643ae8d
11
trans.sh
11
trans.sh
@ -420,6 +420,8 @@ mount_pseudo_fs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
download_cloud_init_config() {
|
download_cloud_init_config() {
|
||||||
|
os_dir=$1
|
||||||
|
|
||||||
if ! mount | grep -w 'on /os type'; then
|
if ! mount | grep -w 'on /os type'; then
|
||||||
apk add lsblk
|
apk add lsblk
|
||||||
mkdir -p /os
|
mkdir -p /os
|
||||||
@ -429,6 +431,7 @@ download_cloud_init_config() {
|
|||||||
# fedora 云镜像没有默认子卷,且系统在root子卷中
|
# fedora 云镜像没有默认子卷,且系统在root子卷中
|
||||||
if mount /dev/$part /os; then
|
if mount /dev/$part /os; then
|
||||||
if etc_dir=$({ ls -d /os/etc || ls -d /os/*/etc; } 2>/dev/null); then
|
if etc_dir=$({ ls -d /os/etc || ls -d /os/*/etc; } 2>/dev/null); then
|
||||||
|
os_dir=$(dirname $etc_dir)
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
umount /os
|
umount /os
|
||||||
@ -436,18 +439,18 @@ download_cloud_init_config() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$etc_dir" ]; then
|
if [ -z "$os_dir" ]; then
|
||||||
error_and_exit "can't find os partition"
|
error_and_exit "can't find os partition"
|
||||||
fi
|
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
|
# shellcheck disable=SC2154
|
||||||
download $confhome/nocloud.yaml $ci_file
|
download $confhome/nocloud.yaml $ci_file
|
||||||
|
|
||||||
# swapfile
|
# swapfile
|
||||||
# arch自带swap,过滤掉
|
# arch自带swap,过滤掉
|
||||||
if ! grep -w swap $etc_dir/fstab; then
|
if ! grep -w swap $os_dir/etc/fstab; then
|
||||||
# btrfs
|
# btrfs
|
||||||
if mount | grep 'on /os type btrfs'; then
|
if mount | grep 'on /os type btrfs'; then
|
||||||
line_num=$(grep -E -n '^runcmd:' $ci_file | cut -d: -f1)
|
line_num=$(grep -E -n '^runcmd:' $ci_file | cut -d: -f1)
|
||||||
@ -657,7 +660,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# cloud-init
|
# cloud-init
|
||||||
download_cloud_init_config
|
download_cloud_init_config /os
|
||||||
|
|
||||||
# 还原 resolv.conf
|
# 还原 resolv.conf
|
||||||
mv /os/etc/resolv.conf.orig /os/etc/resolv.conf
|
mv /os/etc/resolv.conf.orig /os/etc/resolv.conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user