mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 使用 extra_xxx=yyy 而不是 extra.xxx=yyy
This commit is contained in:
parent
fe660063ce
commit
3b679732c1
@ -123,7 +123,7 @@ d-i preseed/early_command string true; \
|
||||
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
|
||||
# os-prober 卡太久,因此跳过
|
||||
d-i partman/early_command string true; \
|
||||
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||
confhome="$(grep -o 'extra_confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||
|
||||
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
|
||||
cp $postinst $postinst.orig; \
|
||||
@ -161,7 +161,7 @@ d-i partman/early_command string true; \
|
||||
# 另一种方法处理 cloudcone
|
||||
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
||||
d-i preseed/late_command string true; \
|
||||
link_grub_dir="$(grep -o 'extra\.link_grub_dir=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||
link_grub_dir="$(grep -o 'extra_link_grub_dir=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||
if [ "$link_grub_dir" = 1 ]; then ln -s grub /target/boot/grub2; fi; \
|
||||
|
||||
in-target systemctl enable ssh; \
|
||||
|
@ -10,7 +10,7 @@ get_all_disks() {
|
||||
get_xda() {
|
||||
# 如果没找到 main_disk 或 xda
|
||||
# 返回假的值,防止意外地格式化全部盘
|
||||
main_disk="$(grep -o 'extra\.main_disk=[^ ]*' /proc/cmdline | cut -d= -f2)"
|
||||
main_disk="$(grep -o 'extra_main_disk=[^ ]*' /proc/cmdline | cut -d= -f2)"
|
||||
|
||||
if [ -z "$main_disk" ]; then
|
||||
echo 'MAIN_DISK_NOT_FOUND'
|
||||
|
12
redhat.cfg
12
redhat.cfg
@ -38,10 +38,10 @@ distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
||||
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
||||
|
||||
# 重新整理 extra,grub把两侧的引号吃掉了,eval出错,要重新添加引号
|
||||
# 提取 extra.confhome extra.mirrorlist extra.main_disk
|
||||
# 提取 extra_confhome extra_mirrorlist extra_main_disk
|
||||
prefix=extra
|
||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo "$var" | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo "$var" | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||
done
|
||||
|
||||
# centos7 证书链未更新,需要 --no-check-certificate
|
||||
@ -151,10 +151,10 @@ fi
|
||||
|
||||
# 分步安装的系统,要将最后一个分区(installer)合并到系统分区
|
||||
if [ -e /dev/disk/by-label/installer ]; then
|
||||
# 提取 extra.localtest extra.confhome extra.mirrorlist
|
||||
# 提取 extra_localtest extra_confhome extra_mirrorlist
|
||||
prefix=extra
|
||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo "$var" | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo "$var" | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||
done
|
||||
|
||||
cd /
|
||||
|
15
reinstall.sh
15
reinstall.sh
@ -2069,30 +2069,35 @@ build_finalos_cmdline() {
|
||||
value=${!key}
|
||||
key=${key#finalos_}
|
||||
if [ -n "$value" ] && [ $key != "mirrorlist" ]; then
|
||||
finalos_cmdline+=" finalos.$key='$value'"
|
||||
finalos_cmdline+=" finalos_$key='$value'"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
build_extra_cmdline() {
|
||||
# 使用 extra_xxx=yyy 而不是 extra.xxx=yyy
|
||||
# 因为 debian installer /lib/debian-installer-startup.d/S02module-params
|
||||
# 会将 extra.xxx=yyy 写入新系统的 /etc/modprobe.d/local.conf
|
||||
# https://answers.launchpad.net/ubuntu/+question/249456
|
||||
# https://salsa.debian.org/installer-team/rootskel/-/blob/master/src/lib/debian-installer-startup.d/S02module-params?ref_type=heads
|
||||
for key in confhome hold force cloud_image main_disk; do
|
||||
value=${!key}
|
||||
if [ -n "$value" ]; then
|
||||
extra_cmdline+=" extra.$key='$value'"
|
||||
extra_cmdline+=" extra_$key='$value'"
|
||||
fi
|
||||
done
|
||||
|
||||
# 指定最终安装系统的 mirrorlist,链接有&,在grub中是特殊字符,所以要加引号
|
||||
if [ -n "$finalos_mirrorlist" ]; then
|
||||
extra_cmdline+=" extra.mirrorlist='$finalos_mirrorlist'"
|
||||
extra_cmdline+=" extra_mirrorlist='$finalos_mirrorlist'"
|
||||
elif [ -n "$nextos_mirrorlist" ]; then
|
||||
extra_cmdline+=" extra.mirrorlist='$nextos_mirrorlist'"
|
||||
extra_cmdline+=" extra_mirrorlist='$nextos_mirrorlist'"
|
||||
fi
|
||||
|
||||
# cloudcone 特殊处理
|
||||
if is_grub_dir_linked; then
|
||||
finalos_cmdline+=" extra.link_grub_dir=1"
|
||||
finalos_cmdline+=" extra_link_grub_dir=1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
12
trans.sh
12
trans.sh
@ -322,7 +322,7 @@ extract_env_from_cmdline() {
|
||||
value=$(echo $line | cut -d= -f2-)
|
||||
eval "$key='$value'"
|
||||
fi
|
||||
done < <(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
|
||||
done < <(xargs -n1 </proc/cmdline | grep "^${prefix}_" | sed "s/^${prefix}_//")
|
||||
done
|
||||
}
|
||||
|
||||
@ -3556,13 +3556,13 @@ install_redhat_ubuntu() {
|
||||
|
||||
# 重新整理 extra,因为grub会处理掉引号,要重新添加引号
|
||||
extra_cmdline=''
|
||||
for var in $(grep -o '\bextra\.[^ ]*' /proc/cmdline | xargs); do
|
||||
if [[ "$var" = "extra.main_disk="* ]]; then
|
||||
for var in $(grep -o '\bextra_[^ ]*' /proc/cmdline | xargs); do
|
||||
if [[ "$var" = "extra_main_disk="* ]]; then
|
||||
# 重新记录主硬盘
|
||||
refind_main_disk
|
||||
extra_cmdline="$extra_cmdline extra.main_disk=$main_disk"
|
||||
extra_cmdline="$extra_cmdline extra_main_disk=$main_disk"
|
||||
else
|
||||
extra_cmdline="$extra_cmdline $(echo $var | sed -E "s/(extra\.[^=]*)=(.*)/\1='\2'/")"
|
||||
extra_cmdline="$extra_cmdline $(echo $var | sed -E "s/(extra_[^=]*)=(.*)/\1='\2'/")"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -3588,7 +3588,7 @@ install_redhat_ubuntu() {
|
||||
insmod all_video
|
||||
search --no-floppy --label --set=root installer
|
||||
loopback loop /ubuntu.iso
|
||||
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline extra.kernel=$kernel --- $console_cmdline
|
||||
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline extra_kernel=$kernel --- $console_cmdline
|
||||
initrd (loop)/casper/initrd
|
||||
}
|
||||
EOF
|
||||
|
12
ubuntu.yaml
12
ubuntu.yaml
@ -20,10 +20,10 @@ autoinstall:
|
||||
# https://askubuntu.com/questions/1302392/ubuntu-server-20-04-setup-stuck-at-block-probing-did-not-discover-any-disks
|
||||
mount | grep /isodevice && { losetup -d /dev/loop0; umount -l /isodevice; } || true
|
||||
|
||||
# 提取 extra.confhome extra.kernel
|
||||
# 提取 extra_confhome extra_kernel
|
||||
prefix=extra
|
||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo $var | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||
done
|
||||
|
||||
# 生成分区信息
|
||||
@ -49,10 +49,10 @@ autoinstall:
|
||||
# 还原 DNS
|
||||
# sed -i -E 's/^#(nameserver )/\1/' /etc/resolv.conf
|
||||
|
||||
# 提取 extra.confhome
|
||||
# 提取 extra_confhome
|
||||
prefix=extra
|
||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo $var | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||
done
|
||||
|
||||
# 下载合并分区脚本
|
||||
|
Loading…
x
Reference in New Issue
Block a user